简体   繁体   English

如何在SilverStripe中删除过时的数据库列

[英]How to remove obsolete database columns in SilverStripe

Is there a convenient way to remove obsolete table columns from the database? 有没有方便的方法从数据库中删除过时的表列 I'm wondering if there is a more convention-based solutions rather than logging into PHPMyADMIN and deleting columns manually. 我想知道是否有更多基于约定的解决方案而不是登录PHPMyADMIN并手动删除列。

Example When installing SilverStripe-Fluent and adding an extra locale (eg nz-NZ) the module will split each SiteTree record to add extra translation columns with prefix _nz-NZ . 示例安装SilverStripe-Fluent并添加额外的区域设置(例如nz-NZ)时,模块将拆分每个SiteTree记录以添加前缀为_nz-NZ额外翻译列。 Suppose we delete the extra locale (nz-NZ), the columns will stay there after a /dev/build. 假设我们删除了额外的语言环境(nz-NZ),列将在/ dev / build之后保留在那里。

there was a great module DBPlumber for version 2.4 that had this function but I'm guessing you are using a later version! 版本2.4有一个很棒的模块DBPlumber有这个功能,但我猜你使用的是更高版本! It would be great if this was upgraded for V3. 如果升级到V3,那将会很棒。

The module artefact cleaner would be ideal. 模块人工制品清洁剂将是理想的。 Its description from the github page is... 它从github页面的描述是......

Find and optionally delete disused tables and fields in a SilverStripe database. 查找并选择删除SilverStripe数据库中的废弃表和字段。

During development of a SilverStripe application it is common to delete a data object class or remove a field from a data object. 在开发SilverStripe应用程序期间,通常删除数据对象类或从数据对象中删除字段。 This leaves obsolete columns and tables in your database. 这会在数据库中留下过时的列和表。 Because these columns or tables may contain data that you still want, the SilverStripe framework doesn't delete those automatically. 由于这些列或表可能包含您仍需要的数据,因此SilverStripe框架不会自动删除这些数据。 This task displays the obsolete columns and tables in the form of SQL DROP and ALTER commands. 此任务以SQL DROP和ALTER命令的形式显示过时的列和表。 It also provides a way to delete them. 它还提供了删除它们的方法。 If you do that, there is no undo, so always make a backup first. 如果您这样做,则没有撤消,因此请始终先进行备份。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM