update
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,2 +1,3 @@
|
||||
target
|
||||
.env
|
||||
.env
|
||||
.trae
|
||||
10
.idea/.gitignore
generated
vendored
Normal file
10
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# 已忽略包含查询文件的默认文件夹
|
||||
/queries/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
||||
# 基于编辑器的 HTTP 客户端请求
|
||||
/httpRequests/
|
||||
11
.idea/astarcup-backend.iml
generated
Normal file
11
.idea/astarcup-backend.iml
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="EMPTY_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/astarcup/migration/src" isTestSource="false" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/astarcup/migration/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
13
.idea/dataSources.xml
generated
Normal file
13
.idea/dataSources.xml
generated
Normal file
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
|
||||
<data-source source="LOCAL" name="postgres@192.168.31.247" uuid="dd0cad51-fe47-4844-9996-5044bc017f43">
|
||||
<driver-ref>postgresql</driver-ref>
|
||||
<synchronize>true</synchronize>
|
||||
<remarks>本地</remarks>
|
||||
<jdbc-driver>org.postgresql.Driver</jdbc-driver>
|
||||
<jdbc-url>jdbc:postgresql://192.168.31.247:5432/postgres</jdbc-url>
|
||||
<working-dir>$ProjectFileDir$</working-dir>
|
||||
</data-source>
|
||||
</component>
|
||||
</project>
|
||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/astarcup-backend.iml" filepath="$PROJECT_DIR$/.idea/astarcup-backend.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,4 +1,5 @@
|
||||
use sea_orm_migration::{prelude::*, schema::*};
|
||||
use sea_query::extension::postgres::Type;
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
@@ -6,6 +7,21 @@ 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("userstate"))
|
||||
.values([Alias::new("active"),Alias::new("approved"),Alias::new("banned"),Alias::new("ignored")])
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
manager
|
||||
.create_type(
|
||||
Type::create()
|
||||
.as_enum(Alias::new("usergroup"))
|
||||
.values([Alias::new("player"),Alias::new("admin"),Alias::new("mapooler"),Alias::new("tester")])
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
@@ -18,7 +34,12 @@ impl MigrationTrait for Migration {
|
||||
.auto_increment()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(User::OsuId).string().not_null().unique_key())
|
||||
.col(
|
||||
ColumnDef::new(User::OsuId)
|
||||
.integer()
|
||||
.not_null()
|
||||
.unique_key(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(User::Username)
|
||||
.string()
|
||||
@@ -33,19 +54,13 @@ impl MigrationTrait for Migration {
|
||||
.col(ColumnDef::new(User::CountryRank).integer().null())
|
||||
.col(
|
||||
ColumnDef::new(User::UserState)
|
||||
.enumeration(
|
||||
"userstate",
|
||||
vec!["active", "approved", "banned", "ignored"],
|
||||
)
|
||||
.custom(Alias::new("userstate"))
|
||||
.not_null()
|
||||
.default("active"),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(User::UserGroup)
|
||||
.enumeration(
|
||||
"usergroup",
|
||||
vec!["player", "admin", "mappooler", "tester"],
|
||||
)
|
||||
.custom(Alias::new("usergroup"))
|
||||
.not_null()
|
||||
.default("player"),
|
||||
)
|
||||
@@ -65,7 +80,6 @@ impl MigrationTrait for Migration {
|
||||
.not_null()
|
||||
.default(Expr::current_timestamp()),
|
||||
)
|
||||
.col(ColumnDef::new(User::CreatedAt).timestamp().null())
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
@@ -74,6 +88,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_table(Table::drop().table(User::Table).to_owned())
|
||||
.await
|
||||
@@ -90,11 +106,14 @@ enum User {
|
||||
AvatarUrl,
|
||||
Pp,
|
||||
GlobalRank,
|
||||
CountryCode,
|
||||
CountryRank,
|
||||
UserState,
|
||||
UserGroup,
|
||||
Season,
|
||||
GuServerUserId,
|
||||
GuServerUsername,
|
||||
GuServerBindAt,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use sea_orm_migration::{prelude::*, schema::*};
|
||||
use crate::extension::postgres::Type;
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
@@ -6,6 +7,22 @@ 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()
|
||||
@@ -42,38 +59,71 @@ impl MigrationTrait for Migration {
|
||||
.col(ColumnDef::new(MapSelections::Cs).decimal().null())
|
||||
.col(ColumnDef::new(MapSelections::Od).decimal().null())
|
||||
.col(ColumnDef::new(MapSelections::Hp).decimal().null())
|
||||
.col(ColumnDef::new(MapSelections::SelectedMods).json().null())
|
||||
.col(
|
||||
ColumnDef::new(MapSelections::Mode)
|
||||
.custom(Alias::new("mode"))
|
||||
.not_null()
|
||||
.default("std"),
|
||||
)
|
||||
.col(ColumnDef::new(MapSelections::Mods).json().null())
|
||||
.col(
|
||||
ColumnDef::new(MapSelections::SelectedModName)
|
||||
.string()
|
||||
.null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(MapSelections::SelectedModPosition)
|
||||
.integer()
|
||||
.null(),
|
||||
)
|
||||
.col(ColumnDef::new(MapSelections::Comment).text().null())
|
||||
.col(ColumnDef::new(MapSelections::Comment).string().null())
|
||||
.col(ColumnDef::new(MapSelections::SelectedBy).integer().null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.from(MapSelections::Table, MapSelections::SelectedBy)
|
||||
.to(Users::Table, Users::Id),
|
||||
.to(User::Table, User::Id),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(MapSelections::SelectedAt)
|
||||
.timestamp()
|
||||
.not_null(),
|
||||
)
|
||||
.col(ColumnDef::new(MapSelections::Season).string().not_null())
|
||||
.col(ColumnDef::new(MapSelections::Category).string().not_null())
|
||||
.col(ColumnDef::new(MapSelections::CoverUrl).text().null())
|
||||
.col(
|
||||
ColumnDef::new(MapSelections::Season)
|
||||
.integer()
|
||||
.not_null()
|
||||
.default(1),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(MapSelections::Category)
|
||||
.custom(Alias::new("category"))
|
||||
.not_null()
|
||||
.default("qua"),
|
||||
)
|
||||
.col(ColumnDef::new(MapSelections::CoverUrl).string().null())
|
||||
.col(
|
||||
ColumnDef::new(MapSelections::IsApproved)
|
||||
.boolean()
|
||||
.null()
|
||||
.default(Expr::bool(false)),
|
||||
.default(false),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(MapSelections::IsNeedTest)
|
||||
.boolean()
|
||||
.null()
|
||||
.default(Expr::bool(false)),
|
||||
.default(false),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(MapSelections::IsOrigin)
|
||||
.boolean()
|
||||
.null()
|
||||
.default(false),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(MapSelections::IsCustome)
|
||||
.boolean()
|
||||
.null()
|
||||
.default(false),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(MapSelections::CreatedAt)
|
||||
@@ -95,6 +145,8 @@ impl MigrationTrait for Migration {
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager.drop_type(Type::drop().name(Alias::new("mode")).to_owned()).await?;
|
||||
manager.drop_type(Type::drop().name(Alias::new("category")).to_owned()).await?;
|
||||
manager
|
||||
.drop_table(Table::drop().table(MapSelections::Table).to_owned())
|
||||
.await
|
||||
@@ -106,7 +158,7 @@ enum MapSelections {
|
||||
Table,
|
||||
Id,
|
||||
BeatmapId,
|
||||
BeatmapsetId,
|
||||
BeatmapSetId,
|
||||
Title,
|
||||
TitleUnicode,
|
||||
Artist,
|
||||
@@ -121,17 +173,26 @@ enum MapSelections {
|
||||
Cs,
|
||||
Od,
|
||||
Hp,
|
||||
SelectedMods,
|
||||
ModPosition,
|
||||
Mode,
|
||||
Mods,
|
||||
SelectedModName,
|
||||
SelectedModPosition,
|
||||
Comment,
|
||||
SelectedBy,
|
||||
SelectedAt,
|
||||
Season,
|
||||
Category,
|
||||
Url,
|
||||
CoverUrl,
|
||||
Approved,
|
||||
Padding,
|
||||
IsApproved,
|
||||
IsNeedTest,
|
||||
IsOrigin,
|
||||
IsCustome,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
}
|
||||
|
||||
#[derive(DeriveIden)]
|
||||
enum User {
|
||||
Table,
|
||||
Id,
|
||||
}
|
||||
|
||||
@@ -6,6 +6,10 @@ 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()
|
||||
@@ -19,10 +23,8 @@ impl MigrationTrait for Migration {
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(MatchRooms::RoundNumber).integer().not_null())
|
||||
.col(ColumnDef::new(MatchRooms::MatchDate).date().not_null())
|
||||
.col(ColumnDef::new(MatchRooms::MatchTime).time().not_null())
|
||||
.col(ColumnDef::new(MatchRooms::MatchTime).timestamp().not_null())
|
||||
.col(ColumnDef::new(MatchRooms::MatchNumber).integer().not_null())
|
||||
.col(ColumnDef::new(MatchRooms::MaxParticipants).integer().null())
|
||||
.col(
|
||||
ColumnDef::new(MatchRooms::Status)
|
||||
.enumeration("status", vec!["available", "scheduled", "completed"])
|
||||
@@ -51,6 +53,13 @@ impl MigrationTrait for Migration {
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -61,10 +70,8 @@ enum MatchRooms {
|
||||
Id,
|
||||
RoomName,
|
||||
RoundNumber,
|
||||
MatchDate,
|
||||
MatchTime,
|
||||
MatchNumber,
|
||||
MaxParticipants,
|
||||
Status,
|
||||
CreatedBy,
|
||||
CreatedAt,
|
||||
|
||||
@@ -6,6 +6,10 @@ 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()
|
||||
@@ -20,24 +24,24 @@ impl MigrationTrait for Migration {
|
||||
)
|
||||
.col(ColumnDef::new(MatchSchedules::RoomId).integer().not_null())
|
||||
.col(
|
||||
ColumnDef::new(MatchSchedules::Player1OsuId)
|
||||
.string()
|
||||
ColumnDef::new(MatchSchedules::PlayerRedOsuId)
|
||||
.integer()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(MatchSchedules::Player1Username)
|
||||
.string()
|
||||
.not_null(),
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.from(MatchSchedules::Table, MatchSchedules::PlayerRedOsuId)
|
||||
.to(User::Table, User::OsuId),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(MatchSchedules::Player2OsuId)
|
||||
.string()
|
||||
ColumnDef::new(MatchSchedules::PlayerBlueOsuId)
|
||||
.integer()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(MatchSchedules::Player2Username)
|
||||
.string()
|
||||
.not_null(),
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.from(MatchSchedules::Table, MatchSchedules::PlayerBlueOsuId)
|
||||
.to(User::Table, User::OsuId),
|
||||
)
|
||||
.col(ColumnDef::new(MatchSchedules::RedScore).integer().null())
|
||||
.col(ColumnDef::new(MatchSchedules::BlueScore).integer().null())
|
||||
@@ -78,6 +82,13 @@ 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(),
|
||||
)
|
||||
.await?;
|
||||
manager
|
||||
.drop_table(Table::drop().table(MatchSchedules::Table).to_owned())
|
||||
.await
|
||||
@@ -89,10 +100,8 @@ enum MatchSchedules {
|
||||
Table,
|
||||
Id,
|
||||
RoomId,
|
||||
Player1OsuId,
|
||||
Player1Username,
|
||||
Player2OsuId,
|
||||
Player2Username,
|
||||
PlayerRedOsuId,
|
||||
PlayerBlueOsuId,
|
||||
RedScore,
|
||||
BlueScore,
|
||||
Status,
|
||||
@@ -108,3 +117,8 @@ enum MatchRooms {
|
||||
Table,
|
||||
Id,
|
||||
}
|
||||
#[derive(DeriveIden)]
|
||||
enum User {
|
||||
Table,
|
||||
OsuId,
|
||||
}
|
||||
|
||||
@@ -6,6 +6,14 @@ 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()
|
||||
@@ -19,22 +27,24 @@ impl MigrationTrait for Migration {
|
||||
.primary_key(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(PlayerMatchups::Player1OsuId)
|
||||
ColumnDef::new(PlayerMatchups::Season)
|
||||
.integer()
|
||||
.not_null()
|
||||
.default(1),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(PlayerMatchups::Category)
|
||||
.enumeration("category", vec!["qua", "ro16", "qf", "sf", "f", "gf"])
|
||||
.not_null()
|
||||
.default("qua"),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(PlayerMatchups::PlayerRedOsuId)
|
||||
.string()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(PlayerMatchups::Player1Username)
|
||||
.string()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(PlayerMatchups::Player2OsuId)
|
||||
.string()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(PlayerMatchups::Player2Username)
|
||||
ColumnDef::new(PlayerMatchups::PlayerBlueOsuId)
|
||||
.string()
|
||||
.not_null(),
|
||||
)
|
||||
@@ -43,11 +53,6 @@ impl MigrationTrait for Migration {
|
||||
.enumeration("status", vec!["available", "scheduled", "completed"])
|
||||
.null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(PlayerMatchups::CreatedBy)
|
||||
.string()
|
||||
.not_null(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(PlayerMatchups::CreatedAt)
|
||||
.timestamp()
|
||||
@@ -68,6 +73,20 @@ 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(),
|
||||
)
|
||||
.await?;
|
||||
manager
|
||||
.drop_type(
|
||||
sea_orm_migration::prelude::Enum::drop()
|
||||
.enum_name("status")
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
manager
|
||||
.drop_table(Table::drop().table(PlayerMatchups::Table).to_owned())
|
||||
.await
|
||||
@@ -78,12 +97,11 @@ impl MigrationTrait for Migration {
|
||||
enum PlayerMatchups {
|
||||
Table,
|
||||
Id,
|
||||
Player1OsuId,
|
||||
Player1Username,
|
||||
Player2OsuId,
|
||||
Player2Username,
|
||||
Season,
|
||||
Category,
|
||||
PlayerRedOsuId,
|
||||
PlayerBlueOsuId,
|
||||
Status,
|
||||
CreatedBy,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
}
|
||||
|
||||
@@ -6,6 +6,14 @@ pub struct Migration;
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.create_type()
|
||||
.create_enum("type", vec!["match_invitation", "match_response", "system"])
|
||||
.await?;
|
||||
manager
|
||||
.create_type()
|
||||
.create_enum("status", vec!["available", "scheduled", "completed"])
|
||||
.await?;
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
@@ -58,6 +66,20 @@ 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(),
|
||||
)
|
||||
.await?;
|
||||
manager
|
||||
.drop_type(
|
||||
sea_orm_migration::prelude::Enum::drop()
|
||||
.enum_name("status")
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
manager
|
||||
.drop_table(Table::drop().table(Messages::Table).to_owned())
|
||||
.await
|
||||
|
||||
@@ -24,7 +24,11 @@ impl MigrationTrait for Migration {
|
||||
.not_null(),
|
||||
)
|
||||
.col(ColumnDef::new(MapComments::OsuId).string().not_null())
|
||||
.col(ColumnDef::new(MapComments::Username).string().not_null())
|
||||
.foreign_key(
|
||||
ForeignKey::create()
|
||||
.from(MapComments::Table, MapComments::OsuId)
|
||||
.to(User::Table, User::OsuId),
|
||||
)
|
||||
.col(ColumnDef::new(MapComments::Comment).text().null())
|
||||
.col(
|
||||
ColumnDef::new(MapComments::CreatedAt)
|
||||
@@ -74,3 +78,8 @@ enum MapSelections {
|
||||
Table,
|
||||
Id,
|
||||
}
|
||||
#[derive(DeriveIden)]
|
||||
enum User {
|
||||
Table,
|
||||
OsuId,
|
||||
}
|
||||
|
||||
@@ -6,6 +6,20 @@ pub struct Migration;
|
||||
#[async_trait::async_trait]
|
||||
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",
|
||||
],
|
||||
)
|
||||
.await?;
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
@@ -19,26 +33,24 @@ impl MigrationTrait for Migration {
|
||||
.primary_key(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(TournamentSettings::TournamentName)
|
||||
.string()
|
||||
ColumnDef::new(TournamentSettings::Key)
|
||||
.enumeration(
|
||||
"tournament_setting_key",
|
||||
vec![
|
||||
"TournamentName",
|
||||
"MaxPpForRegistration",
|
||||
"MinPpForRegistration",
|
||||
"CurrentSeason",
|
||||
"CurrentSeasonStage",
|
||||
"MappoolVisible",
|
||||
],
|
||||
)
|
||||
.not_null(),
|
||||
)
|
||||
.col(ColumnDef::new(TournamentSettings::MaxPpForRegistration).float().null())
|
||||
.col(ColumnDef::new(TournamentSettings::MinPpForRegistration).float().null())
|
||||
.col(ColumnDef::new(TournamentSettings::CurrentSeason).string().null())
|
||||
.col(ColumnDef::new(TournamentSettings::CurrentSeasonStage).string().null())
|
||||
.col(ColumnDef::new(TournamentSettings::MappoolVisible).integer().null())
|
||||
.col(
|
||||
ColumnDef::new(TournamentSettings::CreatedAt)
|
||||
.timestamp()
|
||||
.not_null()
|
||||
.default(Expr::current_timestamp()),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(TournamentSettings::UpdatedAt)
|
||||
.timestamp()
|
||||
.not_null()
|
||||
.default(Expr::current_timestamp()),
|
||||
ColumnDef::new(TournamentSettings::Value)
|
||||
.string()
|
||||
.not_null(),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
@@ -48,6 +60,13 @@ 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(),
|
||||
)
|
||||
.await?;
|
||||
manager
|
||||
.drop_table(Table::drop().table(TournamentSettings::Table).to_owned())
|
||||
.await
|
||||
@@ -58,12 +77,6 @@ impl MigrationTrait for Migration {
|
||||
enum TournamentSettings {
|
||||
Table,
|
||||
Id,
|
||||
TournamentName,
|
||||
MaxPpForRegistration,
|
||||
MinPpForRegistration,
|
||||
CurrentSeason,
|
||||
CurrentSeasonStage,
|
||||
MappoolVisible,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
Key,
|
||||
Value,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user