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

move deferrable to after on update/on delete #4976

Merged
merged 3 commits into from Jan 28, 2022
Merged

move deferrable to after on update/on delete #4976

merged 3 commits into from Jan 28, 2022

Conversation

bflyblue
Copy link
Contributor

Postgresql requires that deferrable appear after on update/on delete, the current order fails with:

error: alter table "smtp_servers" add constraint "smtp_servers_email_channel_foreign" foreign key ("email_channel") references "email_channels" ("id") deferrable initially deferred  on update cascade on delete cascade - syntax error at or near "on"

Moving the deferred clause to the end works as intended.

@kibertoad
Copy link
Collaborator

can you add a test that fails without this change?

@bflyblue
Copy link
Contributor Author

@kibertoad I'm new to the ecosystem so the test might not be great, but I hope it's sufficient to demonstrate the issue.

It fails with error: alter table "table_a" add constraint "table_a_b_id_foreign" foreign key ("b_id") references "table_b" ("id") deferrable initially deferred on update cascade on delete cascade - syntax error at or near "on" before the change.

@kibertoad kibertoad merged commit 4f0f0ab into knex:master Jan 28, 2022
@kibertoad
Copy link
Collaborator

Released in 1.0.2

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.

None yet

2 participants