Can I delete all migration files and start from scratch?

蓝咒 提交于 2019-12-02 06:45:20

Migrations are used to update your database or to rollback to previous versions. Once migrations have been run in all environments, they're never looked at again (unless you're manually messing around with the schema_migrations table of course). Once all your migrations have been run, the current state of the database is in db/schema.rb (or db/structure.sql) so schema.rb is all you need to start with a fresh database.

I tend to clear out old migrations every couple months just to cut down on clutter.

As far as the version goes, you can leave it alone. As long as it represent a time in the past (such as 2017-11-29 02:35:38) and it is lower than any migrations that need to be run (which doesn't apply as you're deleting them all) then it doesn't matter what it is.

Go ahead and clear out all the migrations, they're already reflected in schema.rb and you can always dig them out of revision control if you really need them.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!