✅ Short Answer
Yes, Liquibase can generate a changelog from an existing database schema using the generateChangeLog command.
This reverse-engineers the current database structure into a changelog file (XML, YAML, JSON, or SQL) so you can start tracking and versioning it with Liquibase.
🔎 How It Works
You run:
liquibase generateChangeLog \
--url=jdbc:your_database_url \
--username=your_user \
--password=your_pass \
--changeLogFile=initial-changelog.xml
🔹 Liquibase connects to your database
🔹 Reads the current schema (tables, columns, constraints, indexes, sequences…)
🔹 Writes them out as a Liquibase changelog
You can specify:
--changeLogFile→ path to write the changelog--format→ output format: XML (default), YAML, JSON, or SQL
🧪 Example Output (XML)
<changeSet id="1" author="liquibase">
<createTable tableName="users">
<column name="id" type="BIGINT" autoIncrement="true"/>
<column name="email" type="VARCHAR(255)"/>
</createTable>
</changeSet>
⚠️ Things to Keep in Mind
- ✅ Great for bootstrapping Liquibase into an existing project
- ❌ Not ideal for ongoing migrations — generated changelogs may be large and unstructured
- ✅ After generation, you should clean up, organize, and commit to version control
📌 Key Takeaways
✅ Liquibase can generate a changelog from your existing DB schema using generateChangeLog
✅ This is ideal for initial setup or reverse-engineering legacy databases
✅ You can output in XML, YAML, JSON, or SQL formats and customize the scope