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.

restore best-effort behavior of afterColumn

See original GitHub issue

Environment

Liquibase Version: 4.13.0

Liquibase Integration & Version: gradle, spring boot

Liquibase Extension(s) & Version:

Database Vendor & Version: mysql, postgresql

Operating System Type & Version:

Infrastructure Type/Provider:

Description

https://github.com/spinnaker/orca (migrations are here) uses afterColumn in some of its migrations, and tests those migrations using both mysql and postgresql. Before version 4.13.0, and specifically https://github.com/liquibase/liquibase/pull/2943, afterColumn worked with mysql, and did nothing with postgresql. With 4.13.0, afterColumn still works with mysql, but throws a validation error with postgresql. For example:

PgTopApplicationExecutionCleanupPollingNotificationAgentSpec > initializationError FAILED
    com.netflix.spinnaker.kork.sql.test.SqlTestUtil$DatabaseInitializationFailed: liquibase.exception.ValidationFailedException: Validation Failed:
         4 changes have validation failures
              addAfterColumn is not allowed on postgresql, db/changelog/20180510-add-legacy-id-fields.yml::add-legacy-id-fields::cthielen
              addAfterColumn is not allowed on postgresql, db/changelog/20180510-add-legacy-id-fields.yml::add-legacy-id-fields::cthielen
              addAfterColumn is not allowed on postgresql, db/changelog/20180510-add-legacy-id-fields.yml::add-legacy-id-fields::cthielen
              addAfterColumn is not allowed on postgresql, db/changelog/20180510-add-legacy-id-fields.yml::add-legacy-id-fields::cthielen
        at com.netflix.spinnaker.kork.sql.test.SqlTestUtil.initDatabase(SqlTestUtil.java:248)
        at com.netflix.spinnaker.kork.sql.test.SqlTestUtil.initTcPostgresDatabase(SqlTestUtil.java:97)
        at com.netflix.spinnaker.orca.sql.cleanup.PgTopApplicationExecutionCleanupPollingNotificationAgentSpec.getDatabase(TopApplicationExecutionCleanupPollingNotificationAgentSpec.groovy:161)

        Caused by:
        liquibase.exception.ValidationFailedException: Validation Failed:
             4 changes have validation failures
                  addAfterColumn is not allowed on postgresql, db/changelog/20180510-add-legacy-id-fields.yml::add-legacy-id-fields::cthielen
                  addAfterColumn is not allowed on postgresql, db/changelog/20180510-add-legacy-id-fields.yml::add-legacy-id-fields::cthielen
                  addAfterColumn is not allowed on postgresql, db/changelog/20180510-add-legacy-id-fields.yml::add-legacy-id-fields::cthielen
                  addAfterColumn is not allowed on postgresql, db/changelog/20180510-add-legacy-id-fields.yml::add-legacy-id-fields::cthielen
            at liquibase.changelog.DatabaseChangeLog.validate(DatabaseChangeLog.java:307)
            at liquibase.Liquibase.lambda$update$1(Liquibase.java:228)
            at liquibase.Scope.lambda$child$0(Scope.java:180)
            at liquibase.Scope.child(Scope.java:189)
            at liquibase.Scope.child(Scope.java:179)
            at liquibase.Scope.child(Scope.java:158)
            at liquibase.Liquibase.runInScope(Liquibase.java:2400)
            at liquibase.Liquibase.update(Liquibase.java:208)
            at liquibase.Liquibase.update(Liquibase.java:194)
            at liquibase.Liquibase.update(Liquibase.java:190)
            at liquibase.Liquibase.update(Liquibase.java:182)
            at com.netflix.spinnaker.kork.sql.test.SqlTestUtil.initDatabase(SqlTestUtil.java:246)
            ... 2 more

One use of afterColumn is:

    - addColumn:
        tableName: orchestration_stages
        columns:
        - column:
            name: legacy_id
            type: varchar(500)
            afterColumn: id

Expected/Desired Behavior

https://github.com/liquibase/liquibase/pull/2943 notes that this is the new behavior. I’d love a way to go back to the old behavior, where addColumn works where supported, and is ignored where it’s not. There are some migrations where adding e.g.:

modifySql:
  dbms: "mysql"
  append:
    value: " after id"

works, but many where it doesn’t.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:3
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
kataggartcommented, Jul 27, 2022

thanks @jfisbein - also saw you comment over on #3094. Same issue, different command. Stay tuned.

1reaction
dbyron-sfcommented, Jul 25, 2022

Turns out that https://github.com/liquibase/liquibase/issues/3094#issuecomment-1194426594 is actually the heart of the matter:

I’m mainly interested in my changelogs not breaking, and your change breaks them both ways… Leaving the postition=“x” in breaks things, removing the attribute also breaks things, since the signature of the changeset changes.

And yes, there is also the thing about different platforms, which is one of the main selling points for Liquibase 😃

So even if it’s possible to do things with custom sql, the changeset checksums fail.

I think what I’m really asking for is to change this from an enhancement to a bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Restore MYSQL Values after Column Variable Change
I copied the table real quick to preform some tests. Simply switching back the column to varchar(30) restored the previous values.
Read more >
RTI Recording Service
Records using either Best Effort or Reliable communications. ... To restore and see the list of all topics, remove (erase) the search string...
Read more >
Apache Impala SQL Reference - Cloudera Documentation
This behavior differs from other popular database systems. To get the expected result ... MAX_ROW_SIZE are processed on a best-effort basis.
Read more >
Polarimetric signature of the oceans as detected by near ...
In this sense, it would be ideal to conduct the astronomical polarimetry of Earth ... 3, where we retrieve the polarimetric signature of...
Read more >
Kafka Streams and ksqlDB - Confluent Official Asset Library
Systems can rebuild their state anytime by replaying the events in a ... Offsets start at 0 and they enable an important behavior:...
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