question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Table remarks overwritten by column remarks when new column is added to a table

See original GitHub issue

Environment

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)

image

image

ChangeLogOutput.txt ChangeLog.yaml.txt

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
neluconcommented, Jun 15, 2020

Workaround After addColumn you have to add setTableRemarks to put back the table remarks.

0reactions
nvoxlandcommented, Apr 13, 2022

This is a duplicate of #2301 and fixed by #2752.

I’ll close this version to centralize tracking

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solved: Overwrite columns - Microsoft Power BI Community
Solved: Hi, When I add column only in excel (the data loaded from power query) and after it I add another column in...
Read more >
Excel 2013 - how to add extra columns to OLE DB table which ...
Create on a new sheet a table with two columns: Id and Comment. For each source record you want to comment you add...
Read more >
Avoid overwriting existing columns in data.table functions
I'm writing a function that takes a data.table as an argument. The column names of data.table are partially specified as arguments, but not...
Read more >
Add row to another table overwriting - Google Cloud Community
I have tried using the action to add rows to Engines table on Customer add/update but it overwrites the those columns with new...
Read more >
COMMENT - Snowflake Documentation
Adds a comment or overwrites an existing comment for an existing object. ... Comments can be added to individual table columns as well....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found