MaxAffectedRowsAllowedUpdate
This check triggers when the number of rows a SQL statement updates exceeds the value of MaxAffectedRowsAllowed
. The SQL statement is executed against the database and then rolled back.
About MaxAffectedRowsAllowedUpdate |
|
---|---|
Liquibase version required | 4.28.0+ |
Scope (--checks-scope ) |
changelog
|
Default status | enabled
|
Default severity (exit code) | 0 ("INFO ") |
Customizable settings | Yes (dynamic) |
Uses
Use this check to prevent statements from being inserted into your database if more than a specified number of rows are affected by that statement.
Use MaxAffectedRowsAllowedUpdate
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 enabled by default. To verify that it is currently enabled, run the show
command:
liquibase checks show --check-name=<string>
Customize
This check is dynamic, meaning you can customize its settings. See the table on this page for more information.
- If you want to customize any default values of this check, run the
customize
command: - When finished, verify that your configuration is correct by running the
show
command:
liquibase checks customize --check-name=<string>
liquibase checks show --check-name=<string>
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
liquibase checks enable --check-name=maxAffectedRowsAllowedUpdate
example output
Check 'maxAffectedRowsAllowedUpdate' has been enabled.
+-------------------------------------+------------+----------+----------+--------------------------------+--------------------------------+
| MaxAffectedRowsAllowedDelete | changelog | disabled | 0 | MAX_ROWS = 50 | This checks triggers when the |
| | | | | MESSAGE = <AFFECTED_ROWS> rows | Max Affected Rows Allowed |
| | | | | will be affected, which is | value is exceeded by the |
| | | | | more than the allowed | number of rows DELETED by a |
| | | | | '<THRESHOLD>' rows. The SQL | SQL statement. The SQL |
| | | | | statement is '<STATEMENT>' in | statement is executed against |
| | | | | '<CHANGESET>'. | the database, and then rolled |
| | | | | | back.|
+-------------------------------------+------------+----------+----------+--------------------------------+--------------------------------+
| MaxAffectedRowsAllowedInsert | changelog | disabled | 0 | MAX_ROWS = 50 | This checks triggers when the |
| | | | | MESSAGE = <AFFECTED_ROWS> rows | Max Affected Rows Allowed |
| | | | | will be affected, which is | value is exceeded by the |
| | | | | more than the allowed | number of rows INSERTED by a |
| | | | | '<THRESHOLD>' rows. The SQL | SQL statement. The SQL |
| | | | | statement is '<STATEMENT>' in | statement is executed against |
| | | | | '<CHANGESET>'. | the database, and then rolled |
| | | | | | back.|
+-------------------------------------+------------+----------+----------+--------------------------------+--------------------------------+
| MaxAffectedRowsAllowedUpdate | changelog | enabled | 0 | MAX_ROWS = 50 | This checks triggers when the |
| | | | | MESSAGE = <AFFECTED_ROWS> rows | Max Affected Rows Allowed |
| | | | | will be affected, which is | value is exceeded by the |
| | | | | more than the allowed | number of rows UPDATED by a |
| | | | | '<THRESHOLD>' rows. The SQL | SQL statement. The SQL |
| | | | | statement is '<STATEMENT>' in | statement is executed against |
| | | | | '<CHANGESET>'. | the database, and then rolled |
| | | | | | back.|
+-------------------------------------+------------+----------+----------+--------------------------------+--------------------------------+
Liquibase command 'checks enable' was executed successfully.