ChangesetAttributesAndValue
This check triggers when specified attributes do not match the user-supplied string or regex pattern.
About ChangesetAttributesAndValue |
|
---|---|
Liquibase version required | 4.29.0+ |
Scope (--checks-scope ) |
changelog
|
Default status | disabled
|
Default severity (exit code) | 0 ("INFO ") |
Customizable settings | Yes (dynamic) |
Uses
This policy check allows you to easily check whether the attributes in your changesets each match a particular string or regular expression. This helps you ensure that your changesets remain standardized.
For example, if you want to ensure that the value of the changeset attribute id
always follows the format <integer>-<description>
(such as 1-newTable
), you could specify the regular expression \d+-\w+
.
When customizing this check, simply specify the name of the attribute you want to standardize (ATTRIBUTE
) and the string or regular expression (SEARCH_STRING
). If you want to apply this check to multiple attributes, run the copy
command and specify the name of a different attribute.
Note: If you want to specify multiple attributes in a single check, you can specify them as a comma-separated list. However, you can only specify one value to apply to all the attributes you specify in a single check. To run multiple of these checks together, you can specify them in Check Chains.
If Liquibase detects that an attribute does not match the user-supplied string or regex, Liquibase displays the following message:
The attribute '<attributename>' does not match the required pattern '<PATTERN>.'
Use ChangesetAttributesAndValue
Prerequisites
- Ensure that you have correctly specified your Liquibase Pro license key.
- Ensure that the
--checks-scope
parameter includes the scope of this check.
For example:
--license-key=<string>
--checks-scope=<string>
globalArgs: { license-key: "<string>" }
cmdArgs: { checks-scope: "<string>" }
liquibase.licenseKey: <string>
liquibase.command.checksScope: <string>
liquibase.licenseKey: <string>
liquibase.command.checks.run.checksScope: <string>
JAVA_OPTS=-Dliquibase.licenseKey=<string> -Dliquibase.command.checksScope=<string>
JAVA_OPTS=-Dliquibase.licenseKey=<string> -Dliquibase.command.checks.run.checksScope=<string>
LIQUIBASE_LICENSE_KEY=<string>
LIQUIBASE_COMMAND_CHECKS_SCOPE=<string>
LIQUIBASE_LICENSE_KEY=<string>
LIQUIBASE_COMMAND_CHECKS_RUN_CHECKS_SCOPE=<string>
Enable
This check is disabled by default. To enable it, run the enable
command:
liquibase checks enable --check-name=<string>
When you try to enable the check, Liquibase displays the following message:
This check can not be enabled directly because one or more fields does not have a default value. Create a copy of this check and initiate the customization workflow.
Liquibase then prompts you to specify a name for the new check. By default, the name of the copy is <CheckName>1
. You can use the default value by pressing Enter or you can specify a custom name.
Customize
This check is dynamic, meaning you can customize its settings. See the table on this page for more information.
- Once you've enabled the check, follow the steps in the CLI to set new values:
- Default values are shown in [brackets]. You can use these by pressing Enter. Alternatively, specify custom values.
- If a customization setting does not have a default value, you must specify custom values.
- When finished, verify that your configuration is correct by running the
show
command: - If you need to make any other changes, run the
customize
command:
liquibase checks show --check-name=<string>
liquibase checks customize --check-name=<string>
Note: If you want to create another variant of this check with different settings, use the copy
command to create a copy of the original check and then use the customize
command to customize it.
Run
To run the check, use the run
command:
liquibase checks run --check-name=<string>
stages:
Default:
actions:
- type: liquibase
command: checks run
cmdArgs: {check-name: <string>}
And then run the flow
command on your flow file:
liquibase flow
Customization settings
Name | Type | Description | Customization | Default Value |
---|---|---|---|---|
ATTRIBUTE
|
String |
The name of the changeset attribute to match. Cannot be empty. |
Must be a valid changeset attribute. |
null |
SEARCH_STRING
|
String |
The substring or regular expression to match with the one in the changelog file. Cannot be empty. |
Must be |
null |
liquibase checks enable --check-name=ChangesetAttributesAndValue
example output
Check 'ChangesetAttributesAndValue' has been enabled.
+-------------------------------------+------------+----------+----------+--------------------------------+--------------------------------+
| Short Name | Scope | Status | Severity | Customization | Description |
+-------------------------------------+------------+----------+----------+--------------------------------+--------------------------------+
| ChangesetAttributesAndValue | changelog | disabled | 0 | ATTRIBUTE = null | This check triggers when |
| | | | | SEARCH_STRING = null | specified attributes do not |
| | | | | | match the user-supplied string |
| | | | | | or regex pattern. |
+-------------------------------------+------------+----------+----------+--------------------------------+--------------------------------+
Liquibase command 'checks enable' was executed successfully.
Troubleshooting
If you use a property for an attribute value in a changeset (such as runwith=${SOMEVAR}
) and have the
command parameter checks run
--property-substitution-enabled=false
, Liquibase skips the check and displays the following:
WARNING: This check skipped due to unexpanded property in '<attributename>' value. Set '--property-substitution-enabled=true' to properly evaluate this changeset.