简体   繁体   English

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

[英]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.

相关问题 如何保持您的旧迁移作为参考? - How to keep your old migration as reference? Zend数据库表? 还是您自己的SQL? - Zend DB Table ? Or SQL by your own? 根据旧列将值添加到新的mySQL db表列中 - Adding values into a new mySQL db table column depending on an old column 我们不能重写迁移表并重置迁移文件,而不使用列修饰符吗? - Can't we rewrite migration table and reset the migration file instead of using column modifiers? 这是实现“忘记密码?”功能的好方法吗? - Is this a good way to implement “forgot your password?” feature? 您是高数据库,可扩展站点的理想平台吗? - Your ideal platform for a high db, scalable site? SQLSTATE[42000]:语法错误或访问冲突:1064 你的 SQL 语法有错误; 制作迁移表时出错 - SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; Error making a migration table 从测试数据库更新生产数据库的脚本 - Script to update your production DB from test DB 如何在PHP中构建旧数组的新数组? - How to construct new array base on your old array in PHP? 在我的本地Web服务器上迁移了旧的WP博客后,我得到白屏,为什么? wp_options DB表有问题吗? - After migration of an old WP blog on my local web server I obtain white screen, why? is it a wp_options DB table problems?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM