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