From 835fcbe332c0019bb5913aebe8e477fff1d4ec64 Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Sat, 1 Jun 2024 16:20:07 +0530 Subject: [PATCH] feat(backend,database): change defaults for columns --- Cargo.lock | 2 +- apps/backend/Cargo.toml | 2 +- .../m20240607_is_really_last_v5_migration.rs | 23 +++++++++++++++++++ libs/database/src/migrations/mod.rs | 2 ++ 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 libs/database/src/migrations/m20240607_is_really_last_v5_migration.rs diff --git a/Cargo.lock b/Cargo.lock index 77c96704dc..adcaff1e91 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4969,7 +4969,7 @@ checksum = "7ffc183a10b4478d04cbbbfc96d0873219d962dd5accaff2ffbd4ceb7df837f4" [[package]] name = "ryot" -version = "5.5.1" +version = "5.5.2" dependencies = [ "anyhow", "apalis", diff --git a/apps/backend/Cargo.toml b/apps/backend/Cargo.toml index 922fef3cc0..712864d66f 100644 --- a/apps/backend/Cargo.toml +++ b/apps/backend/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ryot" -version = "5.5.1" +version = "5.5.2" edition = "2021" repository = "https://github.com/IgnisDa/ryot" license = "GPL-3.0" diff --git a/libs/database/src/migrations/m20240607_is_really_last_v5_migration.rs b/libs/database/src/migrations/m20240607_is_really_last_v5_migration.rs new file mode 100644 index 0000000000..7286ac1aa6 --- /dev/null +++ b/libs/database/src/migrations/m20240607_is_really_last_v5_migration.rs @@ -0,0 +1,23 @@ +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> { + let db = manager.get_connection(); + db.execute_unprepared( + r#" +ALTER TABLE "review" ALTER COLUMN "visibility" SET DEFAULT 'private'; +ALTER TABLE "seen" ALTER COLUMN "in_progress" SET DEFAULT 'private'; + "#, + ) + .await?; + Ok(()) + } + + async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> { + Ok(()) + } +} diff --git a/libs/database/src/migrations/mod.rs b/libs/database/src/migrations/mod.rs index c403a49936..e6d2603628 100644 --- a/libs/database/src/migrations/mod.rs +++ b/libs/database/src/migrations/mod.rs @@ -46,6 +46,7 @@ mod m20240601_09_complete_cleanup_of_primary_keys; mod m20240601_10_change_enums_to_snake_case; mod m20240601_11_workout_table_changes; mod m20240606_is_last_v5_migration; +mod m20240607_is_really_last_v5_migration; pub use m20230410_create_metadata::Metadata as AliasedMetadata; pub use m20230413_create_person::Person as AliasedPerson; @@ -126,6 +127,7 @@ impl MigratorTrait for Migrator { Box::new(m20240601_10_change_enums_to_snake_case::Migration), Box::new(m20240601_11_workout_table_changes::Migration), Box::new(m20240606_is_last_v5_migration::Migration), + Box::new(m20240607_is_really_last_v5_migration::Migration), ] } }