Liquibase Command snapshot

The snapshot command provided by Liquibase captures the current state of the database, it can also save the current state into the format provided in snapshotFormat attribute in the file name provided in outputFile attributes.

execute the below script into the database

create database appleDb;
use appleDb;
create table apple (apple_id bigint not null AUTO_INCREMENT , apple_name varchar(255), available CHAR(1), current_date_time datetime default now(), primary key (apple_id), CONSTRAINT uqniue_apple_name UNIQUE (apple_name)) engine=InnoDB;
insert into  apple (apple_name, available, current_date_time) values ("Macintosh", 'Y',  now());
insert into  apple (apple_name, available, current_date_time) values ("Fuji", 'Y',  now());
commit;

liquibase.properties (update changeLog File file format with SQL, XML, YAML, JSON as per changelog.mysql.)

liquibase.command.url:jdbc:mysql://localhost:3306/appleDb?createDatabaseIfNotExist=true&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
liquibase.command.username: root
liquibase.command.password: rootroot
snapshotFormat=json
outputFile=Snapshot.json

to create a snapshot of the current database, execute the command

liquibase snapshot

it will create a file named Snapshot.json, which will contain the current state of the database in JSON format

follow us on