From f438d1adbe79fcc61fc34b086ab0ce2b2ed55e47 Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Mon, 30 Sep 2024 14:02:31 +0200 Subject: [PATCH] fix: skip one migration to avoid using md5 for azure support --- .../create_workspace_without_md5.sql | 16 ++++++++++++++++ backend/windmill-api/src/db.rs | 16 +++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 backend/custom_migrations/create_workspace_without_md5.sql diff --git a/backend/custom_migrations/create_workspace_without_md5.sql b/backend/custom_migrations/create_workspace_without_md5.sql new file mode 100644 index 0000000000..4a818d6611 --- /dev/null +++ b/backend/custom_migrations/create_workspace_without_md5.sql @@ -0,0 +1,16 @@ +INSERT INTO workspace(id, name, owner) VALUES + ('admins', 'Admins', 'admin@windmill.dev'); + +INSERT INTO workspace_settings (workspace_id) VALUES + ('admins'); + +INSERT INTO workspace_key + (workspace_id, kind, key) + VALUES ('admins', 'cloud', array_to_string( + array( + SELECT chr( (trunc(65 + random() * 25)::int) + + CASE WHEN random() > 0.5 THEN 32 ELSE 0 END ) -- generates random uppercase/lowercase letters + FROM generate_series(1, 32) -- generates 32 characters + ), + '' +)); \ No newline at end of file diff --git a/backend/windmill-api/src/db.rs b/backend/windmill-api/src/db.rs index 72ef2e1680..41761d53b9 100644 --- a/backend/windmill-api/src/db.rs +++ b/backend/windmill-api/src/db.rs @@ -130,9 +130,19 @@ impl Migrate for CustomMigrator { migration.version, migration.description ); - let r = self.inner.apply(migration).await; - tracing::info!("Finished applying migration {}", migration.version); - r + if migration.version == 20221207103910 { + tracing::info!("Skipping migration 20221207103910 to avoid using md5"); + self.inner + .execute(include_str!( + "../../custom_migrations/create_workspace_without_md5.sql" + )) + .await?; + return Ok(std::time::Duration::from_secs(0)); + } else { + let r = self.inner.apply(migration).await; + tracing::info!("Finished applying migration {}", migration.version); + return r; + } } .boxed() }