2

After updating my gems, I'm not being able to run rails db:schema:load. The error reported is:

ActiveRecord::MismatchedForeignKey: Column `user_id` on table 
`user_applications` has a type of `int(11)`.
This does not match column `id` on `users`, which has type 
`bigint(20)`.

This has to do with some default int type for primary key change from rails 5.2 (or rails 5.1, I don't know). My question is: how should I "migrate" the db/schema? Or, can I set the primary key to be 32bit integer? Because I already tried in application.rb:

config.generators do |generator|
  generator.orm :active_record, primary_key_type: :integer
end

but it didn't do anything when running the aforementioned task.

ChuckE
  • 5,610
  • 4
  • 31
  • 59

1 Answers1

0

Move your old scheme file and create a new one:

$ rails db:schema:dump 
aarkerio
  • 2,183
  • 2
  • 20
  • 34
  • 1
    Thx! It sorta works, but some weird things happen: The `:limit` field from text columns gets erased, `using: :btree` also gets removed (I guess that is by design), and foreign key declarations (`add_foreign_key` calls) just vanish, is this expected? – ChuckE Oct 19 '18 at 09:47
  • Hard to know, can we see your migration file? – aarkerio Oct 19 '18 at 16:30
  • I don't think this has to do with the migration file (I want to migrate only the schema.rb). But `add_foreign_key` calls disappearing is indeed strange. – ChuckE Oct 22 '18 at 13:57