From 5e693cc28a94fb49ff423d593960f59c32cdc771 Mon Sep 17 00:00:00 2001 From: Guillaume Bouvignies Date: Mon, 4 Dec 2023 17:00:52 +0100 Subject: [PATCH] fix: deployment_metadata table app_version is a nullable BIGINT (#2769) --- ...23_refactor_deployment_metadata_table.down.sql | 15 +++++++++++++++ ...4423_refactor_deployment_metadata_table.up.sql | 15 +++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 backend/migrations/20231204144423_refactor_deployment_metadata_table.down.sql create mode 100644 backend/migrations/20231204144423_refactor_deployment_metadata_table.up.sql diff --git a/backend/migrations/20231204144423_refactor_deployment_metadata_table.down.sql b/backend/migrations/20231204144423_refactor_deployment_metadata_table.down.sql new file mode 100644 index 0000000000..f1062f8440 --- /dev/null +++ b/backend/migrations/20231204144423_refactor_deployment_metadata_table.down.sql @@ -0,0 +1,15 @@ +-- Add down migration script here +DROP TABLE deployment_metadata; + +CREATE TABLE deployment_metadata( + workspace_id VARCHAR(50) NOT NULL REFERENCES workspace(id), + path VARCHAR(255) NOT NULL, + script_hash BIGINT, + app_version BIGINT, + callback_job_ids UUID[], + deployment_msg TEXT +); + +CREATE UNIQUE INDEX IF NOT EXISTS deployment_metadata_script ON deployment_metadata (workspace_id, script_hash) WHERE script_hash IS NOT NULL; +CREATE UNIQUE INDEX IF NOT EXISTS deployment_metadata_flow ON deployment_metadata (workspace_id, path) WHERE script_hash IS NULL AND app_version IS NULL; +CREATE UNIQUE INDEX IF NOT EXISTS deployment_metadata_app ON deployment_metadata (workspace_id, path, app_version) WHERE app_version IS NOT NULL; \ No newline at end of file diff --git a/backend/migrations/20231204144423_refactor_deployment_metadata_table.up.sql b/backend/migrations/20231204144423_refactor_deployment_metadata_table.up.sql new file mode 100644 index 0000000000..e4e5589af8 --- /dev/null +++ b/backend/migrations/20231204144423_refactor_deployment_metadata_table.up.sql @@ -0,0 +1,15 @@ +-- Add up migration script here +DROP TABLE deployment_metadata; + +CREATE TABLE deployment_metadata( + workspace_id VARCHAR(50) NOT NULL REFERENCES workspace(id), + path VARCHAR(255) NOT NULL, + script_hash BIGINT, + app_version BIGINT, + callback_job_ids UUID[], + deployment_msg TEXT +); + +CREATE UNIQUE INDEX IF NOT EXISTS deployment_metadata_script ON deployment_metadata (workspace_id, script_hash) WHERE script_hash IS NOT NULL; +CREATE UNIQUE INDEX IF NOT EXISTS deployment_metadata_flow ON deployment_metadata (workspace_id, path) WHERE script_hash IS NULL AND app_version IS NULL; +CREATE UNIQUE INDEX IF NOT EXISTS deployment_metadata_app ON deployment_metadata (workspace_id, path, app_version) WHERE app_version IS NOT NULL;