diff --git a/src/migrations/m20240524_000001_create_actor_activity_object_tables.rs b/src/migrations/m20240524_000001_create_actor_activity_object_tables.rs index 318aa2b..b5721bb 100644 --- a/src/migrations/m20240524_000001_create_actor_activity_object_tables.rs +++ b/src/migrations/m20240524_000001_create_actor_activity_object_tables.rs @@ -46,7 +46,6 @@ pub enum Objects { Table, Internal, Id, - Domain, ObjectType, AttributedTo, Name, @@ -201,14 +200,6 @@ impl MigrationTrait for Migration { .auto_increment() ) .col(ColumnDef::new(Objects::Id).string().not_null().unique_key()) - .col(ColumnDef::new(Objects::Domain).string().not_null()) - .foreign_key( - ForeignKey::create() - .name("fkey-objects-instances") - .from(Objects::Table, Objects::Domain) - .to(Instances::Table, Instances::Domain) - .on_update(ForeignKeyAction::Cascade) - ) .col(ColumnDef::new(Objects::ObjectType).string().not_null()) .col(ColumnDef::new(Objects::AttributedTo).string().null()) // .foreign_key( diff --git a/src/model/instance.rs b/src/model/instance.rs index b1c0226..58039e5 100644 --- a/src/model/instance.rs +++ b/src/model/instance.rs @@ -27,8 +27,6 @@ pub enum Relation { Actors, #[sea_orm(has_many = "super::addressing::Entity")] Addressing, - #[sea_orm(has_many = "super::object::Entity")] - Objects, } impl Related for Entity { @@ -43,12 +41,6 @@ impl Related for Entity { } } -impl Related for Entity { - fn to() -> RelationDef { - Relation::Objects.def() - } -} - impl ActiveModelBehavior for ActiveModel {} impl Entity { diff --git a/src/model/object.rs b/src/model/object.rs index 9438956..2abea5d 100644 --- a/src/model/object.rs +++ b/src/model/object.rs @@ -12,7 +12,6 @@ pub struct Model { pub internal: i64, #[sea_orm(unique)] pub id: String, - pub domain: String, pub object_type: ObjectType, pub attributed_to: Option, pub name: Option, @@ -53,14 +52,6 @@ pub enum Relation { Attachments, #[sea_orm(has_many = "super::hashtag::Entity")] Hashtags, - #[sea_orm( - belongs_to = "super::instance::Entity", - from = "Column::Domain", - to = "super::instance::Column::Domain", - on_update = "Cascade", - on_delete = "NoAction" - )] - Instances, #[sea_orm(has_many = "super::like::Entity")] Likes, #[sea_orm(has_many = "super::mention::Entity")] @@ -111,12 +102,6 @@ impl Related for Entity { } } -impl Related for Entity { - fn to() -> RelationDef { - Relation::Instances.def() - } -} - impl Related for Entity { fn to() -> RelationDef { Relation::Likes.def() @@ -160,12 +145,9 @@ impl Entity { impl ActiveModel { pub fn new(object: &impl apb::Object) -> Result { - let ap_id = object.id().ok_or(super::FieldError("id"))?.to_string(); - let domain = crate::server::Context::server(&ap_id); Ok(ActiveModel { internal: sea_orm::ActiveValue::NotSet, - domain: sea_orm::ActiveValue::Set(domain), - id: sea_orm::ActiveValue::Set(ap_id), + id: sea_orm::ActiveValue::Set(object.id().ok_or(super::FieldError("id"))?.to_string()), object_type: sea_orm::ActiveValue::Set(object.object_type().ok_or(super::FieldError("type"))?), attributed_to: sea_orm::ActiveValue::Set(object.attributed_to().id()), name: sea_orm::ActiveValue::Set(object.name().map(|x| x.to_string())),