2024-03-16 03:29:06 +01:00
|
|
|
use sea_orm_migration::prelude::*;
|
|
|
|
|
|
|
|
#[derive(DeriveMigrationName)]
|
|
|
|
pub struct Migration;
|
|
|
|
|
|
|
|
#[async_trait::async_trait]
|
|
|
|
impl MigrationTrait for Migration {
|
|
|
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
2024-03-16 05:45:58 +01:00
|
|
|
manager
|
|
|
|
.create_table(
|
2024-03-16 03:29:06 +01:00
|
|
|
Table::create()
|
|
|
|
.table(Users::Table)
|
|
|
|
.col(
|
|
|
|
ColumnDef::new(Users::Id)
|
|
|
|
.string()
|
|
|
|
.not_null()
|
|
|
|
.primary_key()
|
|
|
|
)
|
2024-03-19 01:00:44 +01:00
|
|
|
.col(ColumnDef::new(Users::ActorType).string().not_null())
|
2024-03-21 01:09:33 +01:00
|
|
|
.col(ColumnDef::new(Users::Domain).string().not_null())
|
2024-03-16 05:45:58 +01:00
|
|
|
.col(ColumnDef::new(Users::Name).string().not_null())
|
2024-03-21 01:09:33 +01:00
|
|
|
.col(ColumnDef::new(Users::Summary).string().null())
|
|
|
|
.col(ColumnDef::new(Users::Image).string().null())
|
|
|
|
.col(ColumnDef::new(Users::Icon).string().null())
|
|
|
|
.col(ColumnDef::new(Users::PreferredUsername).string().null())
|
|
|
|
.col(ColumnDef::new(Users::Inbox).string().null())
|
|
|
|
.col(ColumnDef::new(Users::SharedInbox).string().null())
|
|
|
|
.col(ColumnDef::new(Users::Outbox).string().null())
|
|
|
|
.col(ColumnDef::new(Users::Following).string().null())
|
|
|
|
.col(ColumnDef::new(Users::Followers).string().null())
|
2024-03-23 16:44:27 +01:00
|
|
|
.col(ColumnDef::new(Users::FollowingCount).integer().not_null().default(0))
|
|
|
|
.col(ColumnDef::new(Users::FollowersCount).integer().not_null().default(0))
|
2024-03-21 02:11:31 +01:00
|
|
|
.col(ColumnDef::new(Users::PublicKey).string().not_null())
|
|
|
|
.col(ColumnDef::new(Users::PrivateKey).string().null())
|
2024-03-21 01:09:33 +01:00
|
|
|
.col(ColumnDef::new(Users::Created).date_time().not_null())
|
|
|
|
.col(ColumnDef::new(Users::Updated).date_time().not_null())
|
2024-03-16 03:29:06 +01:00
|
|
|
.to_owned()
|
|
|
|
)
|
|
|
|
.await?;
|
|
|
|
|
2024-03-16 05:45:58 +01:00
|
|
|
manager
|
|
|
|
.create_table(
|
|
|
|
Table::create()
|
|
|
|
.table(Activities::Table)
|
|
|
|
.col(
|
|
|
|
ColumnDef::new(Activities::Id)
|
|
|
|
.string()
|
|
|
|
.not_null()
|
|
|
|
.primary_key()
|
|
|
|
)
|
2024-03-19 01:00:44 +01:00
|
|
|
.col(ColumnDef::new(Activities::ActivityType).string().not_null())
|
2024-03-16 05:45:58 +01:00
|
|
|
.col(ColumnDef::new(Activities::Actor).string().not_null())
|
|
|
|
.col(ColumnDef::new(Activities::Object).string().null())
|
|
|
|
.col(ColumnDef::new(Activities::Target).string().null())
|
2024-03-21 01:09:33 +01:00
|
|
|
.col(ColumnDef::new(Activities::To).json().null())
|
|
|
|
.col(ColumnDef::new(Activities::Bto).json().null())
|
|
|
|
.col(ColumnDef::new(Activities::Cc).json().null())
|
|
|
|
.col(ColumnDef::new(Activities::Bcc).json().null())
|
|
|
|
.col(ColumnDef::new(Activities::Published).date_time().not_null())
|
2024-03-16 05:45:58 +01:00
|
|
|
.to_owned()
|
|
|
|
).await?;
|
|
|
|
|
|
|
|
manager
|
|
|
|
.create_table(
|
|
|
|
Table::create()
|
|
|
|
.table(Objects::Table)
|
|
|
|
.col(
|
|
|
|
ColumnDef::new(Objects::Id)
|
|
|
|
.string()
|
|
|
|
.not_null()
|
|
|
|
.primary_key()
|
|
|
|
)
|
2024-03-19 01:00:44 +01:00
|
|
|
.col(ColumnDef::new(Objects::ObjectType).string().not_null())
|
2024-03-16 05:45:58 +01:00
|
|
|
.col(ColumnDef::new(Objects::AttributedTo).string().null())
|
|
|
|
.col(ColumnDef::new(Objects::Name).string().null())
|
|
|
|
.col(ColumnDef::new(Objects::Summary).string().null())
|
|
|
|
.col(ColumnDef::new(Objects::Content).string().null())
|
2024-03-22 05:34:08 +01:00
|
|
|
.col(ColumnDef::new(Objects::Likes).integer().not_null().default(0))
|
|
|
|
.col(ColumnDef::new(Objects::Shares).integer().not_null().default(0))
|
|
|
|
.col(ColumnDef::new(Objects::Comments).integer().not_null().default(0))
|
2024-03-21 19:51:00 +01:00
|
|
|
.col(ColumnDef::new(Objects::Context).string().null())
|
2024-03-21 20:36:46 +01:00
|
|
|
.col(ColumnDef::new(Objects::To).json().null())
|
|
|
|
.col(ColumnDef::new(Objects::Bto).json().null())
|
|
|
|
.col(ColumnDef::new(Objects::Cc).json().null())
|
|
|
|
.col(ColumnDef::new(Objects::Bcc).json().null())
|
2024-03-21 01:09:33 +01:00
|
|
|
.col(ColumnDef::new(Objects::Published).string().not_null())
|
2024-03-16 05:45:58 +01:00
|
|
|
.to_owned()
|
|
|
|
).await?;
|
|
|
|
|
2024-03-16 03:29:06 +01:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
2024-03-16 05:45:58 +01:00
|
|
|
manager
|
|
|
|
.drop_table(Table::drop().table(Users::Table).to_owned())
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
manager
|
|
|
|
.drop_table(Table::drop().table(Activities::Table).to_owned())
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
manager
|
|
|
|
.drop_table(Table::drop().table(Objects::Table).to_owned())
|
2024-03-16 03:29:06 +01:00
|
|
|
.await?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(DeriveIden)]
|
|
|
|
enum Users {
|
|
|
|
Table,
|
|
|
|
Id,
|
2024-03-21 01:09:33 +01:00
|
|
|
Domain,
|
2024-03-16 05:45:58 +01:00
|
|
|
ActorType,
|
|
|
|
Name,
|
2024-03-21 01:09:33 +01:00
|
|
|
Summary,
|
|
|
|
Image,
|
|
|
|
Icon,
|
|
|
|
PreferredUsername,
|
|
|
|
Inbox,
|
|
|
|
SharedInbox,
|
|
|
|
Outbox,
|
|
|
|
Following,
|
2024-03-23 16:44:27 +01:00
|
|
|
FollowingCount,
|
2024-03-21 01:09:33 +01:00
|
|
|
Followers,
|
2024-03-23 16:44:27 +01:00
|
|
|
FollowersCount,
|
2024-03-21 02:11:31 +01:00
|
|
|
PublicKey,
|
|
|
|
PrivateKey,
|
2024-03-21 01:09:33 +01:00
|
|
|
Created,
|
|
|
|
Updated,
|
2024-03-16 05:45:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(DeriveIden)]
|
|
|
|
enum Activities {
|
|
|
|
Table,
|
|
|
|
Id,
|
|
|
|
ActivityType,
|
|
|
|
Actor,
|
|
|
|
Object,
|
|
|
|
Target,
|
2024-03-21 01:09:33 +01:00
|
|
|
Cc,
|
|
|
|
Bcc,
|
|
|
|
To,
|
|
|
|
Bto,
|
|
|
|
Published,
|
2024-03-16 05:45:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(DeriveIden)]
|
|
|
|
enum Objects {
|
|
|
|
Table,
|
|
|
|
Id,
|
|
|
|
ObjectType,
|
2024-03-21 01:09:33 +01:00
|
|
|
AttributedTo,
|
2024-03-16 03:29:06 +01:00
|
|
|
Name,
|
2024-03-16 05:45:58 +01:00
|
|
|
Summary,
|
|
|
|
Content,
|
2024-03-22 05:34:08 +01:00
|
|
|
Likes,
|
|
|
|
Shares,
|
|
|
|
Comments,
|
2024-03-21 19:51:00 +01:00
|
|
|
Context,
|
2024-03-21 20:36:46 +01:00
|
|
|
Cc,
|
|
|
|
Bcc,
|
|
|
|
To,
|
|
|
|
Bto,
|
2024-03-16 05:45:58 +01:00
|
|
|
Published,
|
2024-03-16 03:29:06 +01:00
|
|
|
}
|