Skip to content

Handle unconvertible CREATE TABLE table constraints #549

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

Merged
merged 2 commits into from
Dec 18, 2024

Conversation

andrew-farries
Copy link
Collaborator

Ensure that SQL CREATE TABLE statements of the form:

CREATE TABLE foo(a int, CONSTRAINT foo_check CHECK (a > 0))
CREATE TABLE foo(a int, CONSTRAINT foo_unique UNIQUE (a))
CREATE TABLE foo(a int, CONSTRAINT foo_pk PRIMARY KEY (a))
CREATE TABLE foo(a int, CONSTRAINT foo_fk FOREIGN KEY (a) REFERENCES bar(b))
CREATE TABLE foo(a int, CHECK (a > 0))
CREATE TABLE foo(a int, UNIQUE (a))
CREATE TABLE foo(a int, PRIMARY KEY (a))
CREATE TABLE foo(a int, FOREIGN KEY (a) REFERENCES bar(b))

fall back to raw SQL due to the presence of the table level constraints, which aren't currently representable as a pgroll OpCreateTable operation.

The PR only adds test cases as constraint table elements were already causing a fall back to raw SQL; only column definition table elements are converted.

Table constraints are not yet representable by `OpCreateTable`
operations.
@andrew-farries andrew-farries marked this pull request as ready for review December 18, 2024 13:15
@andrew-farries andrew-farries merged commit d933a4f into main Dec 18, 2024
28 checks passed
@andrew-farries andrew-farries deleted the unconvertible-table-constraints branch December 18, 2024 14:48
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.

2 participants