Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

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

Rename Image Field


Go to End


4 Posts   2156 Views

Avatar
x75

Community Member, 43 Posts

29 January 2010 at 11:06pm

Edited: 29/01/2010 11:07pm

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

Avatar
baba-papa

Community Member, 279 Posts

31 January 2010 at 1:54am

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.

Avatar
Hamish

Community Member, 712 Posts

1 February 2010 at 10:27am

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 :)

Avatar
x75

Community Member, 43 Posts

1 February 2010 at 11:02pm

Edited: 01/02/2010 11:03pm

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