This is the issue I am facing while working on one of our confluence plugin bugs. In the earlier stages of development of this plugin, the previous developers forgot to add a “@NotNull” constraint on one column, say ‘ColA’, in the Active Object Entity code. Now we figured out we need to add that constraint back again. But what will happen is that the plugin will fail to install in a confluence instance that already has the null value set for ColA. For such scenarios we need something on the lines of the steps below:
- If this is not the first installation of the plugin AND if the AO doesnt have a not null constraint for that column yet, then check if that column ColA has a null value set.
- If there is a null value set for ColA, then prepopulate it with a random value and THEN apply “@NotNull” constraint on that ColA.
Are the above two steps possible to be done in any way from the Active Objects Java code itself? Any pointers here would be very helpful.
PLEASE NOTE : I also tried using ActiveObjectsUpgradeTask like so : https://bitbucket.org/serverecosystem/ao-tutorial/src/c8ec3147f0d4a35bbfef11d52493cb49ee2afa88/src/main/java/com/atlassian/tutorial/ao/todo/upgrade/v1/TodoUpgradeTask001.java?at=master&fileviewer=file-view-default, in my case I just added a @NotNull constraint in the ‘upgraded’ object. But that didnt help me because it even updated the column entry even if it was already set in the previous plugin installation. We only want to upgrade the column in previous plugin installations if that column entry is set to null.