revert: db
This commit is contained in:
2843
migration/Cargo.lock
generated
Normal file
2843
migration/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -20,4 +20,4 @@ features = [
|
||||
# "runtime-tokio-rustls", # `ASYNC_RUNTIME` feature
|
||||
# "sqlx-postgres", # `DATABASE_DRIVER` feature
|
||||
]
|
||||
version = "2.0.0"
|
||||
version = "2.0.0-rc.31"
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
pub use sea_orm_migration::prelude::*;
|
||||
|
||||
mod m20220101_000001_create_table;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigratorTrait for Migrator {
|
||||
fn migrations() -> Vec<Box<dyn MigrationTrait>> {
|
||||
vec![Box::new(m20220101_000001_create_table::Migration)]
|
||||
}
|
||||
}
|
||||
@@ -1,441 +0,0 @@
|
||||
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> {
|
||||
// Replace the sample below with your own migration scripts
|
||||
todo!();
|
||||
// type creation
|
||||
|
||||
/// 用户类型
|
||||
manager
|
||||
.create_type(
|
||||
Type::create()
|
||||
.as_enum(UserState::Table)
|
||||
.values([
|
||||
UserState::Active,
|
||||
UserState::Registered,
|
||||
UserState::Banned,
|
||||
UserState::Deleted,
|
||||
])
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
/// 用户组
|
||||
manager
|
||||
.create_type(
|
||||
Type::create()
|
||||
.as_enum(UserGroupType::Table)
|
||||
.values([
|
||||
UserGroupType::Player,
|
||||
UserGroupType::Admin,
|
||||
UserGroupType::Pooler,
|
||||
UserGroupType::Tester,
|
||||
])
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
/// 比赛阶段
|
||||
manager
|
||||
.create_type(
|
||||
Type::create()
|
||||
.as_enum(SeasonState::Table)
|
||||
.values([
|
||||
SeasonState::Qua,
|
||||
SeasonState::Ro16,
|
||||
SeasonState::Qf,
|
||||
SeasonState::Sf,
|
||||
SeasonState::F,
|
||||
SeasonState::Gf,
|
||||
])
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
/// 比赛状态
|
||||
manager
|
||||
.create_type(
|
||||
type_::create()
|
||||
.as_enum(MatchState::Table)
|
||||
.values([
|
||||
MatchState::Waiting,
|
||||
MatchState::Running,
|
||||
MatchState::Finished,
|
||||
])
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
/// 房间类型
|
||||
manager
|
||||
.create_type(
|
||||
Type::create()
|
||||
.as_enum(RoomType::Table)
|
||||
.values([RoomType::SoloRoom, RoomType::TeamRoom])
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
/// 图池模式类型
|
||||
manager
|
||||
.create_type(
|
||||
Type::create()
|
||||
.as_enum(BeatmapModeType::Table)
|
||||
.values([
|
||||
BeatmapModeType::Osu,
|
||||
BeatmapModeType::Taiko,
|
||||
BeatmapModeType::Catch,
|
||||
BeatmapModeType::Mania,
|
||||
])
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
// table creation
|
||||
|
||||
/// user table
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(User::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(User::Id)
|
||||
.integer()
|
||||
.not_null()
|
||||
.auto_increment()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(User::Osuid)
|
||||
.integer()
|
||||
.not_null()
|
||||
.unique_key(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(User::Username)
|
||||
.string()
|
||||
.not_null()
|
||||
.unique_key(),
|
||||
)
|
||||
.col(ColumnDef::new(User::AvatarUrl).string().null())
|
||||
.col(ColumnDef::new(User::CoverUrl).string().null())
|
||||
.col(
|
||||
ColumnDef::new(User::UserState)
|
||||
.custom(UserState::Table)
|
||||
.not_null()
|
||||
.default(UserState::Active),
|
||||
)
|
||||
.col(ColumnDef::new(User::Pp).float().not_null().default(0.0))
|
||||
.col(ColumnDef::new(User::CountryCode).string())
|
||||
.col(ColumnDef::new(User::GlobalRank).integer().null())
|
||||
.col(ColumnDef::new(User::CountryRank).integer().null())
|
||||
.col(ColumnDef::new(User::Level).integer().not_null().default(1))
|
||||
.col(
|
||||
ColumnDef::new(User::RegisteredSeasonal)
|
||||
.integer()
|
||||
.not_null()
|
||||
.default(1),
|
||||
)
|
||||
// gu服绑定
|
||||
.col(
|
||||
ColumnDef::new(User::GuServerId)
|
||||
.integer()
|
||||
.null()
|
||||
.unique_key(),
|
||||
)
|
||||
.col(ColumnDef::new(User::GuServerUsername).string().null())
|
||||
// 用户组
|
||||
.col(
|
||||
ColumnDef::new(User::UserGroupType)
|
||||
.custom(UserGroupType::Table)
|
||||
.not_null()
|
||||
.default(UserGroupType::Player),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(User::CreatedAt)
|
||||
.timestamp()
|
||||
.not_null()
|
||||
.default(Expr::current_timestamp()),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(User::UpdatedAt)
|
||||
.timestamp()
|
||||
.not_null()
|
||||
.default(Expr::current_timestamp()),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
/// schedule table
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(Schedule::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(Schedule::Id)
|
||||
.integer()
|
||||
.not_null()
|
||||
.auto_increment()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Schedule::Season)
|
||||
.integer()
|
||||
.not_null()
|
||||
.default(1),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Schedule::Category)
|
||||
.custom(Category::Table)
|
||||
.not_null()
|
||||
.default(Category::Qua),
|
||||
)
|
||||
.col(ColumnDef::new(Schedule::RedPlayerId).integer().null())
|
||||
.col(ColumnDef::new(Schedule::BluePlayerId).integer().null())
|
||||
.col(ColumnDef::new(Schedule::RedScore).integer().null())
|
||||
.col(ColumnDef::new(Schedule::BlueScore).integer().null())
|
||||
.col(
|
||||
ColumnDef::new(Schedule::State)
|
||||
.custom(MatchState::Table)
|
||||
.not_null()
|
||||
.default(MatchState::Waiting),
|
||||
)
|
||||
.col(ColumnDef::new(Schedule::CreatedAt).timestamp().null())
|
||||
.col(ColumnDef::new(Schedule::UpdatedAt).timestamp().null())
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
/// room table
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(Room::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(Room::Id)
|
||||
.integer()
|
||||
.not_null()
|
||||
.auto_increment()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(Room::Name).string().not_null())
|
||||
.col(
|
||||
ColumnDef::new(Room::Type)
|
||||
.custom(RoomType::Table)
|
||||
.not_null()
|
||||
.default(RoomType::SoloRoom),
|
||||
)
|
||||
.col(ColumnDef::new(RoomSolo::RoomSoloId).integer().null())
|
||||
.col(ColumnDef::new(RoomTeam::RoomTeamId).integer().null())
|
||||
.col(ColumnDef::new(Room::RedScore).integer().null().default(0))
|
||||
.col(ColumnDef::new(Room::BlueScore).integer().null().default(0))
|
||||
.col(ColumnDef::new(Room::CreatedAt).timestamp().null())
|
||||
.col(ColumnDef::new(Room::UpdatedAt).timestamp().null())
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
/// room for solo
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(RoomSolo::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(RoomSolo::RoomSoloId)
|
||||
.integer()
|
||||
.not_null()
|
||||
.auto_increment()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(RoomSolo::RedPlayerId).integer().not_null())
|
||||
.col(ColumnDef::new(RoomSolo::BluePlayerId).integer().not_null())
|
||||
.col(ColumnDef::new(RoomSolo::CreatedAt).timestamp().null())
|
||||
.col(ColumnDef::new(RoomSolo::UpdatedAt).timestamp().null())
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
/// room for team
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(RoomTeam::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(RoomTeam::RoomTeamId)
|
||||
.integer()
|
||||
.not_null()
|
||||
.auto_increment()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(RoomTeam::RedTeamId).integer().not_null())
|
||||
.col(ColumnDef::new(RoomTeam::BlueTeamId).integer().not_null())
|
||||
.col(ColumnDef::new(RoomTeam::CreatedAt).timestamp().null())
|
||||
.col(ColumnDef::new(RoomTeam::UpdatedAt).timestamp().null()),
|
||||
)
|
||||
.await?;
|
||||
|
||||
/// beatmap table
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(Beatmap::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(Beatmap::Id)
|
||||
.integer()
|
||||
.not_null()
|
||||
.auto_increment()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Beatmap::Sid)
|
||||
.integer()
|
||||
.not_null()
|
||||
.unique_key(),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Beatmap::Bid)
|
||||
.integer()
|
||||
.not_null()
|
||||
.unique_key(),
|
||||
)
|
||||
.col(ColumnDef::new(Beatmap::Title).string().null())
|
||||
.col(ColumnDef::new(Beatmap::TitleUnicode).string().null())
|
||||
.col(ColumnDef::new(Beatmap::Artist).string().null())
|
||||
.col(ColumnDef::new(Beatmap::ArtistUnicode).string().null())
|
||||
.col(ColumnDef::new(Beatmap::Creator).string().null())
|
||||
.col(ColumnDef::new(Beatmap::Version).string().null())
|
||||
.col(ColumnDef::new(Beatmap::CoverUrl).string().null())
|
||||
.col(
|
||||
ColumnDef::new(Beatmap::DifficultyStar)
|
||||
.float()
|
||||
.null()
|
||||
.default(0.0),
|
||||
)
|
||||
.col(ColumnDef::new(Beatmap::Ar).string().null())
|
||||
.col(ColumnDef::new(Beatmap::Od).string().null())
|
||||
.col(ColumnDef::new(Beatmap::Cs).string().null())
|
||||
.col(ColumnDef::new(Beatmap::Hp).string().null())
|
||||
.col(ColumnDef::new(Beatmap::TotalLength).integer().null())
|
||||
.col(ColumnDef::new(Beatmap::MaxCombo).integer().null())
|
||||
.col(ColumnDef::new(Beatmap::Bpm).float().null().default(0.0))
|
||||
.col(
|
||||
ColumnDef::new(Beatmap::Mode)
|
||||
.custom(BeatmapModeType::Table)
|
||||
.not_null()
|
||||
.default(BeatmapModeType::Osu),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Beatmap::Mod)
|
||||
.json()
|
||||
.null()
|
||||
.default(Json::default([])),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Beatmap::SelectMod)
|
||||
.string()
|
||||
.not_null()
|
||||
.default("NM"),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Beatmap::SelectModSlot)
|
||||
.integer()
|
||||
.not_null()
|
||||
.default(1),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Beatmap::Approved)
|
||||
.boolean()
|
||||
.null()
|
||||
.default(false),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Beatmap::NeedTest)
|
||||
.boolean()
|
||||
.null()
|
||||
.default(false),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Beatmap::Deleted)
|
||||
.boolean()
|
||||
.null()
|
||||
.default(false),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Beatmap::IsCustom)
|
||||
.boolean()
|
||||
.null()
|
||||
.default(false),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(Beatmap::IsOriginal)
|
||||
.boolean()
|
||||
.null()
|
||||
.default(false),
|
||||
)
|
||||
.col(ColumnDef::new(Beatmap::Season).integer().null().default(1))
|
||||
.col(
|
||||
ColumnDef::new(Beatmap::Category)
|
||||
.custom(Category::Table)
|
||||
.null()
|
||||
.default(Category::Qua),
|
||||
)
|
||||
.col(ColumnDef::new(Beatmap::CreatedAt).timestamp().null())
|
||||
.col(ColumnDef::new(Beatmap::UpdatedAt).timestamp().null())
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
|
||||
/// beatmap comment table
|
||||
manager
|
||||
.create_table(
|
||||
Table::create()
|
||||
.table(BeatmapComment::Table)
|
||||
.if_not_exists()
|
||||
.col(
|
||||
ColumnDef::new(BeatmapComment::Id)
|
||||
.integer()
|
||||
.not_null()
|
||||
.auto_increment()
|
||||
.primary_key(),
|
||||
)
|
||||
.col(ColumnDef::new(Beatmap::Id).integer().not_null())
|
||||
.col(ColumnDef::new(User::Id).integer().not_null())
|
||||
.col(ColumnDef::new(BeatmapComment::Content).string().not_null())
|
||||
.col(
|
||||
ColumnDef::new(BeatmapComment::CreatedAt)
|
||||
.timestamp()
|
||||
.not_null()
|
||||
.default(Expr::current_timestamp()),
|
||||
)
|
||||
.col(
|
||||
ColumnDef::new(BeatmapComment::UpdatedAt)
|
||||
.timestamp()
|
||||
.not_null()
|
||||
.default(Expr::current_timestamp()),
|
||||
)
|
||||
.to_owned(),
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
// Replace the sample below with your own migration scripts
|
||||
todo!();
|
||||
|
||||
// table deletion
|
||||
manager
|
||||
.drop_table(Table::drop().table(User::Table).to_owned())
|
||||
.await
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user