If you change your active objects properties, what happens to existing tables in the DB?

Carl Myers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 4, 2012

I need to store longer data than the default (which seems to be varchar(255) for strings). However, we've already started using my plugin in production, and the prod database already has a table with the schema of varchar(255). If I add annotations similar to what is mentioned in this question:
https://answers.atlassian.com/questions/80200/active-objects-unlimited-string-field-length

What will happen when I load that plugin into my prod instance? Will the old data be migrated? Will it go away? Will a new differently-named table be created then I can migrate the data manually? Any advice?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

4 votes
Answer accepted
Samuel Le Berrigaud
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 4, 2012

Hi Carl,

if you simply change your schema (Active Objects interfaces) AO will try to update the database schema to reflect those change.

Note that this is not always possible. For example most databases won't let you change from a VARCHAR to an INTEGER column, or decrease the size of columns.

In your case this is a change that _should_ work. However I'd make sure to test it before releasing in production. Depending on how many databases you need to support this will be a more or less tedious thing to do.

The general approach to changing column types though is don't do it, add a new column with the new type and migrate the data, either lazily in your code or using the AO plugin's migration capability. As always test before going into production.

Some more information can be found here: https://developer.atlassian.com/display/AO/Upgrading+your+plugin+and+handling+data+model+updates

Carl Myers
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 4, 2012

SaM - Thanks, this is a great answer! I appreciate it!

XXX XXX November 13, 2013

But the question remains, what if we have to do it? And what can we do while developping in order to reset a table? (change column from null to not null for example). I would like to recreate all the tables of my ActiveObjects to avoid problem. Is there a way to do that?

Yagnesh Bhat
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 17, 2018

@Samuel Le Berrigaud, what if I need to add an additonal column to an existing active objects table in production. I have added it via the interface that extends Entity and done necessary changes in the service classes. However, it looks like the column is not getting updated. I have the Preload annotation set for the interface, but the column in simply not getting updated.

 

I tried looking into the documentation you provided for some hints : https://developer.atlassian.com/display/AO/Upgrading+your+plugin+and+handling+data+model+updates

 

But at the moment its taking me to documentation home page.

 

Please advise.

TAGS
AUG Leaders

Atlassian Community Events