Skip to content

Commit

Permalink
fixed #1039 - first DB migration failing on Postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugeny committed Nov 28, 2024
1 parent 379b1bc commit 41d3158
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions warpgate-db-migrations/src/m00001_create_ticket.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use sea_orm::Schema;
use sea_orm::{DbBackend, Schema};
use sea_orm_migration::prelude::*;

pub mod ticket {
Expand Down Expand Up @@ -42,13 +42,15 @@ impl MigrationTrait for Migration {
.create_table(schema.create_table_from_entity(ticket::Entity))
.await?;

// https://github.com/warp-tech/warpgate/issues/857
let _ = manager
.get_connection()
.execute_unprepared(
"ALTER TABLE `tickets` MODIFY COLUMN `expiry` TIMESTAMP NULL DEFAULT NULL",
)
.await;
let connection = manager.get_connection();
if connection.get_database_backend() == DbBackend::MySql {
// https://github.com/warp-tech/warpgate/issues/857
connection
.execute_unprepared(
"ALTER TABLE `tickets` MODIFY COLUMN `expiry` TIMESTAMP NULL DEFAULT NULL",
)
.await?;
}

Ok(())
}
Expand Down

0 comments on commit 41d3158

Please sign in to comment.