I have a Java application that initializes a database with the following schema
Have a conditional remove-if-exists for the users table (like I already have added to the start of the authservice changelog file)?
Now I would like to replace the users table in that database with a users table created by a different application:
And now I'm pondering how do accomplish this:
- Remove the users table from the original changeset (the changeset setting up the schema for the ukelonn application)?
- This will work for setting up a brand new ukelonn database
- This will fail for existing ukelonn databases, because the changeset's checksum doesn't match the one in the changelog of the database
- This works for existing ukelonn databases
- This works for new ukelonn databases if the ukelonn changeset is run first (and I don't think I can arrange that)
- This fails in a new database if the authservice database liquibase runs before the ukelonn database, because then ukelonn schema creation changeset will break because a users table already exists in the database (and making the users table creation conditional will change the changeset checksum and break existing ukelonn databases in the same way removing the table will)
Lessons learned:
- don't make the initial schema creation a single big changeset
- make all table creations conditional