是否可以为表中未使用的列重写旧的数据库迁移?

是否可以为表中未使用的列重写旧的数据库迁移?

问题描述:

Removing unused code is a good practice. But is DB migrations script file an exception in this practice?

I have to maintain a Laravel application and I'm in the process of cleaning up unused code and I found out I have lots migrations scripts. My migration includes adding and dropping table columns.

Anyone who have encountered the same situation? Thanks!

删除未使用的代码是一种很好的做法。 但是在这种做法中,数据库迁移脚本文件是一个例外吗? p>

我必须维护一个Laravel应用程序,我正在清理未使用的代码,我发现我有很多迁移脚本。 我的迁移包括添加和删除表列。 p>

遇到同样情况的人? 谢谢! p> div>

If the migration does not affect anything on the database, then it is fine to remove them.

But, if they affect, even a little part like adding/removing (same or different) columns, changing types ... then look up current data carefully if your in PRODUCTION; otherwise, refactoring before production is good.

If you know you wont need does migration files later in your project lifespan, remove it but i advice you backing up your application before.