Jump to:

23480 Posts in 18951 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Force dev/build to drop unused columns?

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1459 Views
  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Force dev/build to drop unused columns? Link to this post

    Hi,

    I am getting a bit frustrated with backing up and restoring databases because (with mysql) I get a set of SQL inserts to run against the new database... so... in the situation where I had a field in a DataObject, then removed it, it is will still appear in the database export.

    How can I stop this happening? any ideas?

    Barry

  • charden
    Avatar
    Community Member
    7 Posts

    Re: Force dev/build to drop unused columns? Link to this post

    Hello,

    It sounds to me like all you have to do is manually drop the column(s) from the table(s) corresponding to the DataObject you have edited. Once this is done they would disappear from your backups (since they no longer exists).

    /dev/build will not drop columns for you and can not (to my knowledge) be configured to do so. If you ask me, it is sound behaviour since it keeps you safe from loosing data in the case of typos and accidental removal of keys/values in $db or $has_one.

  • ryanwachtl
    Avatar
    Community Member
    46 Posts

    Re: Force dev/build to drop unused columns? Link to this post

    As I understand it, if you have removed a field in your DataObject model you will also have to manually drop the columns in the MySQL database table if you don't want them showing up in your SQL exports.

    The SQL would be something like:

    ALTER TABLE `MyTable`
    DROP `MyLegacyField`

    or you can use phpMyAdmin to drop the fields.

  • swaiba
    Avatar
    Forum Moderator
    1792 Posts

    Re: Force dev/build to drop unused columns? Link to this post

    thanks for these guys, this is what I have done, and I do appreciate that most web developers would be happy with having old data swimming around. I am working with a very large database and this is not only confusing when looking at the data itself but it also increases the size quite alot.

    1459 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.