PrimaryKeyOnCreateTable

This check warns when a create table action does not also include a primary key.

Uses

Use the check to warn when a changeset which creates a table does not include the creation of a primary key. Primary keys are not required on certain tables, but for tables which are heavily used for search or other frequent reads, a primary key can boost performance, and the lack of one can cause significant performance degradations. If your policies or internal practices allow certain tables without primary keys, you can customize the Exceptions_List. This quality check, like other checks, can be configured with a severity level which returns an exit code designed to stop automated jobs, giving your team time to apply this recommended performance practice.

Run the PrimaryKeyOnCreateTable check

To run the PrimaryKeyOnCreateTable check, ensure you have a Liquibase Pro license and the checks-scope property includes changelog. The checks-scope parameter is set in the default properties file, environment variable, or any standard method. Then, check the changelog to see if PrimaryKeyOnCreateTable is enabled.

Note: Please be aware that PrimaryKeyOnCreateTable only supports modeled changeset types. If you use this Quality Check with unmodeled changesets (formatted SQL changelogs as well as sql and sqlFile changeTypes), a message will appear stating the changeset was skipped.

Enable the PrimaryKeyOnCreateTable check by running the following command in the CLI:

liquibase checks enable --check-name=PrimaryKeyOnCreateTable
Short Name Scope Enabled Severity Customization Description
PrimaryKeyOnCreateTable changelog

true

Default value: 0

  • 'INFO' | 0
  • 'MINOR' | 1
  • 'MAJOR' | 2
  • 'CRITICAL' | 3
  • 'BLOCKER' | 4

EXCEPTIONS_LIST =

CASE_SENSITIVE = true

This check warns when a create table action doesn't also include a primary key.