Database / Liquibase interview questions
How do you integrate Liquibase with Spring Boot?
Spring Boot has first-class auto-configuration for Liquibase. When you add the spring-boot-starter-data-jpa or the dedicated liquibase-core dependency alongside Spring Boot, the auto-configuration detects the Liquibase JAR and automatically runs migrations at application startup before the application context fully initialises. This means your schema is always in sync before your application starts serving requests.
Maven dependency:
<dependency> <groupId>org.liquibase</groupId> <artifactId>liquibase-core</artifactId> </dependency>
By default, Spring Boot looks for the changeLog at classpath:db/changelog/db.changelog-master.yaml. You can override this and other settings in application.properties:
spring.liquibase.change-log=classpath:db/changelog/db.changelog-master.xml spring.liquibase.enabled=true spring.liquibase.contexts=dev spring.liquibase.default-schema=myapp spring.liquibase.drop-first=false # NEVER true in production spring.liquibase.user=migration_user # separate low-privilege DB user for migrations spring.liquibase.password=secret
A good practice is running Liquibase with a separate database user (spring.liquibase.user) that has DDL permissions, while the main application datasource user has only DML rights. This limits the blast radius if the application is compromised — the app can read/write rows but cannot drop tables. The drop-first=true option drops the entire schema before running migrations and should never be enabled in production; it is occasionally useful in isolated test environments.
More Related questions...