Reputation:
My 'user' model has 'email:string'. I added 'null: false' to _create_users.rb and migrated.
t.string :email, null: false
After that, I removed 'null: false' from that _create_users.rb and run rake db:migrate
. However, 'null: false' remains in schema.rb. I want to remove this.
What should I do? Is it ok to edit shema.rb directly?
Upvotes: 1
Views: 466
Reputation: 44685
Once you run migration, rake db:migrate
will not rerun it. Try:
rake db:migrate:redo
if this is the most recent migration.
Note: If the migration has been pushed/deployed you should never change it afterwards as this will make other people local databases out of sync with your local database. It might cause this type of issues you will have discussions with a lot of 'it does work for me, s what's your problem?'.
In short - if you have to change the existing migration, don't do it and write a new one.
Upvotes: 1