I want to add a constraint to my django model. I want this migration to do nothing if the constraint has already been added (manually in sql, not by django). I know how to check if constraint is already applied thanks to this question.
However, how could I skip the "add constraint" operation in my migration file based on this condition?
Do I need to create a RunPython
operation or can I rely on django migration objects?
I am using postgres.
EDIT I added the constraint previously directly in sql to avoid doing it during deployment, for performance reason. Also, this constraint isn't applied in all environments so I cannot assume it's already there.