Database / Liquibase interview questions
How do you write Liquibase changeLogs in YAML format?
YAML is a supported Liquibase changeLog format that many teams prefer for its readability compared to verbose XML. The structure maps directly to the XML model — databaseChangeLog is the root, containing a list of changeSet entries, each with an id, author, and a list of changes.
databaseChangeLog:
- changeSet:
id: 1
author: lena
changes:
- createTable:
tableName: product
columns:
- column:
name: id
type: BIGINT
autoIncrement: true
constraints:
primaryKey: true
nullable: false
- column:
name: name
type: VARCHAR(200)
constraints:
nullable: false
- column:
name: price
type: DECIMAL(10, 2)
- changeSet:
id: 2
author: lena
context: prod
changes:
- addColumn:
tableName: product
columns:
- column:
name: sku
type: VARCHAR(50)
rollback:
- dropColumn:
tableName: product
columnName: skuYAML changeLogs support all the same features as XML: preconditions, contexts, labels, rollback, include/includeAll. The root changeLog file uses the same include mechanism:
databaseChangeLog:
- includeAll:
path: db/changelog/releases/v1.0/
- includeAll:
path: db/changelog/releases/v1.1/One common pitfall with YAML changeLogs: YAML is whitespace-sensitive, and incorrect indentation causes silent parsing errors or wrong structure interpretation. Use a YAML linter or IDE plugin that validates structure. Also note that the default Spring Boot changeLog file is YAML format (db.changelog-master.yaml), so new Spring Boot projects automatically use YAML unless configured otherwise.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
