Initial version of pools

This commit is contained in:
Bad Manners 2025-04-09 22:31:32 -03:00
parent fe7edb93ad
commit 2b6b1f30f4
21 changed files with 577 additions and 36 deletions

View file

@ -19,6 +19,18 @@ impl MigrationTrait for Migration {
)
.await?;
manager
.create_table(
Table::create()
.table(SameyConfig::Table)
.if_not_exists()
.col(pk_auto(SameyConfig::Id))
.col(string_uniq(SameyConfig::Key))
.col(json(SameyConfig::Data))
.to_owned(),
)
.await?;
manager
.create_table(
Table::create()
@ -51,6 +63,15 @@ impl MigrationTrait for Migration {
.if_not_exists()
.col(pk_auto(SameyPool::Id))
.col(string_len_uniq(SameyPool::Name, 100))
.col(integer(SameyPool::UploaderId))
.col(boolean(SameyPool::IsPublic).default(false))
.foreign_key(
ForeignKeyCreateStatement::new()
.name("fk-samey_pool-samey_user-uploader_id")
.from(SameyPool::Table, SameyPool::UploaderId)
.to(SameyUser::Table, SameyUser::Id)
.on_delete(ForeignKeyAction::Cascade),
)
.to_owned(),
)
.await?;
@ -220,6 +241,10 @@ impl MigrationTrait for Migration {
.drop_table(Table::drop().table(SameyUser::Table).to_owned())
.await?;
manager
.drop_table(Table::drop().table(SameyConfig::Table).to_owned())
.await?;
manager
.drop_table(Table::drop().table(SameySession::Table).to_owned())
.await?;
@ -238,6 +263,15 @@ enum SameySession {
ExpiryDate,
}
#[derive(DeriveIden)]
enum SameyConfig {
#[sea_orm(iden = "samey_config")]
Table,
Id,
Key,
Data,
}
#[derive(DeriveIden)]
enum SameyUser {
#[sea_orm(iden = "samey_user")]
@ -314,6 +348,8 @@ enum SameyPool {
Table,
Id,
Name,
UploaderId,
IsPublic,
}
#[derive(DeriveIden)]