From c1a10b0342bfb98e68b11f16398325ba07a9b6da Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Mon, 14 Nov 2022 06:31:35 +0000 Subject: [PATCH] add_column_if_not_exists doesn't work in mysql --- migration/src/m20221108_200345_save_anon_stats.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/migration/src/m20221108_200345_save_anon_stats.rs b/migration/src/m20221108_200345_save_anon_stats.rs index 81b65fd0..b63aa8c7 100644 --- a/migration/src/m20221108_200345_save_anon_stats.rs +++ b/migration/src/m20221108_200345_save_anon_stats.rs @@ -6,6 +6,16 @@ pub struct Migration; #[async_trait::async_trait] impl MigrationTrait for Migration { async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { + // note: somehow this column got added in prod, but the migration wasn't marked as complete + let _ = manager + .alter_table( + Table::alter() + .table(RpcAccounting::Table) + .drop_column(RpcAccounting::Origin) + .to_owned(), + ) + .await; + manager .alter_table( Table::alter() @@ -15,7 +25,7 @@ impl MigrationTrait for Migration { .big_unsigned() .null(), ) - .add_column_if_not_exists(ColumnDef::new(RpcAccounting::Origin).string().null()) + .add_column(ColumnDef::new(RpcAccounting::Origin).string().null()) .to_owned(), ) .await