Skip to content

Commit

Permalink
add release disambiguation migration
Browse files Browse the repository at this point in the history
  • Loading branch information
lucat1 committed Dec 9, 2023
1 parent 396ce31 commit bf2e90c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ mod m20230712_000001_imports;
mod m20231118_000001_update_artist;
mod m20231126_000001_artist_picture;
mod m20231126_000002_genres;
mod m20231209_000001_release_disambiguation;

pub struct Migrator;

Expand All @@ -31,6 +32,7 @@ impl MigratorTrait for Migrator {
Box::new(m20231118_000001_update_artist::Migration),
Box::new(m20231126_000001_artist_picture::Migration),
Box::new(m20231126_000002_genres::Migration),
Box::new(m20231209_000001_release_disambiguation::Migration),
]
}
}
26 changes: 26 additions & 0 deletions migration/src/m20231209_000001_release_disambiguation.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use entity::{ReleaseColumn, ReleaseEntity};
use sea_orm::ColumnTrait;
use sea_orm_migration::prelude::*;
use sea_query::Table;

#[derive(DeriveMigrationName)]
pub struct Migration;

#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
let mut binding = Table::alter();
let table =
binding
.table(ReleaseEntity)
.add_column_if_not_exists(&mut ColumnDef::new_with_type(
ReleaseColumn::Disambiguation,
ReleaseColumn::Disambiguation
.def()
.get_column_type()
.clone(),
));
manager.alter_table(table.to_owned()).await?;
Ok(())
}
}

0 comments on commit bf2e90c

Please sign in to comment.