Table remarks overwritten by column remarks when new column is added to a table
See original GitHub issueEnvironment
Liquibase Version: 3.8.5, 4.0.0-beta1
Liquibase Integration & Version: CLI
Liquibase Extension(s) & Version:
Database Vendor & Version: MySQL 5.7
Operating System Type & Version: Win10
Description
The column remarks from an addColumn change overwrite the table remarks.
Steps To Reproduce
Create a change and add a changeSet createTable, add remarks for table and columns. Add another changeSet addColumn, add remarks for column. Run the changelogs against a database with updateSql. See the attached files to the next comment. Examine the output sql.
Actual Behavior
Liquibase Community 3.8.5 by Datical – ********************************************************************* – Update Database Script – ********************************************************************* – Change Log: ./ChangeLog.yaml – Ran at: 6/12/20 8:54 PM – Against: user01@localhost@jdbc:mysql://localhost:3307/msrv_t15 – Liquibase version: 3.8.5 – *********************************************************************
– Create Database Lock Table
CREATE TABLE msrv_t15.DATABASECHANGELOGLOCK (ID INT NOT NULL, LOCKED
BIT(1) NOT NULL, LOCKGRANTED datetime NULL, LOCKEDBY VARCHAR(255) NULL, CONSTRAINT PK_DATABASECHANGELOGLOCK PRIMARY KEY (ID));
– Initialize Database Lock Table DELETE FROM msrv_t15.DATABASECHANGELOGLOCK;
INSERT INTO msrv_t15.DATABASECHANGELOGLOCK (ID, LOCKED
) VALUES (1, 0);
– Lock Database
UPDATE msrv_t15.DATABASECHANGELOGLOCK SET LOCKED
= 1, LOCKEDBY = ‘test (192.168.1.6)’, LOCKGRANTED = ‘2020-06-12 20:54:53.868’ WHERE ID = 1 AND LOCKED
= 0;
– Create Database Change Log Table
CREATE TABLE msrv_t15.DATABASECHANGELOG (ID VARCHAR(255) NOT NULL, AUTHOR VARCHAR(255) NOT NULL, FILENAME VARCHAR(255) NOT NULL, DATEEXECUTED datetime NOT NULL, ORDEREXECUTED INT NOT NULL, EXECTYPE VARCHAR(10) NOT NULL, MD5SUM VARCHAR(35) NULL, DESCRIPTION
VARCHAR(255) NULL, COMMENTS VARCHAR(255) NULL, TAG VARCHAR(255) NULL, LIQUIBASE VARCHAR(20) NULL, CONTEXTS VARCHAR(255) NULL, LABELS VARCHAR(255) NULL, DEPLOYMENT_ID VARCHAR(10) NULL);
– Changeset ./ChangeLog.yaml::1::me CREATE TABLE msrv_t15.table01 (id BIGINT NOT NULL, column01 SMALLINT NOT NULL COMMENT ‘column01 description’, column02 SMALLINT NOT NULL COMMENT ‘column02 description’, CONSTRAINT PK_TABLE01 PRIMARY KEY (id)) COMMENT=‘table01 description’;
ALTER TABLE msrv_t15.table01 COMMENT = ‘table01 description’;
INSERT INTO msrv_t15.DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION
, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES (‘1’, ‘me’, ‘./ChangeLog.yaml’, NOW(), 1, ‘8:15f66f4dd66c63a0560aa2114602a00a’, ‘createTable tableName=table01’, ‘’, ‘EXECUTED’, NULL, NULL, ‘3.8.5’, ‘1984495461’);
– Changeset ./ChangeLog.yaml::2::me ALTER TABLE msrv_t15.table01 ADD column03 BIGINT NULL COMMENT ‘column03 description’;
ALTER TABLE msrv_t15.table01 COMMENT = ‘column03 description’;
INSERT INTO msrv_t15.DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION
, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES (‘2’, ‘me’, ‘./ChangeLog.yaml’, NOW(), 2, ‘8:adfd8cf083db547ed1e7454727367879’, ‘addColumn tableName=table01’, ‘’, ‘EXECUTED’, NULL, NULL, ‘3.8.5’, ‘1984495461’);
– Release Database Lock
UPDATE msrv_t15.DATABASECHANGELOGLOCK SET LOCKED
= 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;
Liquibase command ‘updateSql’ was executed successfully.
You will find this in the output sql: ALTER TABLE msrv_t15.table01 COMMENT = ‘column03 description’; It shouldn’t be there.
Expected/Desired Behavior
The generated sql shouldn’t update the table description after adding a new column.
Screenshots (if appropriate)
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top GitHub Comments
Workaround After addColumn you have to add setTableRemarks to put back the table remarks.
This is a duplicate of #2301 and fixed by #2752.
I’ll close this version to centralize tracking