matthuhiggins/foreigner

Support for Postgres NOT VALID options for foreign key constraints

beanieboi opened this issue · 1 comments

Hey,

in Postgres you can define an FK Constraint as being invalid.

Quote from http://www.postgresql.org/docs/9.1/static/sql-altertable.html

ADD table_constraint [ NOT VALID ]
This form adds a new constraint to a table using the same syntax as CREATE TABLE, plus the option NOT VALID, which is currently only allowed for foreign key constraints. If the constraint is marked NOT VALID, the potentially-lengthy initial check to verify that all rows in the table satisfy the constraint is skipped. The constraint will still be enforced against subsequent inserts or updates (that is, they'll fail unless there is a matching row in the referenced table). But the database will not assume that the constraint holds for all rows in the table, until it is validated by using the VALIDATE CONSTRAINT option.