-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
109 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
migration/src/m20230727_063415_create_mod_beat_saber_versions.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
use sea_orm_migration::prelude::*; | ||
|
||
#[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(ModBeatSaberVersions::Table) | ||
.if_not_exists() | ||
.col( | ||
ColumnDef::new(ModBeatSaberVersions::ModId) | ||
.uuid() | ||
.not_null(), | ||
) | ||
.col( | ||
ColumnDef::new(ModBeatSaberVersions::BeatSaberVersionId) | ||
.uuid() | ||
.not_null(), | ||
) | ||
.foreign_key( | ||
ForeignKey::create() | ||
.name("fk_mod_beat_saber_versions_mods_mod_id") | ||
.from( | ||
ModBeatSaberVersions::Table, | ||
ModBeatSaberVersions::ModId, | ||
) | ||
.to(Mods::Table, Mods::Id) | ||
.on_delete(ForeignKeyAction::Cascade) | ||
.on_update(ForeignKeyAction::Cascade), | ||
) | ||
.foreign_key( | ||
ForeignKey::create() | ||
.name("fk_mod_beat_saber_versions_beat_saber_versions_beat_saber_version_id") | ||
.from( | ||
ModBeatSaberVersions::Table, | ||
ModBeatSaberVersions::BeatSaberVersionId, | ||
) | ||
.to(BeatSaberVersions::Table, BeatSaberVersions::Id) | ||
.on_delete(ForeignKeyAction::Cascade) | ||
.on_update(ForeignKeyAction::Cascade), | ||
) | ||
.to_owned(), | ||
) | ||
.await | ||
} | ||
|
||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { | ||
manager | ||
.drop_table(Table::drop().table(ModBeatSaberVersions::Table).to_owned()) | ||
.await | ||
} | ||
} | ||
|
||
/// Learn more at https://docs.rs/sea-query#iden | ||
#[derive(Iden)] | ||
enum ModBeatSaberVersions { | ||
Table, | ||
ModId, | ||
BeatSaberVersionId, | ||
} | ||
|
||
#[derive(Iden)] | ||
enum Mods { | ||
Table, | ||
Id, | ||
Slug, | ||
Check warning on line 70 in migration/src/m20230727_063415_create_mod_beat_saber_versions.rs GitHub Actions / Build and Publish
|
||
Name, | ||
Description, | ||
Icon, | ||
Cover, | ||
Author, | ||
Category, | ||
Stats, | ||
CreatedAt, | ||
UpdatedAt, | ||
} | ||
|
||
#[derive(Iden)] | ||
enum BeatSaberVersions { | ||
Table, | ||
Id, | ||
Ver, | ||
Check warning on line 86 in migration/src/m20230727_063415_create_mod_beat_saber_versions.rs GitHub Actions / Build and Publish
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters