DB Objects
All db objects (Tables, views, functions etc) are lowercase, the migration does this. Please create new ones and call them from code accordingly.
DB Triggers: erstellt_ and modifiziert_ columns should not have a default value. They should be set by triggers. There is a db function that creates the triggers with the proper syntax. Please use it: f_generate_audit_trigger(tableName)
PKs: NOT DEFERRED, NOT DEFERRABLE (otherwise we canāt create FKs for them)
FKs: DEFERRABLE INITIALLY DEFERRED
Notes:
Deferrable means that the integrity of data in FKs will be checked only at Commit;
Initially deferred means that after an insert the data will be checked only at Commit;
To modify data that is part of PKs/FKs you need to use the command āSET CONSTRAINTS ALL DEFERRED;ā. See āWait for Commitā page
Please note that in PG Admin you will see āDeferrableā checked (correct) but also āDeferredā checked (partially correct, because itās INITIALLY DEFERRED). Donāt create FKs with DEFERRED (without the keyword INITIALLY)
Last updated