Skip to content

Can't use 'calculate-checksum' command for changesets where ID or AUTHOR or FILEPATH value contains '::' #3814

Closed
@TymofiiKritsak

Description

Environment

Liquibase Version: 4.19.0

Liquibase Integration & Version: CLI

Liquibase Extension(s) & Version: NONE

Database Vendor & Version: ANY

Operating System Type & Version: ANY

Infrastructure Type/Provider: NONE

Description

calculate-checksum command is requiring to provide --changeset-identifier parameter in the format filepath::id::author
This format doesn't allow to use the command when ID or AUTHOR or FILEPATH have :: in the value.

liquibase calculate-checksum --help
Calculates and prints a checksum for the changeset
[deprecated: calculateChecksum]

Usage: liquibase calculate-checksum [OPTIONS]
Calculates and prints a checksum for the changeset with the given id in the
format filepath::id::author

      --changeset-identifier=PARAM
                         [REQUIRED] Changeset ID identifier of form filepath::
                           id::author
                         (liquibase.command.changesetIdentifier OR liquibase.
                           command.calculateChecksum.changesetIdentifier)
                         (LIQUIBASE_COMMAND_CHANGESET_IDENTIFIER OR
                           LIQUIBASE_COMMAND_CALCULATE_CHECKSUM_CHANGESET_IDENTI
                           FIER)
                         [deprecated: --changesetIdentifier]

Steps To Reproduce

Add next changelog.xml changelog to the Liquibase project:

<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog
  xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">

  <changeSet author="Me" id="1::createTable">
    <createTable tableName="PRIMARY_TABLE">
      <column name="ID" type="INT"/>
    </createTable>
  </changeSet>

</databaseChangeLog>

Execute: liquibase calculate-checksum --changeset-identifier="changelog.xml::1::createTable::Me"

Actual Behavior

Liquibase fails to parse the identifier:

liquibase calculate-checksum --changeset-identifier="changelog.xml::1::createTable::Me"
Starting Liquibase at 13:05:58 (version 4.19.0 #6648 built at 2023-01-17 15:02+0000)
Liquibase Version: 4.19.0
Liquibase Open Source 4.19.0 by Liquibase

Unexpected error running Liquibase: No such changeSet: changelog.xml::1::createTable

For more information, please use the --log-level flag

Expected/Desired Behavior

calculate-checksum command should not have limitations based on the ID or AUTHOR or FILEPATH values.

I would propose to replace --changeset-identifier parameter with a similar functionality like rollback-one-changeset PRO command has.
It is using three separate parameters to identity a changeset.
Example:

liquibase rollback-one-changeset --changesetPath="changelog.xml"  --changesetId="1::createTable" --changesetAuthor="Me" --force
Starting Liquibase at 13:20:54 (version 4.19.0 #6648 built at 2023-01-17 15:02+0000)
Liquibase Version: 4.19.0
Liquibase Pro 4.19.0 by Liquibase licensed to Liquibase Pro Customer
Rolling Back Changeset: changelog.xml::1::createTable::Me
rollback-one-changeset executed for user@jdbc:postgresql://localhost:5432/db
Liquibase command 'rollback-one-changeset' was executed successfully.

Workaround

  • Don't use :: in the ID or AUTHOR or FILEPATH values.
    • Not applicable for existing changesets

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions