Question

I have a Rails application which have a lot of migrations. Right now I want to redefine almost all the database structure, so most of those migrations will be useless.

What is the approach that I should take? Modify the existing tables with migrations that modify them, or remove those migrations and create new ones?

Thanks

Was it helpful?

Solution

In your database, if you want to modify your database migrations:

You can update migration file and can do updates on that migration by redoing it:

rake db:migrate:redo VERSION=001XXXXX

To down your existing migration:

rake db:migrate:down VERSION=001XXXXX

To up specific migration:

rake db:migrate:up VERSION=001XXXXX

OTHER TIPS

If you check in your schema.rb to the VCS, and you are not seeding the database in your existing migrations, then it's probably ok to delete or archive the old migrations. It is nowhere recommended to create database from migrations anyways. For that you should use the schema.rb only.

Found a nice article on this.

http://adventuresincoding.com/2010/02/how-to-clean-up-your-activerecord-migrations

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top