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.

Data Model Questions

Rename Image Field


Reply

4 Posts   1371 Views

Avatar
x75

29 January 2010 at 11:06pm (Last edited: 29 January 2010 11:07pm), Community Member, 42 Posts

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 [url=http://www.silverstripe.org/data-model-questions/show/273701#post273701](see here)[/url]. 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

31 January 2010 at 1:54am Community Member, 279 Posts

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

1 February 2010 at 10:27am Community Member, 712 Posts

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

1 February 2010 at 11:02pm (Last edited: 1 February 2010 11:03pm), Community Member, 42 Posts

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