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