fixed #1039 - first DB migration failing on Postgres

This commit is contained in:
Eugene 2024-11-28 22:12:03 +01:00
parent 379b1bc5e9
commit 41d3158cbf
No known key found for this signature in database
GPG key ID: 5896FCBBDD1CF4F4

View file

@ -1,4 +1,4 @@
use sea_orm::Schema;
use sea_orm::{DbBackend, Schema};
use sea_orm_migration::prelude::*;
pub mod ticket {
@ -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(())
}