Search code examples
spring-bootdatabase-migrationliquibase

Spring Boot Liquibase versioned database migration - dealing with different environments, db vendors and database credentials


I am considering using Liquibase for versioning database migrations for my Spring Boot API. I have been watching some videos about it before considering it and I find that they talk mostly about setting it and that is great.

But what I am concerned about is the typical enterprise environments where we have for example:

  1. multiple deployment environments like PROD, TEST, DEV. We have no rights to view or touch PROD environments database for example. Delegating database migration, in for example PROD environment, sounds dangerous to me.

  2. we connect to different database vendors such as PostGres, Oracle, MSSQL, DB2 within the same API

  3. in some cases, we will have to work on already existing tables, in other cases, we will have to create new tables

How does Liquibase deals with such cases?


Solution

    1. you can use generate-sql to generate sql's that needs to be executed and then DBAs could run those sql commands
    2. if there is something specific for some db vendor, you can create a specific changeSet with attribute dbms. Search for dbms here
    3. you should be more specific about issue here. You can use preconditions to check whether given script should be executed or not