Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

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. Suppose we delete the extra locale (nz-NZ), the columns will stay there after a /dev/build.

like image 639
Semicolon Avatar asked Nov 09 '22 09:11

Semicolon


1 Answers

there was a great module DBPlumber for version 2.4 that had this function but I'm guessing you are using a later version! It would be great if this was upgraded for V3.

The module artefact cleaner would be ideal. Its description from the github page is...

Find and optionally delete disused tables and fields in a SilverStripe database.

During development of a SilverStripe application it is common to delete a data object class or remove a field from a data object. 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. This task displays the obsolete columns and tables in the form of SQL DROP and ALTER commands. It also provides a way to delete them. If you do that, there is no undo, so always make a backup first.

like image 129
Barry Avatar answered Nov 14 '22 23:11

Barry