databasemigrationliquibasecorda

Want to replace old liquibase migration script file with new ones


I am using liquibase scripts with Cordapp. And previously the first version databaseChangeLog file was having all table creations in one single change set and in a later point of time we have split it into different databaseChangeLog having each changeset.

Now the problem is some production testing environments have the data in it with the older script, but we want to use the new scripts.

The change done is like →

Old: abc-master.xml contained abc-init.xml (usual way)|

Now: abc-master.xml contains abc-v1.xml and abc-v1.xml contains table-v1.xml files for each table creation

Solution we were thinking is like,

create new tables with slight name change → then copy the data from old tables here → then drop old tables. So then we can remove old tables and old scripts (i assume)

Still the DATABASECHANGELOG will probably have the old scripts data, would that be a problem? Or is there a far better way to do this?

Many thanks.


Solution

  • we are planning to go with

    <preConditions onFail="MARK_RAN">
           <not>
               <tableExists tableName="MY_NEW_TABLE"/>
           </not>
       </preConditions>
    

    For all those table creation changeset in new distributed structure ones, so our assumptions are:

    We can keep this new structure alone in code & remove the old INIT file. For environments having existing data, eventhough these new structure of changesets will be considered as new changeset to run, the preconditions will prevent it running. For fresh db deployments, it will work as expected, by creating all the required tables.