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

No DEFERRABLE Constraint option #209

Open
anonymouz4 opened this issue May 8, 2023 · 0 comments
Open

No DEFERRABLE Constraint option #209

anonymouz4 opened this issue May 8, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@anonymouz4
Copy link

anonymouz4 commented May 8, 2023

Currently it isn't possible to declare a constraint, while making it DEFERRABLE or set a initial deferred state.

Workaround 1:

guard let db = database as? PostgresDatabase else {
	throw Abort(.internalServerError)
}
try db.simpleQuery("ALTER TABLE waitlist ADD  CONSTRAINT no_duplicate_ranks UNIQUE(waitlist_rank) DEFERRABLE;").wait()

Workaround 2:

// In create migration
.constraint(.custom("CONSTRAINT \"no_duplicate_ranks\" UNIQUE(waitlist_rank) DEFERRABLE"))
@anonymouz4 anonymouz4 added the enhancement New feature or request label May 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant