feat: add support for databases enforcing strict data integrity through PKs. Fixes #13611 #14103
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #13611
Motivation
As outlined in #13611, certain database systems depend on the presence of primary keys to support replication and ensure data integrity. For instance, Percona XtraDB’s
pxc_strict_mode
enforces this requirement.Modifications
The
schema_history
table lacked a primary key, and adding one through existing migrations was not feasible because earlier migrations would fail in the environments described above. To address this, the table creation statement forschema_history
was updated to include a primary key. Additionally, code was added to check for the presence of the primary key in existing installations and add it if it is missing (making sure the changes are idempotent).Verification
The changes were tested in a local development environment using both MySQL and Postgres, with scenarios including deploying a new cluster and modifying an existing one. Furthermore, a similar test was conducted with a Percona XtraDB cluster deployed via the Percona Operator.
Additionally, I verified that the query against
information_schema.table_constraints
is supported by all the databases we support, and that default permissions should suffice for accessing it.