Fix otel migration error (#5189)

* Fix otel migration error

    1: error returned from database: duplicate key value violates unique constraint "global_settings_pkey"
    0: while executing migration 20250131115248: error returned from database: duplicate key value violates unique constraint "global_settings_pkey"

* delete migration

* add .sqlx cache + move otel_global_settings to new location

* Fix compilation error

* Move before migrating

* Add error handler

* warn -> info

---------

Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
This commit is contained in:
pyranota
2025-01-31 21:34:23 +03:00
committed by GitHub
parent 4bff0b576f
commit f9c77dbc83
4 changed files with 23 additions and 0 deletions
@@ -0,0 +1,12 @@
{
"db_name": "PostgreSQL",
"query": "DELETE FROM _sqlx_migrations WHERE version=20250131115248",
"describe": {
"columns": [],
"parameters": {
"Left": []
},
"nullable": []
},
"hash": "fe58ca3cef78c73867d309156df2b74f7127bf6cba25c9a0c5ca5eedd6a19aff"
}
@@ -0,0 +1 @@
DELETE FROM global_settings WHERE name = 'otel';
@@ -0,0 +1,3 @@
INSERT INTO global_settings (name, value)
VALUES ('otel', '{}')
ON CONFLICT (name) DO NOTHING;
+7
View File
@@ -173,6 +173,13 @@ pub async fn migrate(db: &DB) -> Result<(), Error> {
let migrator = db.acquire().await?;
let mut custom_migrator = CustomMigrator { inner: migrator };
if let Err(err) = sqlx::query!("DELETE FROM _sqlx_migrations WHERE version=20250131115248")
.execute(db)
.await
{
tracing::info!("Could not remove sqlx migration with version=20250131115248: {err:#}");
}
match sqlx::migrate!("../migrations")
.run_direct(&mut custom_migrator)
.await