From c575fe8b6770a2fb347db119ba9015c20c794cb4 Mon Sep 17 00:00:00 2001 From: Samuel Lindgren Date: Sun, 24 Nov 2024 18:16:47 +0100 Subject: [PATCH 1/4] change `workflow_id` from varchar 255 to text in postgresql --- .../v0.6/extend_workflow_id_length.sql | 19 +++++++++++++++++++ .../cadence/versioned/v0.6/manifest.json | 8 ++++++++ schema/postgres/version.go | 4 ++-- .../v0.8/extend_workflow_id_length.sql | 1 + .../visibility/versioned/v0.8/manifest.json | 8 ++++++++ tools/common/schema/updatetask_test.go | 4 ++-- 6 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 schema/postgres/cadence/versioned/v0.6/extend_workflow_id_length.sql create mode 100644 schema/postgres/cadence/versioned/v0.6/manifest.json create mode 100644 schema/postgres/visibility/versioned/v0.8/extend_workflow_id_length.sql create mode 100644 schema/postgres/visibility/versioned/v0.8/manifest.json diff --git a/schema/postgres/cadence/versioned/v0.6/extend_workflow_id_length.sql b/schema/postgres/cadence/versioned/v0.6/extend_workflow_id_length.sql new file mode 100644 index 00000000000..1a4be42a952 --- /dev/null +++ b/schema/postgres/cadence/versioned/v0.6/extend_workflow_id_length.sql @@ -0,0 +1,19 @@ +ALTER TABLE executions ALTER workflow_id TYPE text; + +ALTER TABLE current_executions ALTER workflow_id TYPE text; + +ALTER TABLE buffered_events ALTER workflow_id TYPE text; + +ALTER TABLE activity_info_maps ALTER workflow_id TYPE text; + +ALTER TABLE timer_info_maps ALTER workflow_id TYPE text; + +ALTER TABLE child_execution_info_maps ALTER workflow_id TYPE text; + +ALTER TABLE request_cancel_info_maps ALTER workflow_id TYPE text; + +ALTER TABLE signal_info_maps ALTER workflow_id TYPE text; + +ALTER TABLE buffered_replication_task_maps ALTER workflow_id TYPE text; + +ALTER TABLE signals_requested_sets ALTER workflow_id TYPE text; \ No newline at end of file diff --git a/schema/postgres/cadence/versioned/v0.6/manifest.json b/schema/postgres/cadence/versioned/v0.6/manifest.json new file mode 100644 index 00000000000..131f2289d92 --- /dev/null +++ b/schema/postgres/cadence/versioned/v0.6/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "0.6", + "MinCompatibleVersion": "0.6", + "Description": "update type of workflow_id to text to remove length restriction", + "SchemaUpdateCqlFiles": [ + "extend_workflow_id_length.sql" + ] +} diff --git a/schema/postgres/version.go b/schema/postgres/version.go index 37faef7fb44..050de1a80de 100644 --- a/schema/postgres/version.go +++ b/schema/postgres/version.go @@ -24,8 +24,8 @@ package postgres // Version is the Postgres database release version // Cadence supports both MySQL and Postgres officially, so upgrade should be perform for both MySQL and Postgres -const Version = "0.5" +const Version = "0.6" // VisibilityVersion is the Postgres visibility database release version // Cadence supports both MySQL and Postgres officially, so upgrade should be perform for both MySQL and Postgres -const VisibilityVersion = "0.7" +const VisibilityVersion = "0.8" diff --git a/schema/postgres/visibility/versioned/v0.8/extend_workflow_id_length.sql b/schema/postgres/visibility/versioned/v0.8/extend_workflow_id_length.sql new file mode 100644 index 00000000000..ab272e0c9af --- /dev/null +++ b/schema/postgres/visibility/versioned/v0.8/extend_workflow_id_length.sql @@ -0,0 +1 @@ +ALTER TABLE executions_visibility ALTER workflow_id TYPE TEXT; diff --git a/schema/postgres/visibility/versioned/v0.8/manifest.json b/schema/postgres/visibility/versioned/v0.8/manifest.json new file mode 100644 index 00000000000..a31b9548c19 --- /dev/null +++ b/schema/postgres/visibility/versioned/v0.8/manifest.json @@ -0,0 +1,8 @@ +{ + "CurrVersion": "0.8", + "MinCompatibleVersion": "0.8", + "Description": "update type of workflow_id to text to remove length restriction", + "SchemaUpdateCqlFiles": [ + "extend_workflow_id_length.sql" + ] +} \ No newline at end of file diff --git a/tools/common/schema/updatetask_test.go b/tools/common/schema/updatetask_test.go index b58d310aee1..7c31f762a81 100644 --- a/tools/common/schema/updatetask_test.go +++ b/tools/common/schema/updatetask_test.go @@ -138,13 +138,13 @@ func (s *UpdateTaskTestSuite) TestReadSchemaDirFromEmbeddings() { s.NoError(err) ans, err = readSchemaDir(fsys, "0.3", "") s.NoError(err) - s.Equal([]string{"v0.4", "v0.5"}, ans) + s.Equal([]string{"v0.4", "v0.5", "v0.6"}, ans) fsys, err = fs.Sub(postgres.SchemaFS, "visibility/versioned") s.NoError(err) ans, err = readSchemaDir(fsys, "0.5", "") s.NoError(err) - s.Equal([]string{"v0.6", "v0.7"}, ans) + s.Equal([]string{"v0.6", "v0.7", "v0.8"}, ans) } func (s *UpdateTaskTestSuite) TestReadManifest() { From 127edeaff51575ccfb7c62858bf588f7e31d4548 Mon Sep 17 00:00:00 2001 From: Samuel Lindgren Date: Mon, 25 Nov 2024 09:12:48 +0100 Subject: [PATCH 2/4] patch broken TestListBatchJobs unittest --- tools/cli/workflow_batch_commands_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/cli/workflow_batch_commands_test.go b/tools/cli/workflow_batch_commands_test.go index 14c7a0737c6..56134ffcf37 100644 --- a/tools/cli/workflow_batch_commands_test.go +++ b/tools/cli/workflow_batch_commands_test.go @@ -467,11 +467,11 @@ func TestListBatchJobs(t *testing.T) { expectedOutput: []map[string]string{ { "jobID": "example-workflow-1", - "startTime": "1970-01-01T00:00:01Z", + "startTime": "1970-01-01T01:00:01+01:00", "reason": "Testing reason", "operator": "test-operator", "status": "COMPLETED", - "closeTime": "1970-01-01T00:00:00Z", + "closeTime": "1970-01-01T01:00:00+01:00", }, }, }, From 10d91a04e15b80ee43a1bef8016cb769f5f51fc2 Mon Sep 17 00:00:00 2001 From: Samuel Lindgren Date: Wed, 27 Nov 2024 16:42:17 +0100 Subject: [PATCH 3/4] Revert "patch broken TestListBatchJobs unittest" This reverts commit 127edeaff51575ccfb7c62858bf588f7e31d4548. --- tools/cli/workflow_batch_commands_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/cli/workflow_batch_commands_test.go b/tools/cli/workflow_batch_commands_test.go index 56134ffcf37..14c7a0737c6 100644 --- a/tools/cli/workflow_batch_commands_test.go +++ b/tools/cli/workflow_batch_commands_test.go @@ -467,11 +467,11 @@ func TestListBatchJobs(t *testing.T) { expectedOutput: []map[string]string{ { "jobID": "example-workflow-1", - "startTime": "1970-01-01T01:00:01+01:00", + "startTime": "1970-01-01T00:00:01Z", "reason": "Testing reason", "operator": "test-operator", "status": "COMPLETED", - "closeTime": "1970-01-01T01:00:00+01:00", + "closeTime": "1970-01-01T00:00:00Z", }, }, }, From 9adcb93dc9505a6db54364aa366721f03b198cee Mon Sep 17 00:00:00 2001 From: Samuel Lindgren Date: Thu, 5 Dec 2024 16:21:18 +0100 Subject: [PATCH 4/4] update schemas to reflect incremental schema changes --- schema/postgres/cadence/schema.sql | 20 ++++++++++---------- schema/postgres/visibility/schema.sql | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/schema/postgres/cadence/schema.sql b/schema/postgres/cadence/schema.sql index aca57be60a1..608cce12dad 100644 --- a/schema/postgres/cadence/schema.sql +++ b/schema/postgres/cadence/schema.sql @@ -46,7 +46,7 @@ CREATE TABLE cross_cluster_tasks( CREATE TABLE executions( shard_id INTEGER NOT NULL, domain_id BYTEA NOT NULL, - workflow_id VARCHAR(255) NOT NULL, + workflow_id TEXT NOT NULL, run_id BYTEA NOT NULL, -- next_event_id BIGINT NOT NULL, @@ -59,7 +59,7 @@ CREATE TABLE executions( CREATE TABLE current_executions( shard_id INTEGER NOT NULL, domain_id BYTEA NOT NULL, - workflow_id VARCHAR(255) NOT NULL, + workflow_id TEXT NOT NULL, -- run_id BYTEA NOT NULL, create_request_id VARCHAR(64) NOT NULL, @@ -74,7 +74,7 @@ CREATE TABLE buffered_events ( id BIGSERIAL NOT NULL, shard_id INTEGER NOT NULL, domain_id BYTEA NOT NULL, - workflow_id VARCHAR(255) NOT NULL, + workflow_id TEXT NOT NULL, run_id BYTEA NOT NULL, -- data BYTEA NOT NULL, @@ -140,7 +140,7 @@ CREATE TABLE activity_info_maps ( -- each row corresponds to one key of one map shard_id INTEGER NOT NULL, domain_id BYTEA NOT NULL, - workflow_id VARCHAR(255) NOT NULL, + workflow_id TEXT NOT NULL, run_id BYTEA NOT NULL, schedule_id BIGINT NOT NULL, -- @@ -154,7 +154,7 @@ CREATE TABLE activity_info_maps ( CREATE TABLE timer_info_maps ( shard_id INTEGER NOT NULL, domain_id BYTEA NOT NULL, - workflow_id VARCHAR(255) NOT NULL, + workflow_id TEXT NOT NULL, run_id BYTEA NOT NULL, timer_id VARCHAR(255) NOT NULL, -- @@ -166,7 +166,7 @@ CREATE TABLE timer_info_maps ( CREATE TABLE child_execution_info_maps ( shard_id INTEGER NOT NULL, domain_id BYTEA NOT NULL, - workflow_id VARCHAR(255) NOT NULL, + workflow_id TEXT NOT NULL, run_id BYTEA NOT NULL, initiated_id BIGINT NOT NULL, -- @@ -178,7 +178,7 @@ CREATE TABLE child_execution_info_maps ( CREATE TABLE request_cancel_info_maps ( shard_id INTEGER NOT NULL, domain_id BYTEA NOT NULL, - workflow_id VARCHAR(255) NOT NULL, + workflow_id TEXT NOT NULL, run_id BYTEA NOT NULL, initiated_id BIGINT NOT NULL, -- @@ -190,7 +190,7 @@ CREATE TABLE request_cancel_info_maps ( CREATE TABLE signal_info_maps ( shard_id INTEGER NOT NULL, domain_id BYTEA NOT NULL, - workflow_id VARCHAR(255) NOT NULL, + workflow_id TEXT NOT NULL, run_id BYTEA NOT NULL, initiated_id BIGINT NOT NULL, -- @@ -202,7 +202,7 @@ CREATE TABLE signal_info_maps ( CREATE TABLE buffered_replication_task_maps ( shard_id INTEGER NOT NULL, domain_id BYTEA NOT NULL, - workflow_id VARCHAR(255) NOT NULL, + workflow_id TEXT NOT NULL, run_id BYTEA NOT NULL, first_event_id BIGINT NOT NULL, -- @@ -220,7 +220,7 @@ CREATE TABLE buffered_replication_task_maps ( CREATE TABLE signals_requested_sets ( shard_id INTEGER NOT NULL, domain_id BYTEA NOT NULL, - workflow_id VARCHAR(255) NOT NULL, + workflow_id TEXT NOT NULL, run_id BYTEA NOT NULL, signal_id VARCHAR(64) NOT NULL, -- diff --git a/schema/postgres/visibility/schema.sql b/schema/postgres/visibility/schema.sql index 7975b76babc..765f6bc9a02 100644 --- a/schema/postgres/visibility/schema.sql +++ b/schema/postgres/visibility/schema.sql @@ -3,7 +3,7 @@ CREATE TABLE executions_visibility ( run_id CHAR(64) NOT NULL, start_time TIMESTAMP NOT NULL, execution_time TIMESTAMP NOT NULL, - workflow_id VARCHAR(255) NOT NULL, + workflow_id TEXT NOT NULL, workflow_type_name VARCHAR(255) NOT NULL, close_status INTEGER, -- enum WorkflowExecutionCloseStatus {COMPLETED, FAILED, CANCELED, TERMINATED, CONTINUED_AS_NEW, TIMED_OUT} close_time TIMESTAMP NULL,