I created quite a lot of migrations since the beginning of my rails app. Some of them where just for test purposes. I now have a lot of migrations that are totally useless (eg: create a table in a migration and drop it in the next one).
As schema.rb get updated once db:migrate is ran, is it possible to delete all the migrations and to start from the actual content of schema.rb ?
Yes, you can (and probably should) remove older migrations. There will come a point where your old migrations might no longer work since your model code will depend on later versions of your schema.
So by all means delete the migrations (you have them under source control, right?), and use
rake db:schema:load
to initialize a new database if you need to.
UPDATE: The Rails guide now has something similar to say about this: http://guides.rubyonrails.org/active_record_migrations.html#schema-dumping-and-you
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