Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relational db: set all foreign key constraints to "initially deferred" #157

Open
r-peschke opened this issue Sep 3, 2024 · 0 comments
Open
Assignees
Labels
Milestone

Comments

@r-peschke
Copy link
Member

@m-schieder @reicda @rrenkert
Since we can't guarantee the sequence of create events/write requests in current development, we have to set all foreign key constraints deferred.
Simple example:

  • agenda_item/1 with a content_object_id motion/5 should be inserted into db
  • There exist following foreign key constraint: ALTER TABLE agenda_item_t ADD FOREIGN KEY(content_object_id_motion_id) REFERENCES motion_t(id);

There is no problem inserting the motion/5 first and afterwards the agenda_item/1. The opposite is not true: Inserting the agenda_item/1 with the field content_object_id motion/5 first, throws ForeignKeyViolation: insert or update on table "agenda_item_t" violates foreign key constraint "agenda_item_t_content_object_id_motion_id_fkey", because the constraint is checked immediately. To move the check to the end of transaction we will change all foreign key constraints to the form ALTER TABLE agenda_item_t ADD FOREIGN KEY(content_object_id_motion_id) REFERENCES motion_t(id) INITIALLY DEFERRED;

Solving this issue we will write a new issue to revert this and try to remove the INITIALLY DEFERRED, because we expect it to be a time and/or memory penalty

@r-peschke r-peschke added this to the 4.2 milestone Sep 3, 2024
@r-peschke r-peschke self-assigned this Sep 3, 2024
@reicda reicda self-assigned this Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants