Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to handle active objects data model changes when upgrading a plugin?

jtw-ic January 28, 2013

Hi,

I recently changed the active objects data model of my plugin, which wasnt a big deal in the previous upgrades. This time however, I changed the annotation of a field of an active objects entity to "Unique", what is fine as long as there are no existing database entries with a null value in this field. In this case, the active objects update fails.

So the problem is, how can I make sure that the active objects update will not fail when someone is updating my plugin without knowing if there might be an entry in his database with a null value in the field that is now annotated as "Unique"? Is there a way to get rid of the the possible null values or fill them with dummy data in the customers database lazily before active objects tries to update the model?

I already read https://developer.atlassian.com/display/AO/Upgrading+your+plugin+and+handling+data+model+updates , but I couldnt figure out if thats what would help me to prepare and correct database values before the active objects update process.

Thank you!

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Alejandro Conde Carrillo
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.
January 28, 2013

The link you mentnion is right. You have to create a new class which implements com.atlassian.activeobjects.external.ActiveObjectsUpgradeTask and in the upgrade method you should do a find for all rows wich may cause problems (in your case the ones containing null values) and modify them as needed.

That task should run during the upgrade/installation of the plugin so your data is ready for the new model. It works in a similar way to the classes implementing PluginUpgradeTask, but for ActiveObjects.

jtw-ic January 28, 2013

Thank you Alex for your quick answer, I think I understood what you suggested. I'll give it a try!

TAGS
AUG Leaders

Atlassian Community Events