Draft: [PoC] Test trigger based FK constraint for custom work item types

What does this MR do and why?

PoC to test trigger based integrity check for our new table work_item_custom_types. The id on this table will be referenced in other tables and has IDs always greater than 1000. Child tables like issues can't have a foreign key because the column should also be able to hold system defined IDs (fixed values 1 - 9).

Concerns

  • Performance won't be as good as with regular foreign keys as these are optimized at the DB level
  • Bulk inserts on child tables will perform a select per inserted row (this is also optimized with FKs)
  • Concurrency checks, not sure if the lock used in this PoC is enough

Alternatives

I don't think we have many alternatives at this point:

  • Don't have any DB level constraint and handle different possible data states at the app level (e.g. missing custom work item types still referenced in child tables)
  • Only have a trigger to prevent deletes from work_item_custom_types if a record references it as that is an important integrity check
Edited by Mario Celi

Merge request reports

Loading