I have recently discovered that a relationship between two of my tables is wrong and I would like to make the necessary changes - this involves dropping a foreign key on my accommodations table and adding a foreign key on my users table.
I have created a migration file using:
rails g migration ForeignKeyAdjustment
and then added this to the new migration file:
class ForeignKeyAdjustment < ActiveRecord::Migration
def self.up
remove_column :accommodations, :user_id
add_column :users, :accommodation_id, :integer
end
end
I then ran the migration using:
bundle exec rake db:migrate
and then used the console to check the column names in each table and the changes have not taken effect!
rails console
and
User.column_names
What am I missing?
p.s. would it be a major issue if I just deleted my models and the database migration files and generated new models from the terminal? It wouldn't take me long and no important data to consider.