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

Fix SQL visibility root workflow fields in schema #6067

Merged
merged 1 commit into from
Jun 5, 2024
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
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);
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
Loading