initial migrations for derank lists
All checks were successful
/ build-all-services (push) Successful in 10m39s
All checks were successful
/ build-all-services (push) Successful in 10m39s
This commit is contained in:
parent
96478fb5d2
commit
f3ec651657
15 changed files with 370 additions and 8 deletions
|
@ -1,4 +1,4 @@
|
||||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1
|
||||||
|
|
||||||
use sea_orm::entity::prelude::*;
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
|
37
authservice/entity/src/derank_list_entry.rs
Normal file
37
authservice/entity/src/derank_list_entry.rs
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel)]
|
||||||
|
#[sea_orm(table_name = "derank_list_entry")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub entry_id: String,
|
||||||
|
pub derank_list_id: String,
|
||||||
|
pub url_match: String,
|
||||||
|
pub and: Option<String>,
|
||||||
|
pub unless: Option<String>,
|
||||||
|
#[sea_orm(column_type = "Double")]
|
||||||
|
pub multiplier: f64,
|
||||||
|
pub comment: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
pub enum Relation {
|
||||||
|
#[sea_orm(
|
||||||
|
belongs_to = "super::derank_list_meta::Entity",
|
||||||
|
from = "Column::DerankListId",
|
||||||
|
to = "super::derank_list_meta::Column::Id",
|
||||||
|
on_update = "NoAction",
|
||||||
|
on_delete = "Cascade"
|
||||||
|
)]
|
||||||
|
DerankListMeta,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::derank_list_meta::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::DerankListMeta.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
49
authservice/entity/src/derank_list_meta.rs
Normal file
49
authservice/entity/src/derank_list_meta.rs
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
||||||
|
#[sea_orm(table_name = "derank_list_meta")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub id: String,
|
||||||
|
pub name: Option<String>,
|
||||||
|
pub owner: String,
|
||||||
|
pub description: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
pub enum Relation {
|
||||||
|
#[sea_orm(has_many = "super::derank_list_entry::Entity")]
|
||||||
|
DerankListEntry,
|
||||||
|
#[sea_orm(has_many = "super::derank_list_subscription::Entity")]
|
||||||
|
DerankListSubscription,
|
||||||
|
#[sea_orm(
|
||||||
|
belongs_to = "super::user::Entity",
|
||||||
|
from = "Column::Owner",
|
||||||
|
to = "super::user::Column::Id",
|
||||||
|
on_update = "NoAction",
|
||||||
|
on_delete = "SetNull"
|
||||||
|
)]
|
||||||
|
User,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::derank_list_entry::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::DerankListEntry.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::derank_list_subscription::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::DerankListSubscription.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::user::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::User.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
47
authservice/entity/src/derank_list_subscription.rs
Normal file
47
authservice/entity/src/derank_list_subscription.rs
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1
|
||||||
|
|
||||||
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
||||||
|
#[sea_orm(table_name = "derank_list_subscription")]
|
||||||
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
|
pub id: String,
|
||||||
|
pub user_id: String,
|
||||||
|
pub derank_list_id: String,
|
||||||
|
pub active: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
|
pub enum Relation {
|
||||||
|
#[sea_orm(
|
||||||
|
belongs_to = "super::derank_list_meta::Entity",
|
||||||
|
from = "Column::DerankListId",
|
||||||
|
to = "super::derank_list_meta::Column::Id",
|
||||||
|
on_update = "NoAction",
|
||||||
|
on_delete = "Cascade"
|
||||||
|
)]
|
||||||
|
DerankListMeta,
|
||||||
|
#[sea_orm(
|
||||||
|
belongs_to = "super::user::Entity",
|
||||||
|
from = "Column::UserId",
|
||||||
|
to = "super::user::Column::Id",
|
||||||
|
on_update = "NoAction",
|
||||||
|
on_delete = "Cascade"
|
||||||
|
)]
|
||||||
|
User,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::derank_list_meta::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::DerankListMeta.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::user::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::User.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ActiveModelBehavior for ActiveModel {}
|
|
@ -1,4 +1,4 @@
|
||||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1
|
||||||
|
|
||||||
use sea_orm::entity::prelude::*;
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1
|
||||||
|
|
||||||
pub mod prelude;
|
pub mod prelude;
|
||||||
|
|
||||||
pub mod announcement;
|
pub mod announcement;
|
||||||
|
pub mod derank_list_entry;
|
||||||
|
pub mod derank_list_meta;
|
||||||
|
pub mod derank_list_subscription;
|
||||||
pub mod invite_code;
|
pub mod invite_code;
|
||||||
pub mod user;
|
pub mod user;
|
||||||
pub mod user_session;
|
pub mod user_session;
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1
|
||||||
|
|
||||||
pub use super::announcement::Entity as Announcement;
|
pub use super::announcement::Entity as Announcement;
|
||||||
|
pub use super::derank_list_entry::Entity as DerankListEntry;
|
||||||
|
pub use super::derank_list_meta::Entity as DerankListMeta;
|
||||||
|
pub use super::derank_list_subscription::Entity as DerankListSubscription;
|
||||||
pub use super::invite_code::Entity as InviteCode;
|
pub use super::invite_code::Entity as InviteCode;
|
||||||
pub use super::user::Entity as User;
|
pub use super::user::Entity as User;
|
||||||
pub use super::user_session::Entity as UserSession;
|
pub use super::user_session::Entity as UserSession;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1
|
||||||
|
|
||||||
use sea_orm::entity::prelude::*;
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
@ -22,6 +22,10 @@ pub struct Model {
|
||||||
pub enum Relation {
|
pub enum Relation {
|
||||||
#[sea_orm(has_many = "super::announcement::Entity")]
|
#[sea_orm(has_many = "super::announcement::Entity")]
|
||||||
Announcement,
|
Announcement,
|
||||||
|
#[sea_orm(has_many = "super::derank_list_meta::Entity")]
|
||||||
|
DerankListMeta,
|
||||||
|
#[sea_orm(has_many = "super::derank_list_subscription::Entity")]
|
||||||
|
DerankListSubscription,
|
||||||
#[sea_orm(has_many = "super::invite_code::Entity")]
|
#[sea_orm(has_many = "super::invite_code::Entity")]
|
||||||
InviteCode,
|
InviteCode,
|
||||||
#[sea_orm(has_many = "super::user_session::Entity")]
|
#[sea_orm(has_many = "super::user_session::Entity")]
|
||||||
|
@ -36,6 +40,18 @@ impl Related<super::announcement::Entity> for Entity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Related<super::derank_list_meta::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::DerankListMeta.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Related<super::derank_list_subscription::Entity> for Entity {
|
||||||
|
fn to() -> RelationDef {
|
||||||
|
Relation::DerankListSubscription.def()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Related<super::invite_code::Entity> for Entity {
|
impl Related<super::invite_code::Entity> for Entity {
|
||||||
fn to() -> RelationDef {
|
fn to() -> RelationDef {
|
||||||
Relation::InviteCode.def()
|
Relation::InviteCode.def()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1
|
||||||
|
|
||||||
use sea_orm::entity::prelude::*;
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1
|
||||||
|
|
||||||
use sea_orm::entity::prelude::*;
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.0.0
|
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.1
|
||||||
|
|
||||||
use sea_orm::entity::prelude::*;
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,9 @@ mod m20240814_014654_create_user_session;
|
||||||
mod m20240814_015232_create_verification_code;
|
mod m20240814_015232_create_verification_code;
|
||||||
mod m20240829_214347_create_user_settings;
|
mod m20240829_214347_create_user_settings;
|
||||||
mod m20241115_003101_create_announcement;
|
mod m20241115_003101_create_announcement;
|
||||||
|
mod m20250317_192753_create_deranklist_meta;
|
||||||
|
mod m20250317_193359_create_deranklist_entry;
|
||||||
|
mod m20250317_194216_create_deranklist_subscription;
|
||||||
|
|
||||||
pub struct Migrator;
|
pub struct Migrator;
|
||||||
|
|
||||||
|
@ -19,6 +22,9 @@ impl MigratorTrait for Migrator {
|
||||||
Box::new(m20240814_015232_create_verification_code::Migration),
|
Box::new(m20240814_015232_create_verification_code::Migration),
|
||||||
Box::new(m20240829_214347_create_user_settings::Migration),
|
Box::new(m20240829_214347_create_user_settings::Migration),
|
||||||
Box::new(m20241115_003101_create_announcement::Migration),
|
Box::new(m20241115_003101_create_announcement::Migration),
|
||||||
|
Box::new(m20250317_192753_create_deranklist_meta::Migration),
|
||||||
|
Box::new(m20250317_193359_create_deranklist_entry::Migration),
|
||||||
|
Box::new(m20250317_194216_create_deranklist_subscription::Migration),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
use crate::m20240814_013106_create_user::User;
|
||||||
|
use sea_orm_migration::{prelude::*, schema::*};
|
||||||
|
|
||||||
|
#[derive(DeriveMigrationName)]
|
||||||
|
pub struct Migration;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl MigrationTrait for Migration {
|
||||||
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(DerankListMeta::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(DerankListMeta::Id)
|
||||||
|
.string()
|
||||||
|
.not_null()
|
||||||
|
.unique_key()
|
||||||
|
.primary_key(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(DerankListMeta::Name).string())
|
||||||
|
.col(ColumnDef::new(DerankListMeta::Owner).string().not_null())
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(DerankListMeta::Description)
|
||||||
|
.string()
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk-deranklistmeta-owner")
|
||||||
|
.from(DerankListMeta::Table, DerankListMeta::Owner)
|
||||||
|
.to(User::Table, User::Id)
|
||||||
|
.on_delete(ForeignKeyAction::SetNull),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(DerankListMeta::Table).to_owned())
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
pub enum DerankListMeta {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
Name,
|
||||||
|
Owner,
|
||||||
|
Description,
|
||||||
|
}
|
|
@ -0,0 +1,69 @@
|
||||||
|
use crate::m20250317_192753_create_deranklist_meta::DerankListMeta;
|
||||||
|
use sea_orm_migration::{prelude::*, schema::*};
|
||||||
|
|
||||||
|
#[derive(DeriveMigrationName)]
|
||||||
|
pub struct Migration;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl MigrationTrait for Migration {
|
||||||
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(DerankListEntry::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(DerankListEntry::EntryId)
|
||||||
|
.string()
|
||||||
|
.not_null()
|
||||||
|
.unique_key()
|
||||||
|
.primary_key(),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(DerankListEntry::DerankListId)
|
||||||
|
.string()
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(DerankListEntry::UrlMatch)
|
||||||
|
.string()
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(DerankListEntry::And).string())
|
||||||
|
.col(ColumnDef::new(DerankListEntry::Unless).string())
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(DerankListEntry::Multiplier)
|
||||||
|
.double()
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(ColumnDef::new(DerankListEntry::Comment).string())
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk-deranklistentry-deranklist")
|
||||||
|
.from(DerankListEntry::Table, DerankListEntry::DerankListId)
|
||||||
|
.to(DerankListMeta::Table, DerankListMeta::Id)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(DerankListEntry::Table).to_owned())
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum DerankListEntry {
|
||||||
|
Table,
|
||||||
|
EntryId,
|
||||||
|
DerankListId,
|
||||||
|
UrlMatch,
|
||||||
|
And,
|
||||||
|
Unless,
|
||||||
|
Multiplier,
|
||||||
|
Comment,
|
||||||
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
use crate::m20240814_013106_create_user::User;
|
||||||
|
use crate::m20250317_192753_create_deranklist_meta::DerankListMeta;
|
||||||
|
use sea_orm_migration::{prelude::*, schema::*};
|
||||||
|
|
||||||
|
#[derive(DeriveMigrationName)]
|
||||||
|
pub struct Migration;
|
||||||
|
|
||||||
|
#[async_trait::async_trait]
|
||||||
|
impl MigrationTrait for Migration {
|
||||||
|
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
manager
|
||||||
|
.create_table(
|
||||||
|
Table::create()
|
||||||
|
.table(DerankListSubscription::Table)
|
||||||
|
.if_not_exists()
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(DerankListSubscription::Id)
|
||||||
|
.string()
|
||||||
|
.not_null()
|
||||||
|
.unique_key()
|
||||||
|
.primary_key(),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(DerankListSubscription::UserId)
|
||||||
|
.string()
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(DerankListSubscription::DerankListId)
|
||||||
|
.string()
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.col(
|
||||||
|
ColumnDef::new(DerankListSubscription::Active)
|
||||||
|
.boolean()
|
||||||
|
.not_null(),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk-deranklistsubscription-userid")
|
||||||
|
.from(
|
||||||
|
DerankListSubscription::Table,
|
||||||
|
DerankListSubscription::UserId,
|
||||||
|
)
|
||||||
|
.to(User::Table, User::Id)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.foreign_key(
|
||||||
|
ForeignKey::create()
|
||||||
|
.name("fk-deranklistsubscription-deranklistid")
|
||||||
|
.from(
|
||||||
|
DerankListSubscription::Table,
|
||||||
|
DerankListSubscription::DerankListId,
|
||||||
|
)
|
||||||
|
.to(DerankListMeta::Table, DerankListMeta::Id)
|
||||||
|
.on_delete(ForeignKeyAction::Cascade),
|
||||||
|
)
|
||||||
|
.to_owned(),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||||
|
manager
|
||||||
|
.drop_table(Table::drop().table(DerankListSubscription::Table).to_owned())
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(DeriveIden)]
|
||||||
|
enum DerankListSubscription {
|
||||||
|
Table,
|
||||||
|
Id,
|
||||||
|
UserId,
|
||||||
|
DerankListId,
|
||||||
|
Active,
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue