Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for databases enforcing strict data integrity through PKs. Fixes #13611 #14103

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

radusora
Copy link

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 for schema_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.

@radusora radusora marked this pull request as ready for review January 22, 2025 17:00
Copy link
Member

@MasonM MasonM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I tested this locally with both MySQL 8.4.4 and PostgreSQL 12.22

@MasonM MasonM requested a review from tczhao January 28, 2025 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add primary key to schema_history
2 participants