-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Implement NOT VALID for Postgres databases #2600
Merged
nvoxland
merged 2 commits into
liquibase:master
from
coenvk:table-constraint-not-valid-postgresql
Jun 15, 2022
Merged
Implement NOT VALID for Postgres databases #2600
nvoxland
merged 2 commits into
liquibase:master
from
coenvk:table-constraint-not-valid-postgresql
Jun 15, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
nvoxland
approved these changes
Jun 13, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review and test results:
Change makes sense, thanks!
Things to be aware of
- I created Added check for validate=false on addForeignKeyConstraint for Postgresql liquibase-test-harness#240 as an automated test for it
Things to worry about
nvoxland
added
the
SafeToBuild
Indicates that a particular PR contains changes which are safe to build using GitHub actions
label
Jun 13, 2022
XDelphiGrl
approved these changes
Jun 15, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Fix is straight-forward and localized to the Postgres databases 9.1 or higher.
- Test added to the test harness.
APPROVED
suryaaki2
approved these changes
Jun 15, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
autocandidate
DBPostgres
IntegrationCLI
OSWindows
SafeToBuild
Indicates that a particular PR contains changes which are safe to build using GitHub actions
sprint2022-27
TypeIncorrectSQL
ver4.7.1
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.
Environment
Liquibase Version: 4.7.1
Liquibase Integration & Version: CLI
Liquibase Extension(s) & Version:
Database Vendor & Version: PostgreSQL 9.1
Operating System Type & Version: Microsoft Windows 11 Home
Pull Request Type
Description
PostgreSQL has implemented a feature, since version 9.1, that ensures that constraints are only checked for new or modified rows, but not for existing data. When defining a constraint, NOT VALID can be added at the end to make use of this feature. A similar feature is available in Oracle under the name of ENABLE NOVALIDATE. Currently, NOT VALID is only allowed for foreign key and check constraints.
Steps To Reproduce
liquibase updateSQL
Actual Behavior
ALTER TABLE public.account ADD CONSTRAINT account_customer_id_fkey FOREIGN KEY (customer_id) REFERENCES public.customer (id) NOT VALID;
Expected/Desired Behavior
Executing the addForeignKeyConstraint migration with validate="false" on a Postgres database will now append "NOT VALID" add the end of the SQL and ensures that existing data will not validated by the foreign key constraint.