Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Rename Image Field

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

Page: 1
Go to End
Author Topic: 1359 Views
  • x75
    Avatar
    Community Member
    42 Posts

    Rename Image Field Link to this post

    Hi,

    is there a way to rename a filed in the model, while preserving it's data?

    The reason why I'm asking:
    I have:

    static $has_one = array(
    'Image' => 'Image', ...

    in a page. This causes problems with tinyMCE (see here). On my other projects i just removed it and added a new image called PageImage. But then I had to manualy reselect all the images. I can't do this on the current project. There are way to many pages with images. So I'm wondering if it is possible to rename the image field and keep all the data.

    Thanks
    Johannes

  • baba-papa
    Avatar
    Community Member
    279 Posts

    Re: Rename Image Field Link to this post

    I would rename the column in the databases table then rename the code. I never tried this. I recommand to try this on a developing system.

  • Hamish
    Avatar
    Community Member
    712 Posts

    Re: Rename Image Field Link to this post

    If you rename it, and manually modify the table with the new name at the same time, then run dev/build it *should* work. Backup your database first tho

  • x75
    Avatar
    Community Member
    42 Posts

    Re: Rename Image Field Link to this post

    Hi,

    thank you both for your answers. I was afraid there might be some backup tables or logs that would need to be updatet to...

    I'll try my luck in renaming like you sugessted.

    Thanks
    Johannes

    1359 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.