Skip to content

Commit

Permalink
fix(migrations): add check before adding new column
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnisDa committed Feb 5, 2025
1 parent c0e5ed7 commit 4dfe644
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions crates/migrations/src/m20250204_changes_for_issue_1231.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand Down

0 comments on commit 4dfe644

Please sign in to comment.