PrimaryKeyOnCreateTable

Last updated: July 14, 2025

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

Uses

Property

Value

Liquibase version required

4.12.0+

Scope (--checks-scope)

changelog

Default status

enabled

Default severity (exit code)

0 ("INFO")

Customizable settings

Yes (dynamic)

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 policy 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.

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

Before you begin

  1. Ensure that you have correctly specified your Liquibase Pro license key.

  2. Ensure that the --checks-scope parameter includes the scope of this check.

Changelog checks prerequisites

--license-key=<string>
--checks-scope=<string>

Procedure

1

Enable

This check is enabled by default. To verify that it is currently enabled, run the checks show command:

liquibase checks show --check-name=<string>

2

Customize

This check is dynamic, meaning you can customize its settings. See the table on this page for more information.

1. 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 pressingEnter. Alternatively, specify custom values. If a customization setting does not have a default value, you must specify custom values.

2. When finished, verify that your configuration is correct by running thechecks showcommand.

liquibase checks show --check-name=<string>

3. If you need to make any other changes, run thechecks customizecommand:

liquibase checks customize --check-name=<string>

Note: If you want to create another variant of this check with different settings, use thechecks copycommand to create a copy of the original check and then use thechecks customizecommand to customize it.

3

Run

To run the check, use the checks run command.

liquibase checks run --check-name=<string>