add columns for errors on videos (count & reason)

This commit is contained in:
OMGeeky
2023-10-15 12:54:30 +02:00
parent 24d522efc8
commit 36dc05bc06
4 changed files with 60 additions and 1 deletions

View File

@@ -22,6 +22,8 @@ pub struct Model {
pub youtube_playlist_created_at: Option<String>,
pub part_count: i32,
pub status: Status,
pub fail_count: i32,
pub fail_reason: Option<String>,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]

View File

@@ -9,7 +9,7 @@ use tracing::{info, instrument};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
run().await.unwrap();
run().await?;
Ok(())
}

View File

@@ -0,0 +1,55 @@
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
.alter_table(
Table::alter()
.table(Videos::Table)
.add_column(
ColumnDef::new(Videos::FailCount)
.integer()
.not_null()
.default(0),
)
.to_owned(),
)
.await?;
manager
.alter_table(
Table::alter()
.table(Videos::Table)
.add_column(ColumnDef::new(Videos::FailReason).string().null())
.to_owned(),
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.alter_table(
Table::alter()
.table(Videos::Table)
.drop_column(Videos::FailCount)
.to_owned(),
)
.await?;
manager
.alter_table(
Table::alter()
.table(Videos::Table)
.drop_column(Videos::FailReason)
.to_owned(),
)
.await
}
}
#[derive(Iden)]
pub enum Videos {
Table,
FailCount,
FailReason,
}

View File

@@ -4,6 +4,7 @@ mod m20230916_000001_create_users_table;
mod m20230916_000002_create_videos_table;
mod m20230916_000003_create_video_upload_table;
mod m20230916_000004_add_sample_data;
mod m20231015_000005_alter_videos_table_for_errors;
pub struct Migrator;
#[async_trait::async_trait]
@@ -14,6 +15,7 @@ impl MigratorTrait for Migrator {
Box::new(m20230916_000002_create_videos_table::Migration),
Box::new(m20230916_000003_create_video_upload_table::Migration),
// Box::new(m20230916_000004_add_sample_data::Migration),
Box::new(m20231015_000005_alter_videos_table_for_errors::Migration),
]
}
}