From a083edef6e67d9c0ce9c3cace169c1a4942c5649 Mon Sep 17 00:00:00 2001 From: alemi Date: Sun, 21 Apr 2024 16:30:29 +0200 Subject: [PATCH] fix: sqlite won't update columns anyway since this migration breaks all sqlite dbs, i changed the original migration so that future ones won't panic when reaching here. note that, if you are on sqlite, just `sqlite3 .dump > backup.sql` and then, after rebuilding and re-migrating db, `cat backup.sql | sqlite3 ` --- .../m20240324_000001_add_addressing.rs | 2 +- ...000001_make_addressed_activity_nullable.rs | 48 ------------------- src/migrations/mod.rs | 2 - 3 files changed, 1 insertion(+), 51 deletions(-) delete mode 100644 src/migrations/m20240421_000001_make_addressed_activity_nullable.rs diff --git a/src/migrations/m20240324_000001_add_addressing.rs b/src/migrations/m20240324_000001_add_addressing.rs index 32aac39b..358a5566 100644 --- a/src/migrations/m20240324_000001_add_addressing.rs +++ b/src/migrations/m20240324_000001_add_addressing.rs @@ -19,7 +19,7 @@ impl MigrationTrait for Migration { ) .col(ColumnDef::new(Addressing::Actor).string().not_null()) .col(ColumnDef::new(Addressing::Server).string().not_null()) - .col(ColumnDef::new(Addressing::Activity).string().not_null()) + .col(ColumnDef::new(Addressing::Activity).string().null()) .col(ColumnDef::new(Addressing::Object).string().null()) .col(ColumnDef::new(Addressing::Published).date_time().not_null()) .to_owned() diff --git a/src/migrations/m20240421_000001_make_addressed_activity_nullable.rs b/src/migrations/m20240421_000001_make_addressed_activity_nullable.rs deleted file mode 100644 index 74c4265f..00000000 --- a/src/migrations/m20240421_000001_make_addressed_activity_nullable.rs +++ /dev/null @@ -1,48 +0,0 @@ -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(Addressing::Table) - .modify_column( - ColumnDef::new(Addressing::Activity) - .string() - .null() - ) - .to_owned() - ) - .await?; - - Ok(()) - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - manager - .alter_table( - Table::alter() - .table(Addressing::Table) - .modify_column( - ColumnDef::new(Addressing::Activity) - .string() - .not_null() - .default("") - ) - .to_owned() - ) - .await?; - - Ok(()) - } -} - -#[derive(DeriveIden)] -enum Addressing { - Table, - Activity, -} diff --git a/src/migrations/mod.rs b/src/migrations/mod.rs index c80871d3..19d63012 100644 --- a/src/migrations/mod.rs +++ b/src/migrations/mod.rs @@ -10,7 +10,6 @@ mod m20240324_000001_add_addressing; mod m20240325_000001_add_deliveries; mod m20240325_000002_add_system_key; mod m20240418_000001_add_statuses_and_reply_to; -mod m20240421_000001_make_addressed_activity_nullable; pub struct Migrator; @@ -28,7 +27,6 @@ impl MigratorTrait for Migrator { Box::new(m20240325_000001_add_deliveries::Migration), Box::new(m20240325_000002_add_system_key::Migration), Box::new(m20240418_000001_add_statuses_and_reply_to::Migration), - Box::new(m20240421_000001_make_addressed_activity_nullable::Migration), ] } }