This is the first version of my changelog.sql:
-- liquibase formatted sql
-- changeset kh:1
CREATE TABLE test_table (test_id INT, test_column VARCHAR(256), PRIMARY KEY (test_id))
--changeset kh:2
INSERT INTO test_table (test_id, test_column) VALUES(3,'saket');
This is an update of my changelog.sql (Added a column in the first changeset):
-- liquibase formatted sql
-- changeset kh:1
CREATE TABLE test_table (test_id INT, test_column VARCHAR(256), test_column2 VARCHAR(256), PRIMARY KEY (test_id))
--changeset kh:2
INSERT INTO test_table (test_id, test_column) VALUES(3,'saket');
I execute a liquibase update with the following command:
docker run --rm -v /changelog:/liquibase/changelog liquibase/liquibase \
--url=jdbc:postgresql://xxxxxxxxxx:5432/postgres \
--changelog-file=changelog.sql --username=xxxx \
--password=xxxx update
I get this error:
Caused by: liquibase.exception.ValidationFailedException: Validation Failed:
1 changesets check sum
changelog.sql::1::kh was: 8:46ea95d67274343c559a1c5ddc8ee33 but is now: 8:ab7361c532323a6a32bc79d230a46574
I understand that when running it in a productive environment, it should fail in order not to launch scripts again by mistake, but, in a non-productive environment, how should it work?
I imagine three solutions in a DevOps (NonProd) scenario:
- Restore database as the first step and execute changelog for specific version.
- For nonprod, ignore the checksum validation
- Modify the changelog and add a new changeset with the change.- For my taste, this is the least correct
In a non-production environment, it may be necessary to make changes to SQL until the new functionality is validated. What is the best practice, and is there any other solution?