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/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/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, 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() {