fix: cascade obj/activity deletions in addressing

otherwise its impossible to delete objects because foreign key relation
is violated!
This commit is contained in:
əlemi 2024-06-22 05:17:03 +02:00
parent b3184e7ae2
commit 16a10112a8
Signed by: alemi
GPG key ID: A4895B84D311642C
3 changed files with 8 additions and 4 deletions

View file

@ -19,7 +19,7 @@ pub enum Relation {
from = "Column::Activity",
to = "super::activity::Column::Internal",
on_update = "Cascade",
on_delete = "NoAction"
on_delete = "Cascade"
)]
Activities,
#[sea_orm(
@ -27,7 +27,7 @@ pub enum Relation {
from = "Column::Actor",
to = "super::actor::Column::Internal",
on_update = "Cascade",
on_delete = "NoAction"
on_delete = "Cascade"
)]
Actors,
#[sea_orm(
@ -43,7 +43,7 @@ pub enum Relation {
from = "Column::Object",
to = "super::object::Column::Internal",
on_update = "Cascade",
on_delete = "NoAction"
on_delete = "Cascade"
)]
Objects,
}

View file

@ -1,4 +1,4 @@
use apb::{field::OptionalString, Link, Collection, Document, Endpoints, Node, Object, PublicKey};
use apb::{field::OptionalString, Collection, Document, Endpoints, Node, Object, PublicKey};
use sea_orm::{sea_query::Expr, ActiveModelTrait, ActiveValue::{Unchanged, NotSet, Set}, ColumnTrait, ConnectionTrait, DbErr, EntityTrait, IntoActiveModel, QueryFilter};
use super::Addresser;

View file

@ -50,6 +50,7 @@ impl MigrationTrait for Migration {
.from(Addressing::Table, Addressing::Actor)
.to(Actors::Table, Actors::Internal)
.on_update(ForeignKeyAction::Cascade)
.on_delete(ForeignKeyAction::Cascade)
)
.col(ColumnDef::new(Addressing::Instance).big_integer().null())
.foreign_key(
@ -58,6 +59,7 @@ impl MigrationTrait for Migration {
.from(Addressing::Table, Addressing::Instance)
.to(Instances::Table, Instances::Internal)
.on_update(ForeignKeyAction::Cascade)
.on_update(ForeignKeyAction::NoAction)
)
.col(ColumnDef::new(Addressing::Activity).big_integer().null())
.foreign_key(
@ -66,6 +68,7 @@ impl MigrationTrait for Migration {
.from(Addressing::Table, Addressing::Activity)
.to(Activities::Table, Activities::Internal)
.on_update(ForeignKeyAction::Cascade)
.on_delete(ForeignKeyAction::Cascade)
)
.col(ColumnDef::new(Addressing::Object).big_integer().null())
.foreign_key(
@ -74,6 +77,7 @@ impl MigrationTrait for Migration {
.from(Addressing::Table, Addressing::Object)
.to(Objects::Table, Objects::Internal)
.on_update(ForeignKeyAction::Cascade)
.on_delete(ForeignKeyAction::Cascade)
)
.col(ColumnDef::new(Addressing::Published).timestamp_with_time_zone().not_null().default(Expr::current_timestamp()))
.to_owned()