Skip to content

Commit

Permalink
Fix SQL visibility root workflow fields in schema
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigozhou committed Jun 5, 2024
1 parent b566f30 commit a1d21aa
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 8 deletions.
2 changes: 1 addition & 1 deletion schema/mysql/v8/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ package v8
const Version = "1.12"

// VisibilityVersion is the MySQL visibility database release version
const VisibilityVersion = "1.5"
const VisibilityVersion = "1.6"
4 changes: 2 additions & 2 deletions schema/mysql/v8/visibility/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ CREATE TABLE executions_visibility (
search_attributes JSON NULL,
parent_workflow_id VARCHAR(255) NULL,
parent_run_id VARCHAR(255) NULL,
root_workflow_id VARCHAR(255) NULL,
root_run_id VARCHAR(255) NULL,
root_workflow_id VARCHAR(255) NOT NULL DEFAULT '',
root_run_id VARCHAR(255) NOT NULL DEFAULT '',

-- Each search attribute has its own generated column.
-- For string types (keyword and text), we need to unquote the json string,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DROP INDEX by_root_workflow_id ON executions_visibility;
DROP INDEX by_root_run_id ON executions_visibility;
ALTER TABLE executions_visibility DROP COLUMN root_workflow_id;
ALTER TABLE executions_visibility DROP COLUMN root_run_id;

ALTER TABLE executions_visibility ADD COLUMN root_workflow_id VARCHAR(255) NOT NULL DEFAULT '';
ALTER TABLE executions_visibility ADD COLUMN root_run_id VARCHAR(255) NOT NULL DEFAULT '';
CREATE INDEX by_root_workflow_id ON executions_visibility (namespace_id, root_workflow_id, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id);
CREATE INDEX by_root_run_id ON executions_visibility (namespace_id, root_run_id, (COALESCE(close_time, CAST('9999-12-31 23:59:59' AS DATETIME))) DESC, start_time DESC, run_id);
8 changes: 8 additions & 0 deletions schema/mysql/v8/visibility/versioned/v1.6/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"CurrVersion": "1.6",
"MinCompatibleVersion": "0.1",
"Description": "fix root workflow info columns",
"SchemaUpdateCqlFiles": [
"fix_root_workflow_info.sql"
]
}
2 changes: 1 addition & 1 deletion schema/postgresql/v12/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ const Version = "1.12"

// VisibilityVersion is the Postgres visibility database release version
// Temporal supports both MySQL and Postgres officially, so upgrade should be performed for both MySQL and Postgres
const VisibilityVersion = "1.5"
const VisibilityVersion = "1.6"
4 changes: 2 additions & 2 deletions schema/postgresql/v12/visibility/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ CREATE TABLE executions_visibility (
search_attributes JSONB NULL,
parent_workflow_id VARCHAR(255) NULL,
parent_run_id VARCHAR(255) NULL,
root_workflow_id VARCHAR(255) NULL,
root_run_id VARCHAR(255) NULL,
root_workflow_id VARCHAR(255) NOT NULL DEFAULT '',
root_run_id VARCHAR(255) NOT NULL DEFAULT '',

-- Each search attribute has its own generated column.
-- Since PostgreSQL doesn't support virtual columns, all columns are stored.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
DROP INDEX by_root_workflow_id;
DROP INDEX by_root_run_id;
ALTER TABLE executions_visibility DROP COLUMN root_workflow_id;
ALTER TABLE executions_visibility DROP COLUMN root_run_id;

ALTER TABLE executions_visibility ADD COLUMN root_workflow_id VARCHAR(255) NOT NULL DEFAULT '';
ALTER TABLE executions_visibility ADD COLUMN root_run_id VARCHAR(255) NOT NULL DEFAULT '';
CREATE INDEX by_root_workflow_id ON executions_visibility (namespace_id, root_workflow_id, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id);
CREATE INDEX by_root_run_id ON executions_visibility (namespace_id, root_run_id, (COALESCE(close_time, '9999-12-31 23:59:59')) DESC, start_time DESC, run_id);
8 changes: 8 additions & 0 deletions schema/postgresql/v12/visibility/versioned/v1.6/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"CurrVersion": "1.6",
"MinCompatibleVersion": "0.1",
"Description": "fix root workflow info columns",
"SchemaUpdateCqlFiles": [
"fix_root_workflow_info.sql"
]
}
4 changes: 2 additions & 2 deletions schema/sqlite/v3/visibility/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ CREATE TABLE executions_visibility (
search_attributes TEXT NULL,
parent_workflow_id VARCHAR(255) NULL,
parent_run_id VARCHAR(255) NULL,
root_workflow_id VARCHAR(255) NULL,
root_run_id VARCHAR(255) NULL,
root_workflow_id VARCHAR(255) NOT NULL DEFAULT '',
root_run_id VARCHAR(255) NOT NULL DEFAULT '',

-- Predefined search attributes
TemporalChangeVersion TEXT GENERATED ALWAYS AS (JSON_EXTRACT(search_attributes, "$.TemporalChangeVersion")) STORED,
Expand Down

0 comments on commit a1d21aa

Please sign in to comment.