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

Add safe add_check_constraint #95

Merged
merged 12 commits into from Jun 9, 2023
Merged

Add safe add_check_constraint #95

merged 12 commits into from Jun 9, 2023

Conversation

ThHareau
Copy link
Contributor

@ThHareau ThHareau commented Jun 7, 2023

Adding a check constraint requires an ACCESS EXCLUSIVE lock, which prevent writing and reading in the tables as soon as the lock is requested.

Adding the constraint itself is rather fast, the major part of the time is spent on validating this constraint.
Thus safe-pg-migrations ensures that adding a constraints holds blocking locks for the least amount of time by
splitting the constraint addition in two steps:

  1. adding the constraint without validation, will not validate existing rows;
  2. validating the constraint, will validate existing rows in the table, without blocking read or write on the table

@ThHareau ThHareau self-assigned this Jun 7, 2023
@ThHareau ThHareau marked this pull request as ready for review June 8, 2023 14:10
@ThHareau ThHareau requested a review from rchoquet June 8, 2023 14:10
README.md Outdated Show resolved Hide resolved
@ThHareau ThHareau merged commit 3598097 into master Jun 9, 2023
16 checks passed
@ThHareau ThHareau deleted the safe-add_check_constraint branch June 9, 2023 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants