chore: better id, mix strings and numbers in joins
"hot" joins will use internal ids (relations, like/share, addressing) while "slow" relations will use full ap ids (attributed to, context, user configs)
This commit is contained in:
parent
12c5a6f3a5
commit
94ec7d0d37
20 changed files with 249 additions and 218 deletions
|
@ -2,9 +2,9 @@ use sea_orm_migration::prelude::*;
|
|||
#[derive(DeriveIden)]
|
||||
pub enum Actors {
|
||||
Table,
|
||||
Internal,
|
||||
Id,
|
||||
ApId,
|
||||
Instance,
|
||||
Domain,
|
||||
ActorType,
|
||||
Name,
|
||||
Summary,
|
||||
|
@ -28,8 +28,8 @@ pub enum Actors {
|
|||
#[derive(DeriveIden)]
|
||||
pub enum Activities {
|
||||
Table,
|
||||
Internal,
|
||||
Id,
|
||||
ApId,
|
||||
ActivityType,
|
||||
Actor,
|
||||
Object,
|
||||
|
@ -44,8 +44,8 @@ pub enum Activities {
|
|||
#[derive(DeriveIden)]
|
||||
pub enum Objects {
|
||||
Table,
|
||||
Internal,
|
||||
Id,
|
||||
ApId,
|
||||
ObjectType,
|
||||
AttributedTo,
|
||||
Name,
|
||||
|
@ -69,11 +69,12 @@ pub enum Objects {
|
|||
#[derive(DeriveIden)]
|
||||
pub enum Instances {
|
||||
Table,
|
||||
Id,
|
||||
Name,
|
||||
Internal,
|
||||
Domain,
|
||||
Name,
|
||||
Software,
|
||||
Version,
|
||||
Icon,
|
||||
DownSince,
|
||||
Users,
|
||||
Posts,
|
||||
|
@ -95,16 +96,17 @@ impl MigrationTrait for Migration {
|
|||
.table(Instances::Table)
|
||||
.comment("known other instances in the fediverse")
|
||||
.col(
|
||||
ColumnDef::new(Instances::Id)
|
||||
.integer()
|
||||
ColumnDef::new(Instances::Internal)
|
||||
.big_integer()
|
||||
.not_null()
|
||||
.auto_increment()
|
||||
.primary_key()
|
||||
)
|
||||
.col(ColumnDef::new(Instances::Domain).string().not_null().unique_key())
|
||||
.col(ColumnDef::new(Instances::Name).string().null())
|
||||
.col(ColumnDef::new(Instances::Domain).string().not_null())
|
||||
.col(ColumnDef::new(Instances::Software).string().null())
|
||||
.col(ColumnDef::new(Instances::Version).string().null())
|
||||
.col(ColumnDef::new(Instances::Icon).string().null())
|
||||
.col(ColumnDef::new(Instances::DownSince).date_time().null())
|
||||
.col(ColumnDef::new(Instances::Users).integer().null())
|
||||
.col(ColumnDef::new(Instances::Posts).integer().null())
|
||||
|
@ -115,7 +117,7 @@ impl MigrationTrait for Migration {
|
|||
.await?;
|
||||
|
||||
manager
|
||||
.create_index(Index::create().name("index-instances-domain").table(Instances::Table).col(Instances::Domain).to_owned())
|
||||
.create_index(Index::create().unique().name("index-instances-domain").table(Instances::Table).col(Instances::Domain).to_owned())
|
||||
.await?;
|
||||
|
||||
|
||||
|
@ -126,22 +128,22 @@ impl MigrationTrait for Migration {
|
|||
.table(Actors::Table)
|
||||
.comment("main actors table, with users and applications")
|
||||
.col(
|
||||
ColumnDef::new(Actors::Id)
|
||||
.integer()
|
||||
ColumnDef::new(Actors::Internal)
|
||||
.big_integer()
|
||||
.not_null()
|
||||
.primary_key()
|
||||
.auto_increment()
|
||||
)
|
||||
.col(ColumnDef::new(Actors::ApId).string().not_null().unique_key())
|
||||
.col(ColumnDef::new(Actors::Id).string().not_null().unique_key())
|
||||
.col(ColumnDef::new(Actors::ActorType).string().not_null())
|
||||
.col(ColumnDef::new(Actors::Instance).integer().not_null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-actors-instances")
|
||||
.from(Actors::Table, Actors::Instance)
|
||||
.to(Instances::Table, Instances::Id)
|
||||
.on_update(ForeignKeyAction::Cascade)
|
||||
)
|
||||
.col(ColumnDef::new(Actors::Domain).string().not_null())
|
||||
// .foreign_key(
|
||||
// ForeignKey::create()
|
||||
// .name("fkey-actors-instances")
|
||||
// .from(Actors::Table, Actors::Domain)
|
||||
// .to(Instances::Table, Instances::Domain)
|
||||
// .on_update(ForeignKeyAction::Cascade)
|
||||
// )
|
||||
.col(ColumnDef::new(Actors::Name).string().null())
|
||||
.col(ColumnDef::new(Actors::Summary).string().null())
|
||||
.col(ColumnDef::new(Actors::Image).string().null())
|
||||
|
@ -164,7 +166,7 @@ impl MigrationTrait for Migration {
|
|||
.await?;
|
||||
|
||||
manager
|
||||
.create_index(Index::create().unique().name("index-actors-ap-id").table(Actors::Table).col(Actors::ApId).to_owned())
|
||||
.create_index(Index::create().unique().name("index-actors-id").table(Actors::Table).col(Actors::Id).to_owned())
|
||||
.await?;
|
||||
|
||||
manager
|
||||
|
@ -183,27 +185,34 @@ impl MigrationTrait for Migration {
|
|||
.table(Objects::Table)
|
||||
.comment("objects are all AP documents which are neither actors nor activities")
|
||||
.col(
|
||||
ColumnDef::new(Objects::Id)
|
||||
.integer()
|
||||
ColumnDef::new(Objects::Internal)
|
||||
.big_integer()
|
||||
.not_null()
|
||||
.primary_key()
|
||||
.auto_increment()
|
||||
)
|
||||
.col(ColumnDef::new(Objects::ApId).string().not_null().unique_key())
|
||||
.col(ColumnDef::new(Objects::Id).string().not_null().unique_key())
|
||||
.col(ColumnDef::new(Objects::ObjectType).string().not_null())
|
||||
.col(ColumnDef::new(Objects::AttributedTo).integer().null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-objects-attributed-to")
|
||||
.from(Objects::Table, Objects::AttributedTo)
|
||||
.to(Actors::Table, Actors::Id)
|
||||
.on_update(ForeignKeyAction::Cascade)
|
||||
)
|
||||
.col(ColumnDef::new(Objects::AttributedTo).string().null())
|
||||
// .foreign_key(
|
||||
// ForeignKey::create()
|
||||
// .name("fkey-objects-attributed-to")
|
||||
// .from(Objects::Table, Objects::AttributedTo)
|
||||
// .to(Actors::Table, Actors::Internal)
|
||||
// .on_update(ForeignKeyAction::Cascade)
|
||||
// )
|
||||
.col(ColumnDef::new(Objects::Name).string().null())
|
||||
.col(ColumnDef::new(Objects::Summary).string().null())
|
||||
.col(ColumnDef::new(Objects::Content).string().null())
|
||||
.col(ColumnDef::new(Objects::Sensitive).boolean().not_null().default(false))
|
||||
.col(ColumnDef::new(Objects::InReplyTo).string().null())
|
||||
// .foreign_key(
|
||||
// ForeignKey::create()
|
||||
// .name("fkey-objects-in-reply-to")
|
||||
// .from(Objects::Table, Objects::InReplyTo)
|
||||
// .to(Objects::Table, Objects::Id)
|
||||
// .on_update(ForeignKeyAction::Cascade)
|
||||
// )
|
||||
.col(ColumnDef::new(Objects::Url).string().null())
|
||||
.col(ColumnDef::new(Objects::Likes).integer().not_null().default(0))
|
||||
.col(ColumnDef::new(Objects::Announces).integer().not_null().default(0))
|
||||
|
@ -219,7 +228,7 @@ impl MigrationTrait for Migration {
|
|||
).await?;
|
||||
|
||||
manager
|
||||
.create_index(Index::create().unique().name("index-objects-ap-id").table(Objects::Table).col(Objects::ApId).to_owned())
|
||||
.create_index(Index::create().unique().name("index-objects-id").table(Objects::Table).col(Objects::Id).to_owned())
|
||||
.await?;
|
||||
|
||||
manager
|
||||
|
@ -246,30 +255,30 @@ impl MigrationTrait for Migration {
|
|||
.table(Activities::Table)
|
||||
.comment("all activities this instance ever received or generated")
|
||||
.col(
|
||||
ColumnDef::new(Activities::Id)
|
||||
.integer()
|
||||
ColumnDef::new(Activities::Internal)
|
||||
.big_integer()
|
||||
.not_null()
|
||||
.primary_key()
|
||||
.auto_increment()
|
||||
)
|
||||
.col(ColumnDef::new(Activities::ApId).string().not_null().unique_key())
|
||||
.col(ColumnDef::new(Activities::Id).string().not_null().unique_key())
|
||||
.col(ColumnDef::new(Activities::ActivityType).string().not_null())
|
||||
.col(ColumnDef::new(Activities::Actor).integer().not_null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-activities-actors")
|
||||
.from(Activities::Table, Activities::Actor)
|
||||
.to(Actors::Table, Actors::Id)
|
||||
.on_update(ForeignKeyAction::Cascade)
|
||||
)
|
||||
.col(ColumnDef::new(Activities::Object).integer().null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-activities-objects")
|
||||
.from(Activities::Table, Activities::Object)
|
||||
.to(Objects::Table, Objects::Id)
|
||||
.on_update(ForeignKeyAction::Cascade)
|
||||
)
|
||||
.col(ColumnDef::new(Activities::Actor).string().not_null())
|
||||
// .foreign_key(
|
||||
// ForeignKey::create()
|
||||
// .name("fkey-activities-actors")
|
||||
// .from(Activities::Table, Activities::Actor)
|
||||
// .to(Actors::Table, Actors::Id)
|
||||
// .on_update(ForeignKeyAction::Cascade)
|
||||
// )
|
||||
.col(ColumnDef::new(Activities::Object).string().null())
|
||||
// .foreign_key(
|
||||
// ForeignKey::create()
|
||||
// .name("fkey-activities-objects")
|
||||
// .from(Activities::Table, Activities::Object)
|
||||
// .to(Objects::Table, Objects::Internal)
|
||||
// .on_update(ForeignKeyAction::Cascade)
|
||||
// )
|
||||
.col(ColumnDef::new(Activities::Target).string().null())
|
||||
.col(ColumnDef::new(Activities::To).json().null())
|
||||
.col(ColumnDef::new(Activities::Bto).json().null())
|
||||
|
@ -280,7 +289,7 @@ impl MigrationTrait for Migration {
|
|||
).await?;
|
||||
|
||||
manager
|
||||
.create_index(Index::create().unique().name("index-activities-ap-id").table(Activities::Table).col(Activities::ApId).to_owned())
|
||||
.create_index(Index::create().unique().name("index-activities-id").table(Activities::Table).col(Activities::Id).to_owned())
|
||||
.await?;
|
||||
|
||||
manager
|
||||
|
@ -304,7 +313,7 @@ impl MigrationTrait for Migration {
|
|||
.await?;
|
||||
|
||||
manager
|
||||
.drop_index(Index::drop().name("index-actors-ap-id").table(Actors::Table).to_owned())
|
||||
.drop_index(Index::drop().name("index-actors-id").table(Actors::Table).to_owned())
|
||||
.await?;
|
||||
|
||||
manager
|
||||
|
@ -321,7 +330,7 @@ impl MigrationTrait for Migration {
|
|||
.await?;
|
||||
|
||||
manager
|
||||
.drop_index(Index::drop().name("index-activities-ap-id").table(Activities::Table).to_owned())
|
||||
.drop_index(Index::drop().name("index-activities-id").table(Activities::Table).to_owned())
|
||||
.await?;
|
||||
|
||||
manager
|
||||
|
@ -342,7 +351,7 @@ impl MigrationTrait for Migration {
|
|||
.await?;
|
||||
|
||||
manager
|
||||
.drop_index(Index::drop().name("index-objects-ap-id").table(Objects::Table).to_owned())
|
||||
.drop_index(Index::drop().name("index-objects-id").table(Objects::Table).to_owned())
|
||||
.await?;
|
||||
|
||||
manager
|
||||
|
|
|
@ -5,7 +5,7 @@ use super::m20240524_000001_create_actor_activity_object_tables::{Activities, Ac
|
|||
#[derive(DeriveIden)]
|
||||
pub enum Relations {
|
||||
Table,
|
||||
Id,
|
||||
Internal,
|
||||
Follower,
|
||||
Following,
|
||||
Activity,
|
||||
|
@ -16,9 +16,9 @@ pub enum Relations {
|
|||
#[allow(clippy::enum_variant_names)]
|
||||
pub enum Likes {
|
||||
Table,
|
||||
Id,
|
||||
Internal,
|
||||
Actor,
|
||||
Likes,
|
||||
Object,
|
||||
Published,
|
||||
}
|
||||
|
||||
|
@ -26,9 +26,9 @@ pub enum Likes {
|
|||
#[allow(clippy::enum_variant_names)]
|
||||
pub enum Announces {
|
||||
Table,
|
||||
Id,
|
||||
Internal,
|
||||
Actor,
|
||||
Announces,
|
||||
Object,
|
||||
Published,
|
||||
}
|
||||
|
||||
|
@ -44,44 +44,44 @@ impl MigrationTrait for Migration {
|
|||
.table(Relations::Table)
|
||||
.comment("follow relations between actors (applications too! for relays)")
|
||||
.col(
|
||||
ColumnDef::new(Relations::Id)
|
||||
.integer()
|
||||
ColumnDef::new(Relations::Internal)
|
||||
.big_integer()
|
||||
.not_null()
|
||||
.primary_key()
|
||||
.auto_increment()
|
||||
)
|
||||
.col(ColumnDef::new(Relations::Follower).integer().not_null())
|
||||
.col(ColumnDef::new(Relations::Follower).big_integer().not_null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-relations-follower")
|
||||
.from(Relations::Table, Relations::Follower)
|
||||
.to(Actors::Table, Actors::Id)
|
||||
.to(Actors::Table, Actors::Internal)
|
||||
.on_update(ForeignKeyAction::Cascade)
|
||||
.on_delete(ForeignKeyAction::Cascade)
|
||||
)
|
||||
.col(ColumnDef::new(Relations::Following).integer().not_null())
|
||||
.col(ColumnDef::new(Relations::Following).big_integer().not_null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-relations-following")
|
||||
.from(Relations::Table, Relations::Following)
|
||||
.to(Actors::Table, Actors::Id)
|
||||
.to(Actors::Table, Actors::Internal)
|
||||
.on_update(ForeignKeyAction::Cascade)
|
||||
.on_delete(ForeignKeyAction::Cascade)
|
||||
)
|
||||
.col(ColumnDef::new(Relations::Accept).integer().null())
|
||||
.col(ColumnDef::new(Relations::Accept).big_integer().null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-relations-accept")
|
||||
.from(Relations::Table, Relations::Accept)
|
||||
.to(Activities::Table, Activities::Id)
|
||||
.to(Activities::Table, Activities::Internal)
|
||||
.on_update(ForeignKeyAction::Cascade)
|
||||
)
|
||||
.col(ColumnDef::new(Relations::Activity).integer().not_null())
|
||||
.col(ColumnDef::new(Relations::Activity).big_integer().not_null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-relations-activity")
|
||||
.from(Relations::Table, Relations::Activity)
|
||||
.to(Activities::Table, Activities::Id)
|
||||
.to(Activities::Table, Activities::Internal)
|
||||
.on_update(ForeignKeyAction::Cascade)
|
||||
)
|
||||
.to_owned()
|
||||
|
@ -102,27 +102,27 @@ impl MigrationTrait for Migration {
|
|||
.table(Likes::Table)
|
||||
.comment("all like events, joining actor to object")
|
||||
.col(
|
||||
ColumnDef::new(Likes::Id)
|
||||
.integer()
|
||||
ColumnDef::new(Likes::Internal)
|
||||
.big_integer()
|
||||
.not_null()
|
||||
.primary_key()
|
||||
.auto_increment()
|
||||
)
|
||||
.col(ColumnDef::new(Likes::Actor).integer().not_null())
|
||||
.col(ColumnDef::new(Likes::Actor).big_integer().not_null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-likes-actor")
|
||||
.from(Likes::Table, Likes::Actor)
|
||||
.to(Actors::Table, Actors::Id)
|
||||
.to(Actors::Table, Actors::Internal)
|
||||
.on_update(ForeignKeyAction::Cascade)
|
||||
.on_delete(ForeignKeyAction::Cascade)
|
||||
)
|
||||
.col(ColumnDef::new(Likes::Likes).integer().not_null())
|
||||
.col(ColumnDef::new(Likes::Object).big_integer().not_null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-likes-likes")
|
||||
.from(Likes::Table, Likes::Likes)
|
||||
.to(Objects::Table, Objects::Id)
|
||||
.name("fkey-likes-object")
|
||||
.from(Likes::Table, Likes::Object)
|
||||
.to(Objects::Table, Objects::Internal)
|
||||
.on_update(ForeignKeyAction::Cascade)
|
||||
.on_delete(ForeignKeyAction::Cascade)
|
||||
)
|
||||
|
@ -136,17 +136,17 @@ impl MigrationTrait for Migration {
|
|||
.await?;
|
||||
|
||||
manager
|
||||
.create_index(Index::create().name("index-likes-likes").table(Likes::Table).col(Likes::Likes).to_owned())
|
||||
.create_index(Index::create().name("index-likes-object").table(Likes::Table).col(Likes::Likes).to_owned())
|
||||
.await?;
|
||||
|
||||
manager
|
||||
.create_index(
|
||||
Index::create()
|
||||
.unique()
|
||||
.name("index-likes-actor-likes")
|
||||
.name("index-likes-actor-object")
|
||||
.table(Likes::Table)
|
||||
.col(Likes::Actor)
|
||||
.col(Likes::Likes)
|
||||
.col(Likes::Object)
|
||||
.to_owned()
|
||||
).await?;
|
||||
|
||||
|
@ -156,27 +156,27 @@ impl MigrationTrait for Migration {
|
|||
.table(Announces::Table)
|
||||
.comment("all share/boost/reblog events, joining actor to object")
|
||||
.col(
|
||||
ColumnDef::new(Announces::Id)
|
||||
.integer()
|
||||
ColumnDef::new(Announces::Internal)
|
||||
.big_integer()
|
||||
.not_null()
|
||||
.primary_key()
|
||||
.auto_increment()
|
||||
)
|
||||
.col(ColumnDef::new(Announces::Actor).integer().not_null())
|
||||
.col(ColumnDef::new(Announces::Actor).big_integer().not_null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-announces-actor")
|
||||
.from(Announces::Table, Announces::Actor)
|
||||
.to(Actors::Table, Actors::Id)
|
||||
.to(Actors::Table, Actors::Internal)
|
||||
.on_update(ForeignKeyAction::Cascade)
|
||||
.on_delete(ForeignKeyAction::Cascade)
|
||||
)
|
||||
.col(ColumnDef::new(Announces::Announces).integer().not_null())
|
||||
.col(ColumnDef::new(Announces::Object).big_integer().not_null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-announces-announces")
|
||||
.from(Announces::Table, Announces::Announces)
|
||||
.to(Objects::Table, Objects::Id)
|
||||
.name("fkey-announces-object")
|
||||
.from(Announces::Table, Announces::Object)
|
||||
.to(Objects::Table, Objects::Internal)
|
||||
.on_update(ForeignKeyAction::Cascade)
|
||||
.on_delete(ForeignKeyAction::Cascade)
|
||||
)
|
||||
|
@ -190,7 +190,7 @@ impl MigrationTrait for Migration {
|
|||
.await?;
|
||||
|
||||
manager
|
||||
.create_index(Index::create().name("index-announces-announces").table(Announces::Table).col(Announces::Announces).to_owned())
|
||||
.create_index(Index::create().name("index-announces-object").table(Announces::Table).col(Announces::Announces).to_owned())
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
|
@ -217,10 +217,10 @@ impl MigrationTrait for Migration {
|
|||
.drop_index(Index::drop().name("index-likes-actor").table(Likes::Table).to_owned())
|
||||
.await?;
|
||||
manager
|
||||
.drop_index(Index::drop().name("index-likes-likes").table(Likes::Table).to_owned())
|
||||
.drop_index(Index::drop().name("index-likes-object").table(Likes::Table).to_owned())
|
||||
.await?;
|
||||
manager
|
||||
.drop_index(Index::drop().name("index-likes-actor-likes").table(Likes::Table).to_owned())
|
||||
.drop_index(Index::drop().name("index-likes-actor-object").table(Likes::Table).to_owned())
|
||||
.await?;
|
||||
|
||||
manager
|
||||
|
@ -228,10 +228,10 @@ impl MigrationTrait for Migration {
|
|||
.await?;
|
||||
|
||||
manager
|
||||
.drop_index(Index::drop().name("shares-actor-index").table(Announces::Table).to_owned())
|
||||
.drop_index(Index::drop().name("index-announces-actor").table(Announces::Table).to_owned())
|
||||
.await?;
|
||||
manager
|
||||
.drop_index(Index::drop().name("shares-shares-index").table(Announces::Table).to_owned())
|
||||
.drop_index(Index::drop().name("index-announces-object").table(Announces::Table).to_owned())
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -5,7 +5,7 @@ use super::m20240524_000001_create_actor_activity_object_tables::Actors;
|
|||
#[derive(DeriveIden)]
|
||||
pub enum Configs {
|
||||
Table,
|
||||
Id,
|
||||
Internal,
|
||||
Actor,
|
||||
AcceptFollowRequests,
|
||||
ShowFollowersCount,
|
||||
|
@ -17,7 +17,7 @@ pub enum Configs {
|
|||
#[derive(DeriveIden)]
|
||||
pub enum Credentials {
|
||||
Table,
|
||||
Id,
|
||||
Internal,
|
||||
Actor,
|
||||
Login,
|
||||
Password,
|
||||
|
@ -26,7 +26,7 @@ pub enum Credentials {
|
|||
#[derive(DeriveIden)]
|
||||
pub enum Sessions {
|
||||
Table,
|
||||
Id,
|
||||
Internal,
|
||||
Actor,
|
||||
Secret,
|
||||
Expires,
|
||||
|
@ -44,13 +44,13 @@ impl MigrationTrait for Migration {
|
|||
.table(Configs::Table)
|
||||
.comment("configuration for each local user")
|
||||
.col(
|
||||
ColumnDef::new(Configs::Id)
|
||||
.integer()
|
||||
ColumnDef::new(Configs::Internal)
|
||||
.big_integer()
|
||||
.not_null()
|
||||
.primary_key()
|
||||
.auto_increment()
|
||||
)
|
||||
.col(ColumnDef::new(Configs::Actor).integer().not_null())
|
||||
.col(ColumnDef::new(Configs::Actor).string().not_null().unique_key())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-config-actor")
|
||||
|
@ -69,7 +69,7 @@ impl MigrationTrait for Migration {
|
|||
.await?;
|
||||
|
||||
manager
|
||||
.create_index(Index::create().name("index-configs-actor").table(Configs::Table).col(Configs::Actor).to_owned())
|
||||
.create_index(Index::create().unique().name("index-configs-actor").table(Configs::Table).col(Configs::Actor).to_owned())
|
||||
.await?;
|
||||
|
||||
manager
|
||||
|
@ -78,13 +78,13 @@ impl MigrationTrait for Migration {
|
|||
.table(Credentials::Table)
|
||||
.comment("simple login credentials to authenticate local users")
|
||||
.col(
|
||||
ColumnDef::new(Credentials::Id)
|
||||
.integer()
|
||||
ColumnDef::new(Credentials::Internal)
|
||||
.big_integer()
|
||||
.not_null()
|
||||
.primary_key()
|
||||
.auto_increment()
|
||||
)
|
||||
.col(ColumnDef::new(Credentials::Actor).integer().not_null())
|
||||
.col(ColumnDef::new(Credentials::Actor).string().not_null().unique_key())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-credentials-actor")
|
||||
|
@ -99,6 +99,10 @@ impl MigrationTrait for Migration {
|
|||
)
|
||||
.await?;
|
||||
|
||||
manager
|
||||
.create_index(Index::create().unique().name("index-credentials-actor").table(Credentials::Table).col(Credentials::Actor).to_owned())
|
||||
.await?;
|
||||
|
||||
manager
|
||||
.create_index(Index::create().name("index-credentials-login").table(Credentials::Table).col(Credentials::Login).to_owned())
|
||||
.await?;
|
||||
|
@ -109,13 +113,13 @@ impl MigrationTrait for Migration {
|
|||
.table(Sessions::Table)
|
||||
.comment("authenticated sessions from local users")
|
||||
.col(
|
||||
ColumnDef::new(Sessions::Id)
|
||||
.integer()
|
||||
ColumnDef::new(Sessions::Internal)
|
||||
.big_integer()
|
||||
.not_null()
|
||||
.primary_key()
|
||||
.auto_increment()
|
||||
)
|
||||
.col(ColumnDef::new(Sessions::Actor).integer().not_null())
|
||||
.col(ColumnDef::new(Sessions::Actor).string().not_null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-sessions-actor")
|
||||
|
|
|
@ -5,7 +5,7 @@ use super::m20240524_000001_create_actor_activity_object_tables::{Activities, Ac
|
|||
#[derive(DeriveIden)]
|
||||
pub enum Addressing {
|
||||
Table,
|
||||
Id,
|
||||
Internal,
|
||||
Actor,
|
||||
Instance,
|
||||
Activity,
|
||||
|
@ -16,7 +16,7 @@ pub enum Addressing {
|
|||
#[derive(DeriveIden)]
|
||||
pub enum Deliveries {
|
||||
Table,
|
||||
Id,
|
||||
Internal,
|
||||
Actor,
|
||||
Target,
|
||||
Activity,
|
||||
|
@ -37,42 +37,42 @@ impl MigrationTrait for Migration {
|
|||
.table(Addressing::Table)
|
||||
.comment("this join table contains all addressing relations, serving effectively as permissions truth table")
|
||||
.col(
|
||||
ColumnDef::new(Addressing::Id)
|
||||
.integer()
|
||||
ColumnDef::new(Addressing::Internal)
|
||||
.big_integer()
|
||||
.not_null()
|
||||
.auto_increment()
|
||||
.primary_key()
|
||||
)
|
||||
.col(ColumnDef::new(Addressing::Actor).integer().not_null())
|
||||
.col(ColumnDef::new(Addressing::Actor).big_integer().not_null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-addressing-actor")
|
||||
.from(Addressing::Table, Addressing::Actor)
|
||||
.to(Actors::Table, Actors::Id)
|
||||
.to(Actors::Table, Actors::Internal)
|
||||
.on_update(ForeignKeyAction::Cascade)
|
||||
)
|
||||
.col(ColumnDef::new(Addressing::Instance).integer().not_null())
|
||||
.col(ColumnDef::new(Addressing::Instance).big_integer().not_null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-addressing-instance")
|
||||
.from(Addressing::Table, Addressing::Instance)
|
||||
.to(Instances::Table, Instances::Id)
|
||||
.to(Instances::Table, Instances::Internal)
|
||||
.on_update(ForeignKeyAction::Cascade)
|
||||
)
|
||||
.col(ColumnDef::new(Addressing::Activity).integer().null())
|
||||
.col(ColumnDef::new(Addressing::Activity).big_integer().null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-addressing-activity")
|
||||
.from(Addressing::Table, Addressing::Activity)
|
||||
.to(Activities::Table, Activities::Id)
|
||||
.to(Activities::Table, Activities::Internal)
|
||||
.on_update(ForeignKeyAction::Cascade)
|
||||
)
|
||||
.col(ColumnDef::new(Addressing::Object).integer().null())
|
||||
.col(ColumnDef::new(Addressing::Object).big_integer().null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-addressing-object")
|
||||
.from(Addressing::Table, Addressing::Object)
|
||||
.to(Objects::Table, Objects::Id)
|
||||
.to(Objects::Table, Objects::Internal)
|
||||
.on_update(ForeignKeyAction::Cascade)
|
||||
)
|
||||
.col(ColumnDef::new(Addressing::Published).date_time().not_null().default(Expr::current_timestamp()))
|
||||
|
@ -116,13 +116,13 @@ impl MigrationTrait for Migration {
|
|||
.table(Deliveries::Table)
|
||||
.comment("this table contains all enqueued outgoing delivery jobs")
|
||||
.col(
|
||||
ColumnDef::new(Deliveries::Id)
|
||||
.integer()
|
||||
ColumnDef::new(Deliveries::Internal)
|
||||
.big_integer()
|
||||
.not_null()
|
||||
.auto_increment()
|
||||
.primary_key()
|
||||
)
|
||||
.col(ColumnDef::new(Deliveries::Actor).integer().not_null())
|
||||
.col(ColumnDef::new(Deliveries::Actor).string().not_null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-deliveries-actor")
|
||||
|
@ -132,7 +132,7 @@ impl MigrationTrait for Migration {
|
|||
.on_delete(ForeignKeyAction::Cascade)
|
||||
)
|
||||
.col(ColumnDef::new(Deliveries::Target).string().not_null())
|
||||
.col(ColumnDef::new(Deliveries::Activity).integer().not_null())
|
||||
.col(ColumnDef::new(Deliveries::Activity).string().not_null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-deliveries-activity")
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
use sea_orm_migration::prelude::*;
|
||||
|
||||
use super::m20240524_000001_create_actor_activity_object_tables::{Actors, Objects};
|
||||
use super::m20240524_000001_create_actor_activity_object_tables::Objects;
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
pub enum Attachments {
|
||||
Table,
|
||||
Id,
|
||||
Internal,
|
||||
DocumentType,
|
||||
Url,
|
||||
Object,
|
||||
|
@ -17,7 +17,7 @@ pub enum Attachments {
|
|||
#[derive(DeriveIden)]
|
||||
pub enum Mentions {
|
||||
Table,
|
||||
Id,
|
||||
Internal,
|
||||
Object,
|
||||
Actor,
|
||||
Published,
|
||||
|
@ -26,7 +26,7 @@ pub enum Mentions {
|
|||
#[derive(DeriveIden)]
|
||||
pub enum Hashtags {
|
||||
Table,
|
||||
Id,
|
||||
Internal,
|
||||
Object,
|
||||
Name,
|
||||
Published,
|
||||
|
@ -44,19 +44,19 @@ impl MigrationTrait for Migration {
|
|||
.table(Attachments::Table)
|
||||
.comment("media attachments related to objects")
|
||||
.col(
|
||||
ColumnDef::new(Attachments::Id)
|
||||
.integer()
|
||||
ColumnDef::new(Attachments::Internal)
|
||||
.big_integer()
|
||||
.not_null()
|
||||
.primary_key()
|
||||
.auto_increment()
|
||||
)
|
||||
.col(ColumnDef::new(Attachments::Url).string().not_null().unique_key())
|
||||
.col(ColumnDef::new(Attachments::Object).integer().not_null())
|
||||
.col(ColumnDef::new(Attachments::Object).big_integer().not_null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-attachments-object")
|
||||
.from(Attachments::Table, Attachments::Object)
|
||||
.to(Objects::Table, Objects::Id)
|
||||
.to(Objects::Table, Objects::Internal)
|
||||
.on_update(ForeignKeyAction::Cascade)
|
||||
.on_delete(ForeignKeyAction::Cascade)
|
||||
)
|
||||
|
@ -78,30 +78,30 @@ impl MigrationTrait for Migration {
|
|||
.table(Mentions::Table)
|
||||
.comment("join table relating posts to mentioned users")
|
||||
.col(
|
||||
ColumnDef::new(Mentions::Id)
|
||||
.integer()
|
||||
ColumnDef::new(Mentions::Internal)
|
||||
.big_integer()
|
||||
.not_null()
|
||||
.primary_key()
|
||||
.auto_increment()
|
||||
)
|
||||
.col(ColumnDef::new(Mentions::Object).integer().not_null())
|
||||
.col(ColumnDef::new(Mentions::Object).big_integer().not_null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-mentions-object")
|
||||
.from(Mentions::Table, Mentions::Object)
|
||||
.to(Objects::Table, Objects::Id)
|
||||
.on_update(ForeignKeyAction::Cascade)
|
||||
.on_delete(ForeignKeyAction::Cascade)
|
||||
)
|
||||
.col(ColumnDef::new(Mentions::Actor).integer().not_null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-mentions-actor")
|
||||
.from(Mentions::Table, Mentions::Actor)
|
||||
.to(Actors::Table, Actors::Id)
|
||||
.to(Objects::Table, Objects::Internal)
|
||||
.on_update(ForeignKeyAction::Cascade)
|
||||
.on_delete(ForeignKeyAction::Cascade)
|
||||
)
|
||||
.col(ColumnDef::new(Mentions::Actor).string().not_null())
|
||||
// .foreign_key(
|
||||
// ForeignKey::create()
|
||||
// .name("fkey-mentions-actor")
|
||||
// .from(Mentions::Table, Mentions::Actor)
|
||||
// .to(Actors::Table, Actors::Internal)
|
||||
// .on_update(ForeignKeyAction::Cascade)
|
||||
// .on_delete(ForeignKeyAction::Cascade)
|
||||
// )
|
||||
.col(ColumnDef::new(Mentions::Published).date_time().not_null().default(Expr::current_timestamp()))
|
||||
.to_owned()
|
||||
)
|
||||
|
@ -128,18 +128,18 @@ impl MigrationTrait for Migration {
|
|||
.table(Hashtags::Table)
|
||||
.comment("join table relating posts to hashtags")
|
||||
.col(
|
||||
ColumnDef::new(Hashtags::Id)
|
||||
.integer()
|
||||
ColumnDef::new(Hashtags::Internal)
|
||||
.big_integer()
|
||||
.not_null()
|
||||
.primary_key()
|
||||
.auto_increment()
|
||||
)
|
||||
.col(ColumnDef::new(Hashtags::Object).integer().not_null())
|
||||
.col(ColumnDef::new(Hashtags::Object).big_integer().not_null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.name("fkey-hashtags-object")
|
||||
.from(Hashtags::Table, Hashtags::Object)
|
||||
.to(Objects::Table, Objects::Id)
|
||||
.to(Objects::Table, Objects::Internal)
|
||||
.on_update(ForeignKeyAction::Cascade)
|
||||
.on_delete(ForeignKeyAction::Cascade)
|
||||
)
|
||||
|
|
|
@ -7,12 +7,12 @@ use crate::routes::activitypub::jsonld::LD;
|
|||
#[sea_orm(table_name = "activities")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub internal: i64,
|
||||
#[sea_orm(unique)]
|
||||
pub ap_id: String,
|
||||
pub id: String,
|
||||
pub activity_type: ActivityType,
|
||||
pub actor: i32,
|
||||
pub object: Option<i32>,
|
||||
pub actor: String,
|
||||
pub object: Option<String>,
|
||||
pub target: Option<String>,
|
||||
pub to: Option<Json>,
|
||||
pub bto: Option<Json>,
|
||||
|
|
|
@ -8,11 +8,11 @@ use crate::routes::activitypub::jsonld::LD;
|
|||
#[sea_orm(table_name = "actors")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub internal: i64,
|
||||
#[sea_orm(unique)]
|
||||
pub ap_id: String,
|
||||
pub id: String,
|
||||
pub actor_type: ActorType,
|
||||
pub instance: i32,
|
||||
pub domain: String,
|
||||
pub name: Option<String>,
|
||||
pub summary: Option<String>,
|
||||
pub image: Option<String>,
|
||||
|
@ -49,8 +49,8 @@ pub enum Relation {
|
|||
Deliveries,
|
||||
#[sea_orm(
|
||||
belongs_to = "super::instance::Entity",
|
||||
from = "Column::Instance",
|
||||
to = "super::instance::Column::Id",
|
||||
from = "Column::Domain",
|
||||
to = "super::instance::Column::Domain",
|
||||
on_update = "Cascade",
|
||||
on_delete = "NoAction"
|
||||
)]
|
||||
|
|
|
@ -7,11 +7,11 @@ use crate::routes::activitypub::jsonld::LD;
|
|||
#[sea_orm(table_name = "addressing")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub actor: i32,
|
||||
pub instance: i32,
|
||||
pub activity: Option<i32>,
|
||||
pub object: Option<i32>,
|
||||
pub internal: i64,
|
||||
pub actor: Option<i64>,
|
||||
pub instance: Option<i64>,
|
||||
pub activity: Option<i64>,
|
||||
pub object: Option<i64>,
|
||||
pub published: ChronoDateTimeUtc,
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ pub enum Relation {
|
|||
#[sea_orm(
|
||||
belongs_to = "super::activity::Entity",
|
||||
from = "Column::Activity",
|
||||
to = "super::activity::Column::Id",
|
||||
to = "super::activity::Column::Internal",
|
||||
on_update = "Cascade",
|
||||
on_delete = "NoAction"
|
||||
)]
|
||||
|
@ -28,7 +28,7 @@ pub enum Relation {
|
|||
#[sea_orm(
|
||||
belongs_to = "super::actor::Entity",
|
||||
from = "Column::Actor",
|
||||
to = "super::actor::Column::Id",
|
||||
to = "super::actor::Column::Internal",
|
||||
on_update = "Cascade",
|
||||
on_delete = "NoAction"
|
||||
)]
|
||||
|
@ -36,7 +36,7 @@ pub enum Relation {
|
|||
#[sea_orm(
|
||||
belongs_to = "super::instance::Entity",
|
||||
from = "Column::Instance",
|
||||
to = "super::instance::Column::Id",
|
||||
to = "super::instance::Column::Internal",
|
||||
on_update = "Cascade",
|
||||
on_delete = "NoAction"
|
||||
)]
|
||||
|
@ -44,7 +44,7 @@ pub enum Relation {
|
|||
#[sea_orm(
|
||||
belongs_to = "super::object::Entity",
|
||||
from = "Column::Object",
|
||||
to = "super::object::Column::Id",
|
||||
to = "super::object::Column::Internal",
|
||||
on_update = "Cascade",
|
||||
on_delete = "NoAction"
|
||||
)]
|
||||
|
|
|
@ -4,9 +4,9 @@ use sea_orm::entity::prelude::*;
|
|||
#[sea_orm(table_name = "announces")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub actor: i32,
|
||||
pub announces: i32,
|
||||
pub internal: i64,
|
||||
pub actor: i64,
|
||||
pub object: i64,
|
||||
pub published: ChronoDateTimeUtc,
|
||||
}
|
||||
|
||||
|
@ -15,15 +15,15 @@ pub enum Relation {
|
|||
#[sea_orm(
|
||||
belongs_to = "super::actor::Entity",
|
||||
from = "Column::Actor",
|
||||
to = "super::actor::Column::Id",
|
||||
to = "super::actor::Column::Internal",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
Actors,
|
||||
#[sea_orm(
|
||||
belongs_to = "super::object::Entity",
|
||||
from = "Column::Announces",
|
||||
to = "super::object::Column::Id",
|
||||
from = "Column::Object",
|
||||
to = "super::object::Column::Internal",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
|
|
|
@ -9,10 +9,10 @@ use super::addressing::Event;
|
|||
#[sea_orm(table_name = "attachments")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub internal: i64,
|
||||
#[sea_orm(unique)]
|
||||
pub url: String,
|
||||
pub object: i32,
|
||||
pub object: i64,
|
||||
pub document_type: String,
|
||||
pub name: Option<String>,
|
||||
pub media_type: String,
|
||||
|
@ -24,7 +24,7 @@ pub enum Relation {
|
|||
#[sea_orm(
|
||||
belongs_to = "super::object::Entity",
|
||||
from = "Column::Object",
|
||||
to = "super::object::Column::Id",
|
||||
to = "super::object::Column::Internal",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
|
|
|
@ -4,8 +4,9 @@ use sea_orm::entity::prelude::*;
|
|||
#[sea_orm(table_name = "configs")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub actor: i32,
|
||||
pub internal: i64,
|
||||
#[sea_orm(unique)]
|
||||
pub actor: String,
|
||||
pub accept_follow_requests: bool,
|
||||
pub show_followers_count: bool,
|
||||
pub show_following_count: bool,
|
||||
|
@ -16,7 +17,7 @@ pub struct Model {
|
|||
impl Default for Model {
|
||||
fn default() -> Self {
|
||||
Model {
|
||||
id: 0, actor: 0,
|
||||
internal: 0, actor: "".into(),
|
||||
accept_follow_requests: true,
|
||||
show_following_count: true,
|
||||
show_following: true,
|
||||
|
|
|
@ -4,8 +4,9 @@ use sea_orm::entity::prelude::*;
|
|||
#[sea_orm(table_name = "credentials")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub actor: i32,
|
||||
pub internal: i64,
|
||||
#[sea_orm(unique)]
|
||||
pub actor: String,
|
||||
pub login: String,
|
||||
pub password: String,
|
||||
}
|
||||
|
|
|
@ -4,10 +4,10 @@ use sea_orm::entity::prelude::*;
|
|||
#[sea_orm(table_name = "deliveries")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub actor: i32,
|
||||
pub internal: i64,
|
||||
pub actor: String,
|
||||
pub target: String,
|
||||
pub activity: i32,
|
||||
pub activity: String,
|
||||
pub created: ChronoDateTimeUtc,
|
||||
pub not_before: ChronoDateTimeUtc,
|
||||
pub attempt: i32,
|
||||
|
|
|
@ -4,8 +4,8 @@ use sea_orm::entity::prelude::*;
|
|||
#[sea_orm(table_name = "hashtags")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub object: i32,
|
||||
pub internal: i64,
|
||||
pub object: i64,
|
||||
pub name: String,
|
||||
pub published: ChronoDateTimeUtc,
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ pub enum Relation {
|
|||
#[sea_orm(
|
||||
belongs_to = "super::object::Entity",
|
||||
from = "Column::Object",
|
||||
to = "super::object::Column::Id",
|
||||
to = "super::object::Column::Internal",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
|
|
|
@ -4,11 +4,13 @@ use sea_orm::entity::prelude::*;
|
|||
#[sea_orm(table_name = "instances")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub name: Option<String>,
|
||||
pub internal: i64,
|
||||
#[sea_orm(unique)]
|
||||
pub domain: String,
|
||||
pub name: Option<String>,
|
||||
pub software: Option<String>,
|
||||
pub version: Option<String>,
|
||||
pub icon: Option<String>,
|
||||
pub down_since: Option<ChronoDateTimeUtc>,
|
||||
pub users: Option<i32>,
|
||||
pub posts: Option<i32>,
|
||||
|
|
|
@ -4,9 +4,9 @@ use sea_orm::entity::prelude::*;
|
|||
#[sea_orm(table_name = "likes")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub actor: i32,
|
||||
pub likes: i32,
|
||||
pub internal: i64,
|
||||
pub actor: i64,
|
||||
pub object: i64,
|
||||
pub published: ChronoDateTimeUtc,
|
||||
}
|
||||
|
||||
|
@ -15,15 +15,15 @@ pub enum Relation {
|
|||
#[sea_orm(
|
||||
belongs_to = "super::actor::Entity",
|
||||
from = "Column::Actor",
|
||||
to = "super::actor::Column::Id",
|
||||
to = "super::actor::Column::Internal",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
Actors,
|
||||
#[sea_orm(
|
||||
belongs_to = "super::object::Entity",
|
||||
from = "Column::Likes",
|
||||
to = "super::object::Column::Id",
|
||||
from = "Column::Object",
|
||||
to = "super::object::Column::Internal",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
|
|
|
@ -4,9 +4,9 @@ use sea_orm::entity::prelude::*;
|
|||
#[sea_orm(table_name = "mentions")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub object: i32,
|
||||
pub actor: i32,
|
||||
pub internal: i64,
|
||||
pub object: i64,
|
||||
pub actor: String,
|
||||
pub published: ChronoDateTimeUtc,
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ pub enum Relation {
|
|||
#[sea_orm(
|
||||
belongs_to = "super::object::Entity",
|
||||
from = "Column::Object",
|
||||
to = "super::object::Column::Id",
|
||||
to = "super::object::Column::Internal",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
|
|
|
@ -9,11 +9,11 @@ use super::Audience;
|
|||
#[sea_orm(table_name = "objects")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub internal: i64,
|
||||
#[sea_orm(unique)]
|
||||
pub ap_id: String,
|
||||
pub id: String,
|
||||
pub object_type: String,
|
||||
pub attributed_to: Option<i32>,
|
||||
pub attributed_to: Option<String>,
|
||||
pub name: Option<String>,
|
||||
pub summary: Option<String>,
|
||||
pub content: Option<String>,
|
||||
|
@ -56,6 +56,14 @@ pub enum Relation {
|
|||
Likes,
|
||||
#[sea_orm(has_many = "super::mention::Entity")]
|
||||
Mentions,
|
||||
#[sea_orm(
|
||||
belongs_to = "Entity",
|
||||
from = "Column::InReplyTo",
|
||||
to = "Column::Id",
|
||||
on_update = "Cascade",
|
||||
on_delete = "NoAction"
|
||||
)]
|
||||
Objects,
|
||||
}
|
||||
|
||||
impl Related<super::activity::Entity> for Entity {
|
||||
|
@ -106,6 +114,12 @@ impl Related<super::mention::Entity> for Entity {
|
|||
}
|
||||
}
|
||||
|
||||
impl Related<Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::Objects.def()
|
||||
}
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
|
||||
impl ActiveModel {
|
||||
|
|
|
@ -4,11 +4,11 @@ use sea_orm::entity::prelude::*;
|
|||
#[sea_orm(table_name = "relations")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub follower: i32,
|
||||
pub following: i32,
|
||||
pub accept: Option<i32>,
|
||||
pub activity: i32,
|
||||
pub internal: i64,
|
||||
pub follower: i64,
|
||||
pub following: i64,
|
||||
pub accept: Option<i64>,
|
||||
pub activity: i64,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
|
@ -16,35 +16,35 @@ pub enum Relation {
|
|||
#[sea_orm(
|
||||
belongs_to = "super::activity::Entity",
|
||||
from = "Column::Accept",
|
||||
to = "super::activity::Column::Id",
|
||||
to = "super::activity::Column::Internal",
|
||||
on_update = "Cascade",
|
||||
on_delete = "NoAction"
|
||||
)]
|
||||
Activities2,
|
||||
ActivitiesAccept,
|
||||
#[sea_orm(
|
||||
belongs_to = "super::activity::Entity",
|
||||
from = "Column::Activity",
|
||||
to = "super::activity::Column::Id",
|
||||
to = "super::activity::Column::Internal",
|
||||
on_update = "Cascade",
|
||||
on_delete = "NoAction"
|
||||
)]
|
||||
Activities1,
|
||||
ActivitiesFollow,
|
||||
#[sea_orm(
|
||||
belongs_to = "super::actor::Entity",
|
||||
from = "Column::Follower",
|
||||
to = "super::actor::Column::Id",
|
||||
to = "super::actor::Column::Internal",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
Actors2,
|
||||
ActorsFollower,
|
||||
#[sea_orm(
|
||||
belongs_to = "super::actor::Entity",
|
||||
from = "Column::Following",
|
||||
to = "super::actor::Column::Id",
|
||||
to = "super::actor::Column::Internal",
|
||||
on_update = "Cascade",
|
||||
on_delete = "Cascade"
|
||||
)]
|
||||
Actors1,
|
||||
ActorsFollowing,
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
||||
|
|
|
@ -4,8 +4,8 @@ use sea_orm::entity::prelude::*;
|
|||
#[sea_orm(table_name = "sessions")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: i32,
|
||||
pub actor: i32,
|
||||
pub internal: i64,
|
||||
pub actor: String,
|
||||
pub secret: String,
|
||||
pub expires: ChronoDateTimeUtc,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue