I generated a User model using this command:
rails generate model User name:string date_birth:date age:int...
As you can see I made a mistake. I entered a date of birth and an age. Now I also migrated into a mySql database. Is there any way to just delete the age field?
Edit: Is it also possible to add a field?
Create a new migration with
rails g migration migrationname
and in the migration's up method run the following
remove_column :users, :age
run rake db:migrate and you are good to go.
At least two choices:
rake db:rollback
, delete the field from the migration and then re-run rake db:migrate
rails generate migration new_migration
.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With