In one of my migration files on my development box I have this DB2 request:
CALL SYSPROC.ADMIN_CMD('REORG TABLE COST_RULES.LOW_DLL_EXCEP');
This call seems to be needed for a subsequent ALTER on a column done in a subsequent migration. In the past the devops person manually executed the call to reorg on the test database, but I'd like to put it into the migration so it gets done automatically.
If I add this, it will change the checksum on the migration file, causing a flyway issue when the deployment happens. What Flyway steps should be taken before the deployed job works?
When a table has had certain kinds of alterations, or a certain number of alterations, Db2 can put the table into reorg pending
status.
When the table is NOT in reorg_pending
condition, it is not necessary to preform reorg at this time solely for the purposes of migrations.
Consider changing your migration to make reorg conditional, and also consider online reorg if the table type is compatible.
You can use view SYSIBMADM.ADMINTABINFO
and check REORG_PENDING='Y'
for your table to decide whether or not to perform a reorg. You can use an SQL PL anonymous block to run the conditional logic and conditional reorg.
You can use the INPLACE
option for reorg (and related options) if the table is suitable for online reorg.
You could also use an entirely separate migration, to test if any tables in your schema(s) of interest are in reorg_pending
state, and take appropriate action at that time, including checking the table type to see if an online reorg is appropriate. Such a migration would be re-runnable. It would have its own checksum.