Liquibase add-foreign-key-constraint is delayed: what does it mean?

Looking at the docs for Liquibase and add-foreign-key-constraint , there is a property called deferred. But the docs really don't mention what this property does. Somebody knows?

+6
source share
1 answer

deferred
DOES NOT REFUSE
This determines whether the restriction can be deferred. A constraint that is not delayed will be checked immediately after each command. Checking for constraints that are deferred can be deferred until the end of the transaction (using the SET CONSTRAINTS command). NOT DEFERRABLE - The default value. Only foreign key restrictions currently accept this item. All other types of restrictions are not delayed.

[Source] http://www.postgresql.org/docs/8.1/static/sql-createtable.html

In short, suppose that the two tables have a cyclic dependence FK. When we perform an insert for data that is not referenced in both tables and the FK constraint is not deferred, the database throws an error because there is a violation of the FK constraint. If deferred, verification will be performed during the transaction.

+10
source

Source: https://habr.com/ru/post/920090/


All Articles