forked from alemi/upub
fix: it wasn't that easy
This commit is contained in:
parent
9f1e6da4b9
commit
89cd0d0335
5 changed files with 175 additions and 13 deletions
|
@ -32,7 +32,6 @@ impl MigrationTrait for Migration {
|
||||||
.col(ColumnDef::new(Users::PrivateKey).string().null())
|
.col(ColumnDef::new(Users::PrivateKey).string().null())
|
||||||
.col(ColumnDef::new(Users::Created).date_time().not_null())
|
.col(ColumnDef::new(Users::Created).date_time().not_null())
|
||||||
.col(ColumnDef::new(Users::Updated).date_time().not_null())
|
.col(ColumnDef::new(Users::Updated).date_time().not_null())
|
||||||
.index(Index::create().col(Users::Domain))
|
|
||||||
.to_owned()
|
.to_owned()
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -56,9 +55,6 @@ impl MigrationTrait for Migration {
|
||||||
.col(ColumnDef::new(Activities::Cc).json().null())
|
.col(ColumnDef::new(Activities::Cc).json().null())
|
||||||
.col(ColumnDef::new(Activities::Bcc).json().null())
|
.col(ColumnDef::new(Activities::Bcc).json().null())
|
||||||
.col(ColumnDef::new(Activities::Published).date_time().not_null())
|
.col(ColumnDef::new(Activities::Published).date_time().not_null())
|
||||||
.index(Index::create().col(Activities::Published))
|
|
||||||
.index(Index::create().col(Activities::Actor))
|
|
||||||
.index(Index::create().col(Activities::Object))
|
|
||||||
.to_owned()
|
.to_owned()
|
||||||
).await?;
|
).await?;
|
||||||
|
|
||||||
|
@ -86,7 +82,6 @@ impl MigrationTrait for Migration {
|
||||||
.col(ColumnDef::new(Objects::Cc).json().null())
|
.col(ColumnDef::new(Objects::Cc).json().null())
|
||||||
.col(ColumnDef::new(Objects::Bcc).json().null())
|
.col(ColumnDef::new(Objects::Bcc).json().null())
|
||||||
.col(ColumnDef::new(Objects::Published).string().not_null())
|
.col(ColumnDef::new(Objects::Published).string().not_null())
|
||||||
.index(Index::create().col(Objects::AttributedTo))
|
|
||||||
.to_owned()
|
.to_owned()
|
||||||
).await?;
|
).await?;
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,6 @@ impl MigrationTrait for Migration {
|
||||||
)
|
)
|
||||||
.col(ColumnDef::new(Relations::Follower).string().not_null())
|
.col(ColumnDef::new(Relations::Follower).string().not_null())
|
||||||
.col(ColumnDef::new(Relations::Following).string().not_null())
|
.col(ColumnDef::new(Relations::Following).string().not_null())
|
||||||
.index(Index::create().col(Relations::Follower).col(Relations::Following).unique())
|
|
||||||
.index(Index::create().col(Relations::Follower))
|
|
||||||
.index(Index::create().col(Relations::Following))
|
|
||||||
.to_owned()
|
.to_owned()
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
|
@ -19,9 +19,6 @@ impl MigrationTrait for Migration {
|
||||||
)
|
)
|
||||||
.col(ColumnDef::new(Likes::Actor).string().not_null())
|
.col(ColumnDef::new(Likes::Actor).string().not_null())
|
||||||
.col(ColumnDef::new(Likes::Likes).string().not_null())
|
.col(ColumnDef::new(Likes::Likes).string().not_null())
|
||||||
.index(Index::create().col(Likes::Actor).col(Likes::Likes).unique())
|
|
||||||
.index(Index::create().col(Likes::Actor))
|
|
||||||
.index(Index::create().col(Likes::Likes))
|
|
||||||
.to_owned()
|
.to_owned()
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
@ -40,8 +37,6 @@ impl MigrationTrait for Migration {
|
||||||
.col(ColumnDef::new(Shares::Actor).string().not_null())
|
.col(ColumnDef::new(Shares::Actor).string().not_null())
|
||||||
.col(ColumnDef::new(Shares::Shares).string().not_null())
|
.col(ColumnDef::new(Shares::Shares).string().not_null())
|
||||||
.col(ColumnDef::new(Shares::Date).date_time().not_null())
|
.col(ColumnDef::new(Shares::Date).date_time().not_null())
|
||||||
.index(Index::create().col(Shares::Actor))
|
|
||||||
.index(Index::create().col(Shares::Shares))
|
|
||||||
.to_owned()
|
.to_owned()
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
173
src/migrations/m20240322_000003_add_indexes.rs
Normal file
173
src/migrations/m20240322_000003_add_indexes.rs
Normal file
|
@ -0,0 +1,173 @@
|
||||||
|
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> {
|
||||||
|
manager
|
||||||
|
.create_index(
|
||||||
|
Index::create()
|
||||||
|
.name("user-domain-index")
|
||||||
|
.table(Users::Table)
|
||||||
|
.col(Users::Domain)
|
||||||
|
.to_owned()
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_index(
|
||||||
|
Index::create()
|
||||||
|
.name("activities-published-descending-index")
|
||||||
|
.table(Activities::Table)
|
||||||
|
.col((Activities::Published, IndexOrder::Desc))
|
||||||
|
.to_owned()
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_index(
|
||||||
|
Index::create()
|
||||||
|
.name("activities-actor-index")
|
||||||
|
.table(Activities::Table)
|
||||||
|
.col(Activities::Actor)
|
||||||
|
.to_owned()
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_index(
|
||||||
|
Index::create()
|
||||||
|
.name("activities-object-index")
|
||||||
|
.table(Activities::Table)
|
||||||
|
.col(Activities::Object)
|
||||||
|
.to_owned()
|
||||||
|
).await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_index(
|
||||||
|
Index::create()
|
||||||
|
.name("objects-attributed-to-index")
|
||||||
|
.table(Objects::Table)
|
||||||
|
.col(Objects::AttributedTo)
|
||||||
|
.to_owned()
|
||||||
|
).await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_index(
|
||||||
|
Index::create()
|
||||||
|
.name("shares-actor-index")
|
||||||
|
.table(Shares::Table)
|
||||||
|
.col(Shares::Actor)
|
||||||
|
.to_owned()
|
||||||
|
).await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_index(
|
||||||
|
Index::create()
|
||||||
|
.name("shares-shares-index")
|
||||||
|
.table(Shares::Table)
|
||||||
|
.col(Shares::Shares)
|
||||||
|
.to_owned()
|
||||||
|
).await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_index(
|
||||||
|
Index::create()
|
||||||
|
.name("likes-actor-index")
|
||||||
|
.table(Likes::Table)
|
||||||
|
.col(Likes::Actor)
|
||||||
|
.to_owned()
|
||||||
|
).await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_index(
|
||||||
|
Index::create()
|
||||||
|
.name("likes-likes-index")
|
||||||
|
.table(Likes::Table)
|
||||||
|
.col(Likes::Likes)
|
||||||
|
.to_owned()
|
||||||
|
).await?;
|
||||||
|
|
||||||
|
manager
|
||||||
|
.create_index(
|
||||||
|
Index::create()
|
||||||
|
.name("likes-actor-likes-index")
|
||||||
|
.table(Likes::Table)
|
||||||
|
.col(Likes::Actor)
|
||||||
|
.col(Likes::Likes)
|
||||||
|
.to_owned()
|
||||||
|
).await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
manager
|
||||||
|
.drop_index(Index::drop().name("user-domain-index").to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_index(Index::drop().name("activities-published-descending-index").to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_index(Index::drop().name("activities-actor-index").to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_index(Index::drop().name("activities-object-index").to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_index(Index::drop().name("objects-attributed-to-index").to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_index(Index::drop().name("shares-actor-index").to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_index(Index::drop().name("shares-shares-index").to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_index(Index::drop().name("likes-actor-index").to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_index(Index::drop().name("likes-likes-index").to_owned())
|
||||||
|
.await?;
|
||||||
|
manager
|
||||||
|
.drop_index(Index::drop().name("likes-actor-likes-index").to_owned())
|
||||||
|
.await?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum Likes {
|
||||||
|
Table,
|
||||||
|
Actor,
|
||||||
|
Likes,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum Shares {
|
||||||
|
Table,
|
||||||
|
Actor,
|
||||||
|
Shares,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum Users {
|
||||||
|
Table,
|
||||||
|
Domain,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum Activities {
|
||||||
|
Table,
|
||||||
|
Actor,
|
||||||
|
Object,
|
||||||
|
Published,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum Objects {
|
||||||
|
Table,
|
||||||
|
AttributedTo,
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ use sea_orm_migration::prelude::*;
|
||||||
mod m20240316_000001_create_table;
|
mod m20240316_000001_create_table;
|
||||||
mod m20240322_000001_create_relations;
|
mod m20240322_000001_create_relations;
|
||||||
mod m20240322_000002_add_likes_shares;
|
mod m20240322_000002_add_likes_shares;
|
||||||
|
mod m20240322_000003_add_indexes;
|
||||||
|
|
||||||
pub struct Migrator;
|
pub struct Migrator;
|
||||||
|
|
||||||
|
@ -13,6 +14,7 @@ impl MigratorTrait for Migrator {
|
||||||
Box::new(m20240316_000001_create_table::Migration),
|
Box::new(m20240316_000001_create_table::Migration),
|
||||||
Box::new(m20240322_000001_create_relations::Migration),
|
Box::new(m20240322_000001_create_relations::Migration),
|
||||||
Box::new(m20240322_000002_add_likes_shares::Migration),
|
Box::new(m20240322_000002_add_likes_shares::Migration),
|
||||||
|
Box::new(m20240322_000003_add_indexes::Migration),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue