ruby on rails - Why directly changing a migrate file does not change the schema file? -
my current migrate file is
class createmovies < activerecord::migration def create_table :movies, :force => true |t| t.string :title t.string :rating t.text :description t.datetime :release_date # add together fields allow rails automatically maintain track # of when movies added or modified: t.timestamps end end def downwards drop_table :movies end end i seek alter release_date type integer. straight alter file
class createmovies < activerecord::migration def create_table :movies, :force => true |t| t.string :title t.string :rating t.text :description t.integer :release_date # add together fields allow rails automatically maintain track # of when movies added or modified: t.timestamps end end def downwards drop_table :movies end end please pay attention, release_date type has been changed. after run
bundle exec rake db:migrate
it still produce same schema file before. confused.
it's because you've run migration. before want alter it, should rollback first:
bundle exec rake db:rollback then should modify , run again:
bundle exec rake db:migrate ruby-on-rails ruby
No comments:
Post a Comment