Skip to content

Commit

Permalink
feat(migrations): add columns for import report progress
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnisDa committed Nov 30, 2024
1 parent 30d9282 commit 95cdc46
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crates/migrations/src/m20230509_create_import_report.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ pub struct Migration;

#[derive(Iden)]
pub enum ImportReport {
Table,
Id,
Table,
UserId,
StartedOn,
FinishedOn,
Source,
Details,
Progress,
StartedOn,
FinishedOn,
WasSuccess,
}

Expand Down Expand Up @@ -41,6 +42,7 @@ impl MigrationTrait for Migration {
.col(ColumnDef::new(ImportReport::WasSuccess).boolean())
.col(ColumnDef::new(ImportReport::Details).json_binary())
.col(ColumnDef::new(ImportReport::UserId).text().not_null())
.col(ColumnDef::new(ImportReport::Progress).decimal())
.foreign_key(
ForeignKey::create()
.name("media_import_report_to_user_foreign_key")
Expand Down
4 changes: 4 additions & 0 deletions crates/migrations/src/m20241129_changes_for_issue_1114.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ pub struct Migration;
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
let db = manager.get_connection();
if !manager.has_column("import_report", "progress").await? {
db.execute_unprepared(r#"ALTER TABLE "import_report" ADD COLUMN "progress" DECIMAL"#)
.await?;
}
db.execute_unprepared(
r#"
UPDATE "import_report" SET "source" = 'myanimelist' WHERE "source" = 'mal';
Expand Down

0 comments on commit 95cdc46

Please sign in to comment.