Java.DBMigrationTools.What is the difference between YAML and XML changelogs?

Short answer: there’s no functional difference — only readability, verbosity, and team preference.
Liquibase treats YAML and XML identically after parsing.


Core truth (interview-ready)

YAML and XML changelogs express the same Liquibase model; the difference is syntax, not capability.


Side-by-side comparison

Same change — XML

<databaseChangeLog>
  <changeSet id="create-users" author="stanley">
    <createTable tableName="users">
      <column name="id" type="bigint" autoIncrement="true">
        <constraints primaryKey="true"/>
      </column>
      <column name="email" type="varchar(255)">
        <constraints nullable="false" unique="true"/>
      </column>
    </createTable>
  </changeSet>
</databaseChangeLog>

Same change — YAML

databaseChangeLog:
  - changeSet:
      id: create-users
      author: stanley
      changes:
        - createTable:
            tableName: users
            columns:
              - column:
                  name: id
                  type: bigint
                  autoIncrement: true
                  constraints:
                    primaryKey: true
              - column:
                  name: email
                  type: varchar(255)
                  constraints:
                    nullable: false
                    unique: true

Practical differences that matter in teams

AspectYAMLXML
Verbosity✅ Less❌ More
Readability✅ Better for humans⚠️ Noisy
Diff / PR review✅ Cleaner❌ Harder
Tooling maturity⚠️ Good✅ Excellent
Strictness❌ Indentation-sensitive✅ Very strict
Schema validation❌ Weaker✅ Strong (XSD)

Pros & cons in real projects

YAML — why teams choose it

✅ Cleaner PRs
✅ Faster to write
✅ Less boilerplate
✅ Preferred by product teams

⚠️ Indentation errors can be subtle
⚠️ Less strict validation


XML — why enterprises still use it

✅ Strong schema validation (XSD)
✅ Clear structure for complex changelogs
✅ Better IDE auto-complete in some setups
✅ Familiar to long-time Liquibase users

❌ Verbose
❌ Harder to review
❌ Merge conflicts are uglier


What does not change (important)

No difference in:

  • execution order
  • rollbacks
  • contexts / labels
  • preconditions
  • checksums
  • safety guarantees

Liquibase converts both into the same internal representation.


Interview pitfalls ❌

  • “YAML is less powerful than XML” → wrong
  • “XML is safer by default” → misleading
  • “They run differently” → false

Interview-ready answer (2 sentences)

YAML and XML changelogs are functionally equivalent in Liquibase; they differ only in syntax and readability. YAML is usually preferred for cleaner diffs and faster authoring, while XML offers stricter validation and is common in older or highly regulated projects.

Senior rule of thumb

Choose YAML for humans, XML for tools — but don’t mix both without a clear convention.

This entry was posted in Без рубрики. Bookmark the permalink.