From 470650e504d0e6c4a3cb77a667a92b30f2daed70 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Thu, 25 May 2023 11:07:45 +0200 Subject: [PATCH] fix migration break --- .../20230524065919_fix_migration_break.down.sql | 1 + .../20230524065919_fix_migration_break.up.sql | 11 +++++++++++ backend/src/main.rs | 1 + 3 files changed, 13 insertions(+) create mode 100644 backend/migrations/20230524065919_fix_migration_break.down.sql create mode 100644 backend/migrations/20230524065919_fix_migration_break.up.sql diff --git a/backend/migrations/20230524065919_fix_migration_break.down.sql b/backend/migrations/20230524065919_fix_migration_break.down.sql new file mode 100644 index 0000000000..d2f607c5b8 --- /dev/null +++ b/backend/migrations/20230524065919_fix_migration_break.down.sql @@ -0,0 +1 @@ +-- Add down migration script here diff --git a/backend/migrations/20230524065919_fix_migration_break.up.sql b/backend/migrations/20230524065919_fix_migration_break.up.sql new file mode 100644 index 0000000000..f4db3117a1 --- /dev/null +++ b/backend/migrations/20230524065919_fix_migration_break.up.sql @@ -0,0 +1,11 @@ +-- Add up migration script here +do + $$ +BEGIN + +IF (NOT EXISTS (SELECT workspace_id FROM script WHERE workspace_id = 'demo' UNION ALL SELECT workspace_id FROM flow WHERE workspace_id = 'demo' UNION ALL SELECT workspace_id FROM app WHERE workspace_id = 'demo')) +THEN + DELETE FROM workspace_invite WHERE workspace_id = 'demo'; +END IF; +END +$$ diff --git a/backend/src/main.rs b/backend/src/main.rs index 4dd4a8f312..c0dbd6a26d 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -99,6 +99,7 @@ async fn main() -> anyhow::Result<()> { }; if server_mode { + // migration code to avoid break windmill_api::migrate_db(&db).await?; }