You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There exists the attribute on_delete in the models.yml. It's definition, extracted from models.yml:
- on_delete: This fields determines what should happen with the foreign model if this model gets deleted. Possible values are:
- SET_NULL (default): delete the id from the foreign key
- PROTECT: if the foreign key is not empty, throw an error instead of deleting the object
- CASCADE: also delete all models in this foreign key
The execution is implemented in the openslides-backend code. A relation without explicit on_delete use the default value SET_NULL.
Migration to the relational DB:
Excecution will be done by the postgres-database
On postgres the directive ON DELETE is used in a foreign key definition and it determines, what happens with the model itself if the referenced model gets deleted
Default value is NO ACTION, preventing the deletion of the referenced model and allows the check to be deferred until later in the transaction
Decision to take:
Naming and positioning of the on delete in the models.yml.
Option 1: models.yml stay unchanged and we transform the value only in the generation of the sql schema
Option 2: we replace the on delete and use it with the postgres definition, including postgres default NO ACTION (correspond to old PROTECT)
IMO we should go with option 2. The postgres definition is more universal and documented than the openslides definition. Additionally there are more options available in the postgres definition.
Disadvantage: Think about and change a lot in the models.yml
10.07.24 13:45: Decision for option 2 taken by Raimund, Danny, Ralf
The text was updated successfully, but these errors were encountered:
There exists the attribute on_delete in the models.yml. It's definition, extracted from models.yml:
The execution is implemented in the openslides-backend code. A relation without explicit on_delete use the default value SET_NULL.
Migration to the relational DB:
ON DELETE
is used in a foreign key definition and it determines, what happens with the model itself if the referenced model gets deletedNO ACTION
, preventing the deletion of the referenced model and allows the check to be deferred until later in the transactionDecision to take:
Naming and positioning of the
on delete
in the models.yml.Option 1: models.yml stay unchanged and we transform the value only in the generation of the sql schema
Option 2: we replace the
on delete
and use it with the postgres definition, including postgres defaultNO ACTION
(correspond to oldPROTECT
)IMO we should go with option 2. The postgres definition is more universal and documented than the openslides definition. Additionally there are more options available in the postgres definition.
Disadvantage: Think about and change a lot in the models.yml
10.07.24 13:45: Decision for option 2 taken by Raimund, Danny, Ralf
The text was updated successfully, but these errors were encountered: