From 4dfe644351f8e729fa84a17cbe5b89195198710e Mon Sep 17 00:00:00 2001 From: Diptesh Choudhuri Date: Wed, 5 Feb 2025 15:48:35 +0530 Subject: [PATCH] fix(migrations): add check before adding new column --- .../src/m20250204_changes_for_issue_1231.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/migrations/src/m20250204_changes_for_issue_1231.rs b/crates/migrations/src/m20250204_changes_for_issue_1231.rs index 026af6b435..bf89df14db 100644 --- a/crates/migrations/src/m20250204_changes_for_issue_1231.rs +++ b/crates/migrations/src/m20250204_changes_for_issue_1231.rs @@ -7,10 +7,15 @@ pub struct Migration; impl MigrationTrait for Migration { async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { let db = manager.get_connection(); - db.execute_unprepared( - r#"ALTER TABLE "user_to_entity" ADD COLUMN "collection_extra_information" JSONB"#, - ) - .await?; + if !manager + .has_column("user_to_entity", "collection_extra_information") + .await? + { + db.execute_unprepared( + r#"ALTER TABLE "user_to_entity" ADD COLUMN "collection_extra_information" JSONB"#, + ) + .await?; + } Ok(()) }