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

前端 未结 2 1230
逝去的感伤
逝去的感伤 2021-02-08 20:58

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 cr

2条回答
  •  臣服心动
    2021-02-08 21:22

    I use rake db:setup and rake db:reset exclusively (never rake db:migrate) to install a new database, on a production server or on a new development machine. Those commands already use the schema.rb or structure.sql to recreate the database.

    That said, it is really easy to make a copy of schema.rb, use that as a new starting-point and delete all the old migrations.

    I prefer to keep my migrations for historic purposes, but that is a matter of taste.

提交回复
热议问题