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
Add offline mode support for rollbackSQL <tag> #2222
Conversation
Fix for the `OfflineChangeLogHistoryService` - populate tag to the changelog. liquibase#2219
Hi @msimko81 Thanks for adding this PR. We will add it to the list of PRs to process. A member of the Liquibase team will take a look at your contribution and may suggest:
The PR will be prioritized according to our internal development and testing capacity. We’ll let you know when it’s ready to move to the next step or if any changes are needed. |
…simko81-master
Test Results
Verify rollback-sql command correctly rolls back changes. PASS
Liquibase version [Core: //master/1049/76cf69/2021-12-23 07:02+0000, Pro: master/320/3630fa/2021-12-23T04:37:10Z] #1049 |
Fix for the {{OfflineChangeLogHistoryService}}
[https://github.com//issues/2219|https://github.com//issues/2219]
<!--- This environment context section helps us quickly review your PR.
Please take a minute to fill-out this information. -->
h2. Environment
Liquibase Version:
4.6.1 (but also affecting previous versions)
Liquibase Integration & Version:
CLI & Java API
Database Vendor & Version:
MS SQL Server (but also affecting others)
Operating System Type & Version:
Ubuntu Linux (but also affecting others)
h2. Pull Request Type
<!--- What types of changes does your code introduce?
Put an {{x}} in all the boxes that apply:
If this PR fixes an existing GH issue, edit the next line to add "closes #XXXX" to auto-link.
If this PR fixes an existing CORE Jira issue, note that as well, although there will be no auto-linking. -->
rollbackSQL <tag>
operation #2219h2. Description
The liquibase offline mode doesn't support {{rollbackSQL }} functionality. The reason is the tag value is not persisted in the {{databasechangelog.csv}} as a result of {{updateSQL}} operation. The tag column only contains empty values, also for changeset containing {{tagDatabase}} command.
h2. Steps To Reproduce
Assume the following {{changelog.xml}}:
{code:java}
{code}
apply the above changelog using the offline mode: {{liquibase --changeLogFile=changelog.xml --url=offline:mssql updateSQL}}
try to perform {{rollbackSQL }} operation: {{liquibase --changeLogFile=changelog.xml --url=offline:mssql rollbackSQL 1.0}}
h2. Actual Behavior
The first step produces {{liquibasechangelog.csv}} with two entries. The second one, with id {{release-1.0}}, contains empty tag. However, the tag of this entry shall be {{1.0}} (as is the state of the database table in corresponding online mode case).
The {{rollbackSQL}} operation fails with the error message: {{Unexpected error running Liquibase: Could not find tag '1.0' in the database}}.
Note: if I manually change the CSV file generated by the first step and specify the tag for the second entry (to mimic the online mode behaviour), the second operation is successful and behaves as expected.
h2. Expected/Desired Behavior
The tag value shall be populated in offline mode (i.e. present in {{liquibasechangelog.csv}}) in order to enable {{rollbackSQL }} operation.
h2. Fast Track PR Acceptance Checklist:
<!--- Completing these speeds up the acceptance of your pull request -->
<!--- Put an {{x}} in all the boxes that apply. -->
<
!--- If you're unsure about any of these, just ask us in a comment. We're here to help|width=200,height=183!
-->
h2. Need Help?
Come chat with us on our [discord channel|https://discord.com/channels/700506481111597066/700506481572839505]
h2. Dev Handoff Notes (Internal Use)
h4. Links
rollbackSQL <tag>
operation #2219|https://github.com/Liquibase offline mode doesn't supportrollbackSQL <tag>
operation #2219]h4. Testing
rollbackSQL <tag>
operation #2219|https://github.com/Liquibase offline mode doesn't supportrollbackSQL <tag>
operation #2219]** Impact: only impacts offline mode when there is a change in the changelog
h4. Dev Verification
Verified that with the change, running {{liquibase rollback-sql --tag 1.0}} only returns SQL to roll back the changeset as well as other changesets after it. But not ones before.
My sample changelog:
{code:java}
Manual Tests
Use this changelog:
Verify generated changelog contains correct tag names when using offline mode.
liquibase update-sql --url offline:postgres --changeLog-file changelog.xml
databasechangelog.csv
correctly contains tag namesmyTag
and2.0
for changesets with id 2 and 4Verify rollback-sql command correctly rolls back changes.
liquibase rollback-sql 2.0 --url offline:postgres --changeLogFile changelog.xml
databasechangelog.csv
liquibase rollback-sql myTag --url offline:postgres --changeLogFile changelog.xml
databasechangelog.csv
┆Issue is synchronized with this Jira Bug by Unito