The snapshot
command has two modes. When run without options, it will gather the current state of the database and show a text-based version of the schema to STDOUT. When
run with the --snapshotFormat=JSON
option, creates a JSON file that represents the current state of your database. A snapshot is like a photograph of your database that
can be used in the diff or diffChangeLog commands.
The snapshot
command is typically used when you want to quickly compare changes in your database or keep a record of your current database state. Snapshots can also be used to compare:
Note: Running a
diff
command using at least one snapshot.json file is faster than using adiff
command with two online databases. However, keep in mind that a snapshot will no longer reflect the current state of the database if the database is changed with theupdate
command or if it is changed manually.
To take a snapshot of your database:
Note: For information on how to configure your liquibase.properties file, view the Creating & Configuring your liquibase.properties File topic in the knowledge base.
liquibase --outputFile=myschemaSnapshot.json snapshot --snapshotFormat=json
You can use the JSON format snapshot file in the diff and diffChangeLog commands. One typical workflow is:
liquibase update
to ensure it has the latest schema.liquibase --outputFile=before.json snapshot --snapshotFormat=json
liquibase --referenceUrl=offline:mysql?snapshot=before.json diffChangeLog
liquibase changeLogSync
The format for the database URL when using a snapshot is:
The <dbtype>
in that URL should be the Type Name from the list of supported databases, and the <path/to/snapshot.json>
is a path relative to where the command is running.
The snapshot
command produces a JSON file that contains all your objects and places the file in the same directory as your changelog.
Liquibase Community snapshot
categories:
Liquibase Pro snapshot
categories: