This commit is contained in:
2026-02-23 17:50:02 +08:00
parent 8cbdebf6ed
commit 6e8c47180c
8 changed files with 83 additions and 95 deletions

View File

@@ -9,7 +9,7 @@ impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager.create_type(
Type::create()
.as_enum(Alias::new("userstate"))
.as_enum(Alias::new("userState"))
.values([Alias::new("active"),Alias::new("approved"),Alias::new("banned"),Alias::new("ignored")])
.to_owned(),
)
@@ -17,11 +17,35 @@ impl MigrationTrait for Migration {
manager
.create_type(
Type::create()
.as_enum(Alias::new("usergroup"))
.as_enum(Alias::new("userGroup"))
.values([Alias::new("player"),Alias::new("admin"),Alias::new("mapooler"),Alias::new("tester")])
.to_owned(),
)
.await?;
manager
.create_type(
Type::create()
.as_enum(Alias::new("matchStatus"))
.values([Alias::new("available"), Alias::new("scheduled"), Alias::new("completed")])
.to_owned(),
)
.await?;
manager
.create_type(
Type::create()
.as_enum(Alias::new("category"))
.values([Alias::new("qua"), Alias::new("ro16"), Alias::new("qf"),Alias::new("sf"),Alias::new("f"),Alias::new("gf")])
.to_owned(),
)
.await?;
manager
.create_type(
Type::create()
.as_enum(Alias::new("mode"))
.values([Alias::new("std"),Alias::new("taiko"),Alias::new("ctb"),Alias::new("mania")])
.to_owned(),
)
.await?;
manager
.create_table(
Table::create()
@@ -54,13 +78,13 @@ impl MigrationTrait for Migration {
.col(ColumnDef::new(User::CountryRank).integer().null())
.col(
ColumnDef::new(User::UserState)
.custom(Alias::new("userstate"))
.custom(Alias::new("userState"))
.not_null()
.default("active"),
)
.col(
ColumnDef::new(User::UserGroup)
.custom(Alias::new("usergroup"))
.custom(Alias::new("userGroup"))
.not_null()
.default("player"),
)
@@ -88,8 +112,8 @@ impl MigrationTrait for Migration {
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager.drop_type(Type::drop().name(Alias::new("userstate")).to_owned()).await?;
manager.drop_type(Type::drop().name(Alias::new("usergroup")).to_owned()).await?;
manager.drop_type(Type::drop().name(Alias::new("userState")).to_owned()).await?;
manager.drop_type(Type::drop().name(Alias::new("userGroup")).to_owned()).await?;
manager
.drop_table(Table::drop().table(User::Table).to_owned())
.await

View File

@@ -7,22 +7,6 @@ pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_type(
Type::create()
.as_enum(Alias::new("mode"))
.values([Alias::new("std"),Alias::new("taiko"),Alias::new("ctb"),Alias::new("mania")])
.to_owned(),
)
.await?;
manager
.create_type(
Type::create()
.as_enum(Alias::new("category"))
.values([Alias::new("qua"),Alias::new("ro16"),Alias::new("qf"),Alias::new("sf"),Alias::new("f"),Alias::new("gf")])
.to_owned(),
)
.await?;
manager
.create_table(
Table::create()

View File

@@ -1,4 +1,5 @@
use sea_orm_migration::{prelude::*, schema::*};
use crate::extension::postgres::Type;
#[derive(DeriveMigrationName)]
pub struct Migration;
@@ -6,10 +7,6 @@ pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_type()
.create_enum("status", vec!["available", "scheduled", "completed"])
.await?;
manager
.create_table(
Table::create()
@@ -27,7 +24,8 @@ impl MigrationTrait for Migration {
.col(ColumnDef::new(MatchRooms::MatchNumber).integer().not_null())
.col(
ColumnDef::new(MatchRooms::Status)
.enumeration("status", vec!["available", "scheduled", "completed"])
.custom(Alias::new("matchStatus"))
.default("available")
.null(),
)
.col(ColumnDef::new(MatchRooms::CreatedBy).string().not_null())
@@ -51,15 +49,9 @@ impl MigrationTrait for Migration {
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager.drop_type(Type::drop().name(Alias::new("matchStatus")).to_owned()).await?;
manager
.drop_table(Table::drop().table(MatchRooms::Table).to_owned())
.await?;
manager
.drop_type(
sea_orm_migration::prelude::Enum::drop()
.enum_name("status")
.to_owned(),
)
.await
}
}

View File

@@ -1,15 +1,11 @@
use sea_orm_migration::{prelude::*, schema::*};
use crate::extension::postgres::Type;
#[derive(DeriveMigrationName)]
pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_type()
.create_enum("status", vec!["available", "scheduled", "completed"])
.await?;
manager
.create_table(
Table::create()
@@ -47,7 +43,8 @@ impl MigrationTrait for Migration {
.col(ColumnDef::new(MatchSchedules::BlueScore).integer().null())
.col(
ColumnDef::new(MatchSchedules::Status)
.enumeration("status", vec!["available", "scheduled", "completed"])
.custom(Alias::new("matchStatus"))
.default("available")
.null(),
)
.col(ColumnDef::new(MatchSchedules::ReplayLink).text().null())
@@ -84,9 +81,7 @@ impl MigrationTrait for Migration {
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_type(
sea_orm_migration::prelude::Enum::drop()
.enum_name("status")
.to_owned(),
Type::drop().name(Alias::new("matchStatus")).to_owned(),
)
.await?;
manager

View File

@@ -1,4 +1,5 @@
use sea_orm_migration::{prelude::*, schema::*};
use crate::extension::postgres::Type;
#[derive(DeriveMigrationName)]
pub struct Migration;
@@ -6,14 +7,6 @@ pub struct Migration;
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_type()
.create_enum("category", vec!["qua", "ro16", "qf", "sf", "f", "gf"])
.await?;
manager
.create_type()
.create_enum("status", vec!["available", "scheduled", "completed"])
.await?;
manager
.create_table(
Table::create()
@@ -34,9 +27,9 @@ impl MigrationTrait for Migration {
)
.col(
ColumnDef::new(PlayerMatchups::Category)
.enumeration("category", vec!["qua", "ro16", "qf", "sf", "f", "gf"])
.custom(Alias::new("category"))
.default("qua")
.not_null()
.default("qua"),
)
.col(
ColumnDef::new(PlayerMatchups::PlayerRedOsuId)
@@ -50,8 +43,9 @@ impl MigrationTrait for Migration {
)
.col(
ColumnDef::new(PlayerMatchups::Status)
.enumeration("status", vec!["available", "scheduled", "completed"])
.null(),
.custom(Alias::new("matchStatus"))
.default("available")
.not_null(),
)
.col(
ColumnDef::new(PlayerMatchups::CreatedAt)
@@ -75,16 +69,12 @@ impl MigrationTrait for Migration {
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_type(
sea_orm_migration::prelude::Enum::drop()
.enum_name("category")
.to_owned(),
Type::drop().name(Alias::new("category")).if_exists().to_owned(),
)
.await?;
manager
.drop_type(
sea_orm_migration::prelude::Enum::drop()
.enum_name("status")
.to_owned(),
Type::drop().name(Alias::new("matchStatus")).if_exists().to_owned(),
)
.await?;
manager

View File

@@ -1,5 +1,5 @@
use sea_orm_migration::{prelude::*, schema::*};
use crate::extension::postgres::Type;
#[derive(DeriveMigrationName)]
pub struct Migration;
@@ -7,12 +7,20 @@ pub struct Migration;
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_type()
.create_enum("type", vec!["match_invitation", "match_response", "system"])
.create_type(
Type::create()
.as_enum(Alias::new("type"))
.values([Alias::new("match_invitation"), Alias::new("match_response"), Alias::new("system")])
.to_owned(),
)
.await?;
manager
.create_type()
.create_enum("status", vec!["available", "scheduled", "completed"])
.create_type(
Type::create()
.as_enum(Alias::new("status"))
.values([Alias::new("available"),Alias::new("scheduled"),Alias::new("completed")])
.to_owned(),
)
.await?;
manager
.create_table(
@@ -30,19 +38,18 @@ impl MigrationTrait for Migration {
.col(ColumnDef::new(Messages::ReceiverOsuId).string().not_null())
.col(
ColumnDef::new(Messages::Type)
.enumeration(
"type",
vec!["match_invitation", "match_response", "system"],
)
.null(),
.custom(Alias::new("type"))
.default("match_invitation")
.not_null(),
)
.col(ColumnDef::new(Messages::Title).string().not_null())
.col(ColumnDef::new(Messages::Content).text().not_null())
.col(ColumnDef::new(Messages::RelatedMatchupId).integer().null())
.col(
ColumnDef::new(Messages::Status)
.enumeration("status", vec!["available", "scheduled", "completed"])
.null(),
.custom(Alias::new("matchStatus"))
.default("available")
.not_null(),
)
.col(ColumnDef::new(Messages::ResponseAction).string().null())
.col(ColumnDef::new(Messages::ResponseTime).timestamp().null())
@@ -68,16 +75,12 @@ impl MigrationTrait for Migration {
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_type(
sea_orm_migration::prelude::Enum::drop()
.enum_name("type")
.to_owned(),
Type::drop().name(Alias::new("type")).to_owned(),
)
.await?;
manager
.drop_type(
sea_orm_migration::prelude::Enum::drop()
.enum_name("status")
.to_owned(),
Type::drop().name(Alias::new("matchStatus")).to_owned(),
)
.await?;
manager

View File

@@ -67,7 +67,6 @@ enum MapComments {
Id,
MapSelectionId,
OsuId,
Username,
Comment,
CreatedAt,
UpdatedAt,

View File

@@ -1,4 +1,5 @@
use sea_orm_migration::{prelude::*, schema::*};
use crate::extension::postgres::Type;
#[derive(DeriveMigrationName)]
pub struct Migration;
@@ -7,17 +8,19 @@ pub struct Migration;
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_type()
.create_enum(
"tournament_setting_key",
vec![
"TournamentName",
"MaxPpForRegistration",
"MinPpForRegistration",
"CurrentSeason",
"CurrentSeasonStage",
"MappoolVisible",
],
.create_type(
Type::create()
.as_enum(Alias::new("tournament_setting_key"))
.values([
Alias::new("TournamentName"),
Alias::new("MaxPpForRegistration"),
Alias::new("MinPpForRegistration"),
Alias::new("CurrentSeason"),
Alias::new("CurrentCategory"),
Alias::new("MapPoolVisible"),
Alias::new("CanRegister")
])
.to_owned(),
)
.await?;
manager
@@ -42,7 +45,7 @@ impl MigrationTrait for Migration {
"MinPpForRegistration",
"CurrentSeason",
"CurrentSeasonStage",
"MappoolVisible",
"MapPoolVisible",
],
)
.not_null(),
@@ -62,9 +65,7 @@ impl MigrationTrait for Migration {
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_type(
sea_orm_migration::prelude::Enum::drop()
.enum_name("tournament_setting_key")
.to_owned(),
Type::drop().name(Alias::new("tournament_setting_key")).to_owned(),
)
.await?;
manager