Reputation: 389
We have a case in which one of the table column name use a suffix "_id". The migration code :
create_table :companies do |t|
t.integer :ref_id
t.string :name
end
When running db:migrate, it fails, because rails tried to create a foreign key constraint for ref_id, and found that there is no table called "refs". In our case "ref_id" is not a foreign key.
Is there a way for us to prevent rails to create foreign key constraint for that column?
Upvotes: 3
Views: 141
Reputation: 44715
It seems you have a schema_plus
gem. You can do:
create_table :companies do |t|
t.integer :ref_id, foreign_key: false
t.string :name
end
Upvotes: 3