-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert
ALTER TABLE ... ADD CONSTRAINT ... CHECK
SQL to pgroll
op…
…eration (#538) Convert SQL statements like: ```sql ALTER TABLE foo ADD CONSTRAINT bar CHECK (age > 0) ``` to the equivalent `pgroll` operation: ```json [ { "create_constraint": { "check": "age > 0", "columns": [ "placeholder" ], "down": { "placeholder": "TODO: Implement SQL data migration" }, "name": "bar", "table": "foo", "type": "check", "up": { "placeholder": "TODO: Implement SQL data migration" } } } ] ``` As we don't currently have a reliable way of extracting the columns covered by the constraint from the the `CHECK` SQL expression, the converted `pgroll` operation uses placeholders for the `columns`, `up` and `down` fields. Some forms of the statement are not currently representable by the `create_constraint` operation. For these a raw SQL migration is generated: ```sql "ALTER TABLE foo ADD CONSTRAINT bar CHECK (age > 0) NO INHERIT", "ALTER TABLE foo ADD CONSTRAINT bar CHECK (age > 0) NOT VALID", ```
- Loading branch information
1 parent
f4c17ff
commit be145b1
Showing
4 changed files
with
105 additions
and
10 deletions.
There are no files selected for viewing
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
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
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
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