maxAffectedRowsAllowedDelete

This check triggers when the number of rows a SQL statement deletes exceeds the value of MaxAffectedRowsAllowed. The SQL statement is executed against the database and then rolled back.

Uses

Use this check to prevent statements from being deleted from your database if more than a specified number of rows are affected by that statement.

Run the maxAffectedRowsAllowedDelete check

To run the maxAffectedRowsAllowedDelete check, ensure you have a Liquibase Pro license, a valid url property that points to a live JDBC connection or a snapshot, and that the checks-scope property includes the changelog. The checks-scope property is set in the default properties file, environment variable, or any standard method. Then check if any searchable object types match the supplied pattern.

  1. To set the number of rows allowed you must customize the maxAffectedRowsAllowedDelete check. Run the following command in the CLI:

    liquibase checks customize --check-name=maxAffectedRowsAllowedDelete
  2. Set the Severity to return a code of 0-4 when triggered. (options: 'INFO'|0, 'MINOR'|1, 'MAJOR'|2, 'CRITICAL'|3, 'BLOCKER'|4)? [INFO]:

  3. Set the maximum affected rows in the CLI:

    MAX_ROWS (options: positive numeric value) [50]:
  4. Set the message that displays when this check runs.

    Set 'MESSAGE' [<AFFECTED_ROWS> rows will be affected, which is more than the allowed '<THRESHOLD>' rows. The SQL statement is '<STATEMENT>' in '<CHANGESET>'.]:
  5. Enable the maxAffectedRowsAllowedDelete check by running the following command in the CLI:

    liquibase checks enable --check-name=maxAffectedRowsAllowedDelete

  6. MaxAffectedRowsAllowedDelete Default message

    The maxAffectedRowsAllowedDelete default message is displayed below.

    Checks completed validation of the changelog and found the following issues:
    
    Check Name:         Check Affected Rows Count (MAX_ROWS)
    Changeset ID:       01
    Changeset Filepath: delete.sql
    Check Severity:     INFO (Return code: 0)
    Message:            More than the allowed '50' rows will be affected by the SQL statement 
                        '<SQL STATEMENT>' in 
                        '<CHANGESET>'