[英]Is it good to rewrite your old db migration for unused column in your table?
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. 我必须维护一个Laravel应用程序,并且正在清理未使用的代码,并且发现我有很多迁移脚本。 My migration includes adding and dropping table columns. 我的迁移包括添加和删除表列。
Anyone who have encountered the same situation? 有人遇到过同样的情况吗? Thanks! 谢谢!
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 ; 但是,如果它们影响了,即使只是一点点,例如添加/删除(相同或不同)列,更改类型...如果您在PRODUCTION中 ,则请仔细查找当前数据; otherwise, refactoring before production is good. 否则,在生产之前进行重构是好的。
如果您知道在项目寿命的后期不需要迁移文件,请将其删除,但是我建议您之前备份应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.