Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align Postgres workflow_id Column with Cassandra #6520

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions schema/postgres/cadence/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -140,7 +140,7 @@ CREATE TABLE activity_info_maps (
-- each row corresponds to one key of one map<string, ActivityInfo>
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,
--
Expand All @@ -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,
--
Expand All @@ -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,
--
Expand All @@ -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,
--
Expand All @@ -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,
--
Expand All @@ -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,
--
Expand All @@ -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,
--
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
ALTER TABLE executions ALTER workflow_id TYPE text;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also update cadence/schema.sql and visibility/schema.sql to reflect these changes? During first time setup we run only the schema files, the versions are used only when an existing cluster is upgraded. The schema files should match the outcome of running all the version upgrades.


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;
8 changes: 8 additions & 0 deletions schema/postgres/cadence/versioned/v0.6/manifest.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
4 changes: 2 additions & 2 deletions schema/postgres/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion schema/postgres/visibility/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE executions_visibility ALTER workflow_id TYPE TEXT;
8 changes: 8 additions & 0 deletions schema/postgres/visibility/versioned/v0.8/manifest.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
4 changes: 2 additions & 2 deletions tools/common/schema/updatetask_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading