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   1386 Views

Avatar
x75

Community Member, 42 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 [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

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, 42 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