Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"runOnChange" not working correctly after upgrade to version 4.10.0 #3255

Open
andres-3 opened this issue Sep 7, 2022 · 5 comments
Open

Comments

@andres-3
Copy link

andres-3 commented Sep 7, 2022

Environment

liquibase 4.10

spring boot

postgresql 13

linux

Description

After upgrade to liquibase 4.10.0, runOnChange attribute doesn't work correctly on those changesets, which were created with liquibase version 3.9.0: the changeset is in fact re-executed as it should, and the change is commit to database. However, row in databasechangelog table for such changeset is not updated, therefore also the old md5sum, dateexecuted and exectype fields etc. stay with old values from previous execution time. Another sideeffect of this problem is, that should we now re-modify the changeset so that it again contains the original content, then the changeset is not executed at all. This happens obviously because we are also switching back to the original md5sum checksum which is equal with the (incorrect) original entry still stored to databasechangelog table.

runOnChange attribute still works perfectly (the change is committed and databasechangelog table entry updated) if the consequetive executions of changesets are done under same liquibase version, no matter if 3.9.0 or 4.10.0

Steps To Reproduce

Scenario 1 (NOT OK):

  1. build simple spring boot application with liquibase 3.9.0.
  2. create test changeset, for example
    <changeSet id="Test changeset" author="test" runOnChange="true">
        <sql splitStatements="false">
            INSERT INTO test (value, timestamp) VALUES (1, NOW());
        </sql>
    </changeSet>
  1. OK: start/stop the application. We have now a corresponding row in test table and a row in databasechangelog
id              dateexecuted                exectype    md5sum                              liquibase
-----------------------------------------------------------------------------------------------------
Test changeset  2022-09-07 14:30:12.702375  EXECUTED    8:666e398c8992830cc4914f88fbe83dfb  3.9.0
  1. upgrade Spring Boot test application to liquibase 4.10.0
  2. change the contents of changeset, for example
    <changeSet id="Test changeset" author="test" runOnChange="true">
        <sql splitStatements="false">
            INSERT INTO test (value, timestamp) VALUES (2, NOW());
        </sql>
    </changeSet>
  1. OK: start/stop the application. We have now the row with value "2" in test table.
  2. NOT OK: check the databasechangelog table. It still has the old content with old execution date and old checksum.
id              dateexecuted                exectype    md5sum                              liquibase
-----------------------------------------------------------------------------------------------------
Test changeset  2022-09-07 14:30:12.702375  EXECUTED    8:666e398c8992830cc4914f88fbe83dfb  3.9.0

Scenario 2 (continuation of scenario 1, OK)

We continue from last step of previous scenario
9. Delete manually the entry from databasechangelog
10. OK: start/stop the application. We have now another value "2" in test table and correct up-to-date entry in databasechangelog:

id              dateexecuted                exectype    md5sum                              liquibase
-----------------------------------------------------------------------------------------------------
Test changeset  2022-09-07 14:40:14.802376  EXECUTED    8:aebf92c816c92d7cf59d17be9fb9037e  4.10.0
  1. change the contents of changeset, for example
    <changeSet id="Test changeset" author="test" runOnChange="true">
        <sql splitStatements="false">
            INSERT INTO test (value, timestamp) VALUES (3, NOW());
        </sql>
    </changeSet>
  1. OK: start/stop the application. We have now the row with value "3" in test table.
  2. OK: also databasechangelog row is updated correctly
id              dateexecuted                exectype    md5sum                              liquibase
-----------------------------------------------------------------------------------------------------
Test changeset  2022-09-07 14:50:15.464366  RERAN       8:42580bc7e0e489db95c60823113e0396  4.10.0

Expected/Desired Behavior

databasechangelog-row should be updated even if the previous execution with the changeset was done with older version of liquibase.

@kataggart
Copy link
Contributor

related #1192

@kataggart
Copy link
Contributor

#2589

@rayr007
Copy link

rayr007 commented Jun 9, 2023

I found that version 4.22.0 does not run any of my changed changeSets with runOnChange set to true.

 - changeSet:
      author: me
      id: package.pck
      #comment: N/A
      runOnChange: true
      validCheckSum: any
      sqlFile: 
        encoding: utf8
        endDelimiter: \n/\s*\n|\n/\s*$
        path: plsql/package.pck
        relativeToChangelogFile: true
        splitStatements: true
        stripComments: false

Reverting to version 4.21.1 resolves the issue for me.

@molivasdat
Copy link
Contributor

Hi @rayr007 Please see the readme for 4.22.0
https://github.com/liquibase/liquibase/releases/tag/v4.22.0

@rayr007
Copy link

rayr007 commented Jun 9, 2023

Thanks. Found that after posting this comment... 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Open Issues
Development

No branches or pull requests

4 participants