fluent-postgres-driver icon indicating copy to clipboard operation
fluent-postgres-driver copied to clipboard

No DEFERRABLE Constraint option

Open anonymouz4 opened this issue 2 years ago • 0 comments

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 avatar May 08 '23 13:05 anonymouz4