Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

We have lots of database migration files - should we keep them?

We have around 100 database migration files. Many of them make schema changes which are irreversible. There are also later migrations which change or remove tables which were created in earlier migrations.

We are creating new databases straight from the schema.rb file, so we were wondering if there is any reason to keep the full set of migrations?

We would create a new migration which is based on our existing schema.rb.

like image 446
roo Avatar asked Feb 17 '12 01:02

roo


1 Answers

Yes, what you're proposing is considered a best practice.

I've done this with my old apps several times. You'll want to back your migrations up somewhere until you're satisfied all is well, of course, this is an important part of application maintenance - if you have a lot of old migrations, it can take forever to do a db:reset or to get a new development environment running.

like image 173
Mark Tabler Avatar answered Nov 11 '22 07:11

Mark Tabler