Create CHECK/EXCLUDE constraints using LB4 model/property decorators? #7472
Unanswered
serkansahinBE
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I would like to know if there is a possibility to create constraints of types CHECK and EXCLUDE using LB4's ORM using PostgreSQL connector? Maybe there's already a doc or a topic (I hope)..
For example (a dummy one):
Now I want to add a CHECK constraint on the "balance" column let say that it cannot be below 0, so in an SQL query it will be something like this:
CREATE TABLE wallet (id SERIAL PRIMARY KEY, balance INTEGER CHECK (balance >= 0))
.As a workaround, I have created a custom function that will create all the constraints by running for example:
ALTER TABLE public."wallet" ADD CONSTRAINT check_balance_below_zero CHECK (balance >= 0);
, but I'd like to stay ISO with the framework's ORM and if it is possible to add/create CONSTRAINTS using it.Thanks :)
Beta Was this translation helpful? Give feedback.
All reactions