From 09615e5eebcce1afde2ed67db0390b5dd06ee17b Mon Sep 17 00:00:00 2001 From: Xinyuan Lin Date: Sun, 16 Aug 2026 19:12:26 -0700 Subject: [PATCH 1/5] chore(sql): remove the superseded manual update scripts 01-22 --- sql/updates/01.sql | 54 ----------------------------- sql/updates/02.sql | 77 ------------------------------------------ sql/updates/03.sql | 44 ------------------------ sql/updates/04.sql | 43 ------------------------ sql/updates/05.sql | 33 ------------------ sql/updates/06.sql | 62 ---------------------------------- sql/updates/07.sql | 77 ------------------------------------------ sql/updates/08.sql | 39 --------------------- sql/updates/09.sql | 30 ----------------- sql/updates/10.sql | 30 ----------------- sql/updates/11.sql | 28 ---------------- sql/updates/12.sql | 26 -------------- sql/updates/13.sql | 84 ---------------------------------------------- sql/updates/14.sql | 40 ---------------------- sql/updates/15.sql | 38 --------------------- sql/updates/16.sql | 29 ---------------- sql/updates/17.sql | 66 ------------------------------------ sql/updates/18.sql | 30 ----------------- sql/updates/19.sql | 60 --------------------------------- sql/updates/20.sql | 37 -------------------- sql/updates/21.sql | 29 ---------------- sql/updates/22.sql | 33 ------------------ 22 files changed, 989 deletions(-) delete mode 100644 sql/updates/01.sql delete mode 100644 sql/updates/02.sql delete mode 100644 sql/updates/03.sql delete mode 100644 sql/updates/04.sql delete mode 100644 sql/updates/05.sql delete mode 100644 sql/updates/06.sql delete mode 100644 sql/updates/07.sql delete mode 100644 sql/updates/08.sql delete mode 100644 sql/updates/09.sql delete mode 100644 sql/updates/10.sql delete mode 100644 sql/updates/11.sql delete mode 100644 sql/updates/12.sql delete mode 100644 sql/updates/13.sql delete mode 100644 sql/updates/14.sql delete mode 100644 sql/updates/15.sql delete mode 100644 sql/updates/16.sql delete mode 100644 sql/updates/17.sql delete mode 100644 sql/updates/18.sql delete mode 100644 sql/updates/19.sql delete mode 100644 sql/updates/20.sql delete mode 100644 sql/updates/21.sql delete mode 100644 sql/updates/22.sql diff --git a/sql/updates/01.sql b/sql/updates/01.sql deleted file mode 100644 index 9dd4e3031df..00000000000 --- a/sql/updates/01.sql +++ /dev/null @@ -1,54 +0,0 @@ --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, --- software distributed under the License is distributed on an --- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --- KIND, either express or implied. See the License for the --- specific language governing permissions and limitations --- under the License. - --- ============================================ --- 1. Connect to the texera_db database --- ============================================ -\c texera_db - -SET search_path TO texera_db; - --- ============================================ --- 2. Update the table schema --- ============================================ - -BEGIN; - --- 1. Rename original table temporarily -ALTER TABLE operator_port_executions RENAME TO operator_port_executions_old; - --- 2. Create the new table with columns in the correct order -CREATE TABLE operator_port_executions -( - workflow_execution_id INT NOT NULL, - operator_id VARCHAR(100) NOT NULL, - layer_name VARCHAR(100) NOT NULL DEFAULT 'main', - port_id INT NOT NULL, - result_uri TEXT, - PRIMARY KEY (workflow_execution_id, operator_id, layer_name, port_id), - FOREIGN KEY (workflow_execution_id) REFERENCES workflow_executions(eid) ON DELETE CASCADE -); - --- 3. Copy data from old table (use the default value for `layer_id`) -INSERT INTO operator_port_executions (workflow_execution_id, operator_id, port_id, result_uri) -SELECT workflow_execution_id, operator_id, port_id, result_uri -FROM operator_port_executions_old; - --- 4. Drop the old table after copying data -DROP TABLE operator_port_executions_old; - -COMMIT; \ No newline at end of file diff --git a/sql/updates/02.sql b/sql/updates/02.sql deleted file mode 100644 index 63c6c4ea109..00000000000 --- a/sql/updates/02.sql +++ /dev/null @@ -1,77 +0,0 @@ --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, --- software distributed under the License is distributed on an --- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --- KIND, either express or implied. See the License for the --- specific language governing permissions and limitations --- under the License. - -\c texera_db; - -set search_path to texera_db, public; - -CREATE EXTENSION IF NOT EXISTS pgroonga; - -DO $$ -DECLARE - r RECORD; - stem_filter TEXT := ''; - plugin_status TEXT; -BEGIN - -- Drop all GIN and PGroonga indexes - FOR r IN - SELECT indexname FROM pg_indexes - WHERE (indexdef ILIKE '%USING gin%' OR indexdef ILIKE '%USING pgroonga%') - AND tablename IN ('workflow', 'user', 'project', 'dataset', 'dataset_version') - LOOP - EXECUTE format('DROP INDEX IF EXISTS %I;', r.indexname); - END LOOP; - - -- Check if TokenFilterStem plugin is registered - WITH plugin_registration AS ( - SELECT pgroonga_command('plugin_register token_filters/stem') AS result - ) - SELECT - CASE - WHEN result::jsonb @> '[true]' THEN 'Plugin registered successfully' - ELSE 'Plugin registration failed' - END INTO plugin_status - FROM plugin_registration; - - -- Set the stem_filter based on plugin status - IF plugin_status = 'Plugin registered successfully' THEN - stem_filter := ', plugins=''token_filters/stem'', token_filters=''TokenFilterStem'''; - RAISE NOTICE 'Using TokenMecab + TokenFilterStem'; - ELSE - RAISE NOTICE 'Using TokenMecab only'; - END IF; - - -- Create PGroonga indexes dynamically with correct TokenFilterStem usage - FOR r IN - SELECT tablename, - CASE - WHEN tablename = 'workflow' THEN - '(COALESCE(name, '''') || '' '' || COALESCE(description, '''') || '' '' || COALESCE(content, ''''))' - WHEN tablename IN ('project', 'dataset') THEN - '(COALESCE(name, '''') || '' '' || COALESCE(description, ''''))' - ELSE - 'COALESCE(name, '''')' - END AS index_column - FROM (VALUES ('workflow'), ('user'), ('project'), ('dataset'), ('dataset_version')) AS t(tablename) - LOOP - -- Create PGroonga index with proper TokenFilterStem usage - EXECUTE format( - 'CREATE INDEX idx_%s_pgroonga ON %I USING pgroonga (%s) WITH (tokenizer = ''TokenMecab''%s);', - r.tablename, r.tablename, r.index_column, stem_filter - ); - END LOOP; -END $$; diff --git a/sql/updates/03.sql b/sql/updates/03.sql deleted file mode 100644 index 64d3d48d032..00000000000 --- a/sql/updates/03.sql +++ /dev/null @@ -1,44 +0,0 @@ --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, --- software distributed under the License is distributed on an --- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --- KIND, either express or implied. See the License for the --- specific language governing permissions and limitations --- under the License. - --- ============================================ --- 1. Connect to the texera_db database --- ============================================ -\c texera_db - -SET search_path TO texera_db; - --- ============================================ --- 2. Update the table schema --- ============================================ - -BEGIN; - --- 1. Drop the existing table -DROP TABLE IF EXISTS operator_port_executions; - --- 2. Create the new table with updated columns -CREATE TABLE operator_port_executions -( - workflow_execution_id INT NOT NULL, - global_port_id VARCHAR(200) NOT NULL, - result_uri TEXT, - PRIMARY KEY (workflow_execution_id, global_port_id), - FOREIGN KEY (workflow_execution_id) REFERENCES workflow_executions(eid) ON DELETE CASCADE -); - -COMMIT; \ No newline at end of file diff --git a/sql/updates/04.sql b/sql/updates/04.sql deleted file mode 100644 index 32a075db97b..00000000000 --- a/sql/updates/04.sql +++ /dev/null @@ -1,43 +0,0 @@ --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, --- software distributed under the License is distributed on an --- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --- KIND, either express or implied. See the License for the --- specific language governing permissions and limitations --- under the License. - --- ============================================ --- 1. Connect to the texera_db database --- ============================================ -\c texera_db - -SET search_path TO texera_db; - --- ============================================ --- 2. Update the table schema --- ============================================ - -BEGIN; - - -CREATE TABLE IF NOT EXISTS workflow_computing_unit -( - uid INT NOT NULL, - name VARCHAR(128) NOT NULL, - cuid SERIAL PRIMARY KEY, - creation_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - terminate_time TIMESTAMP DEFAULT NULL, - FOREIGN KEY (uid) REFERENCES "user"(uid) ON DELETE CASCADE -); - - -COMMIT; \ No newline at end of file diff --git a/sql/updates/05.sql b/sql/updates/05.sql deleted file mode 100644 index cba58d666e2..00000000000 --- a/sql/updates/05.sql +++ /dev/null @@ -1,33 +0,0 @@ --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, --- software distributed under the License is distributed on an --- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --- KIND, either express or implied. See the License for the --- specific language governing permissions and limitations --- under the License. - -\c texera_db - -SET search_path TO texera_db; - -DO $$ -BEGIN - IF NOT EXISTS ( - SELECT 1 - FROM information_schema.columns - WHERE table_schema = 'texera_db' AND table_name = 'user' AND column_name = 'comment' - ) THEN -ALTER TABLE "user" - ADD COLUMN comment TEXT; -END IF; -END -$$; diff --git a/sql/updates/06.sql b/sql/updates/06.sql deleted file mode 100644 index 47d30bab7bd..00000000000 --- a/sql/updates/06.sql +++ /dev/null @@ -1,62 +0,0 @@ --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, --- software distributed under the License is distributed on an --- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --- KIND, either express or implied. See the License for the --- specific language governing permissions and limitations --- under the License. - -\c texera_db - -SET search_path TO texera_db; - -DO $$ -BEGIN - IF NOT EXISTS ( - SELECT 1 FROM information_schema.columns - WHERE table_schema = 'texera_db' - AND table_name = 'workflow_executions' - AND column_name = 'runtime_stats_size' - ) THEN - ALTER TABLE workflow_executions - ADD COLUMN runtime_stats_size INT DEFAULT 0; - END IF; -END -$$; - -DO $$ -BEGIN - IF NOT EXISTS ( - SELECT 1 FROM information_schema.columns - WHERE table_schema = 'texera_db' - AND table_name = 'operator_executions' - AND column_name = 'console_messages_size' - ) THEN - ALTER TABLE operator_executions - ADD COLUMN console_messages_size INT DEFAULT 0; - END IF; -END -$$; - -DO $$ -BEGIN - IF NOT EXISTS ( - SELECT 1 FROM information_schema.columns - WHERE table_schema = 'texera_db' - AND table_name = 'operator_port_executions' - AND column_name = 'result_size' - ) THEN - ALTER TABLE operator_port_executions - ADD COLUMN result_size INT DEFAULT 0; - END IF; -END -$$; diff --git a/sql/updates/07.sql b/sql/updates/07.sql deleted file mode 100644 index a56ff5c5330..00000000000 --- a/sql/updates/07.sql +++ /dev/null @@ -1,77 +0,0 @@ --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, --- software distributed under the License is distributed on an --- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --- KIND, either express or implied. See the License for the --- specific language governing permissions and limitations --- under the License. - -\c texera_db - -SET search_path TO texera_db; - -DO $$ -BEGIN - -- 1. Add cuid field to workflow_executions if not exist - IF NOT EXISTS ( - SELECT 1 - FROM information_schema.columns - WHERE table_schema = 'texera_db' AND table_name = 'workflow_executions' AND column_name = 'cuid' - ) THEN -ALTER TABLE workflow_executions - ADD COLUMN cuid INT; - -ALTER TABLE workflow_executions - ADD CONSTRAINT workflow_executions_cuid_fkey - FOREIGN KEY (cuid) REFERENCES workflow_computing_unit(cuid) ON DELETE CASCADE; -END IF; - - -- 2. Add ENUM type for workflow_computing_unit.type -IF NOT EXISTS ( - SELECT 1 - FROM pg_type - WHERE typname = 'workflow_computing_unit_type_enum' - ) THEN - CREATE TYPE workflow_computing_unit_type_enum AS ENUM ('local', 'kubernetes'); -END IF; - - -- 3. Add type column to workflow_computing_unit if not exist -IF NOT EXISTS ( - SELECT 1 - FROM information_schema.columns - WHERE table_schema = 'texera_db' AND table_name = 'workflow_computing_unit' AND column_name = 'type' - ) THEN -ALTER TABLE workflow_computing_unit - ADD COLUMN type workflow_computing_unit_type_enum; -END IF; - - -- 4. Add uri column to workflow_computing_unit if not exist -IF NOT EXISTS ( - SELECT 1 - FROM information_schema.columns - WHERE table_schema = 'texera_db' AND table_name = 'workflow_computing_unit' AND column_name = 'uri' - ) THEN -ALTER TABLE workflow_computing_unit - ADD COLUMN uri TEXT NOT NULL DEFAULT ''; -END IF; - - -- 5. Add resource column to workflow_computing_unit if not exist -IF NOT EXISTS ( - SELECT 1 - FROM information_schema.columns - WHERE table_schema = 'texera_db' AND table_name = 'workflow_computing_unit' AND column_name = 'resource' - ) THEN -ALTER TABLE workflow_computing_unit - ADD COLUMN resource TEXT DEFAULT ''; -END IF; -END -$$; \ No newline at end of file diff --git a/sql/updates/08.sql b/sql/updates/08.sql deleted file mode 100644 index d7a4639440b..00000000000 --- a/sql/updates/08.sql +++ /dev/null @@ -1,39 +0,0 @@ --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, --- software distributed under the License is distributed on an --- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --- KIND, either express or implied. See the License for the --- specific language governing permissions and limitations --- under the License. - -\c texera_db - -SET search_path TO texera_db; - -DO $$ -BEGIN - -- 1. Create site_settings table if it does not exist - IF NOT EXISTS ( - SELECT 1 - FROM information_schema.tables - WHERE table_schema = 'texera_db' AND table_name = 'site_settings' - ) THEN -CREATE TABLE site_settings -( - key VARCHAR(255) PRIMARY KEY, - value TEXT NOT NULL, - updated_by VARCHAR(50), - updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP -); -END IF; -END -$$; \ No newline at end of file diff --git a/sql/updates/09.sql b/sql/updates/09.sql deleted file mode 100644 index 74427af79ea..00000000000 --- a/sql/updates/09.sql +++ /dev/null @@ -1,30 +0,0 @@ --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, --- software distributed under the License is distributed on an --- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --- KIND, either express or implied. See the License for the --- specific language governing permissions and limitations --- under the License. - -\c texera_db - -SET search_path TO texera_db; - -CREATE TABLE IF NOT EXISTS computing_unit_user_access -( - cuid INT NOT NULL, - uid INT NOT NULL, - privilege privilege_enum NOT NULL DEFAULT 'NONE', - PRIMARY KEY (cuid, uid), - FOREIGN KEY (cuid) REFERENCES workflow_computing_unit(cuid) ON DELETE CASCADE, - FOREIGN KEY (uid) REFERENCES "user"(uid) ON DELETE CASCADE -); \ No newline at end of file diff --git a/sql/updates/10.sql b/sql/updates/10.sql deleted file mode 100644 index c449cb3cd22..00000000000 --- a/sql/updates/10.sql +++ /dev/null @@ -1,30 +0,0 @@ --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, --- software distributed under the License is distributed on an --- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --- KIND, either express or implied. See the License for the --- specific language governing permissions and limitations --- under the License. - -\c texera_db - -SET search_path TO texera_db; - -BEGIN; -CREATE TABLE time_log -( - uid INT NOT NULL - PRIMARY KEY - REFERENCES "user"(uid), - last_login TIMESTAMPTZ -); -COMMIT; \ No newline at end of file diff --git a/sql/updates/11.sql b/sql/updates/11.sql deleted file mode 100644 index 01798b97153..00000000000 --- a/sql/updates/11.sql +++ /dev/null @@ -1,28 +0,0 @@ --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, --- software distributed under the License is distributed on an --- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --- KIND, either express or implied. See the License for the --- specific language governing permissions and limitations --- under the License. - -\c texera_db - -SET search_path TO texera_db; - -BEGIN; --- Add downloadable field to dataset table -ALTER TABLE dataset ADD COLUMN IF NOT EXISTS is_downloadable BOOLEAN NOT NULL DEFAULT TRUE; - --- Update existing datasets: downloadable can only be true if dataset is public -UPDATE dataset SET is_downloadable = is_public WHERE is_downloadable != is_public; -COMMIT; \ No newline at end of file diff --git a/sql/updates/12.sql b/sql/updates/12.sql deleted file mode 100644 index 8c9afd2a8d6..00000000000 --- a/sql/updates/12.sql +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -\c texera_db -SET search_path TO texera_db; - -BEGIN; -ALTER TABLE time_log RENAME TO user_last_active_time; - -ALTER TABLE user_last_active_time RENAME COLUMN last_login TO last_active_time; -COMMIT; \ No newline at end of file diff --git a/sql/updates/13.sql b/sql/updates/13.sql deleted file mode 100644 index a66377e58e6..00000000000 --- a/sql/updates/13.sql +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -\c texera_db -SET search_path TO texera_db; - -BEGIN; - --- Rename the old table to migrate later -ALTER TABLE user_activity RENAME TO user_action_old; - --- Validate existing values for "activate" -DO $do$ - BEGIN - IF EXISTS ( - SELECT 1 FROM user_action_old - WHERE lower(activate) NOT IN ('like','unlike','clone','view') - ) THEN - RAISE EXCEPTION 'Error.'; - END IF; - END -$do$; - --- Create enum type -DO $do$ - BEGIN - IF NOT EXISTS ( - SELECT 1 - FROM pg_type t - JOIN pg_namespace n ON n.oid = t.typnamespace - WHERE t.typname = 'action_enum' AND n.nspname = 'texera_db' - ) THEN - EXECUTE 'CREATE TYPE texera_db.action_enum AS ENUM (''like'',''unlike'',''clone'',''view'')'; - END IF; - END -$do$; - --- Create the new table -CREATE TABLE user_action ( - user_action_id BIGSERIAL PRIMARY KEY, - uid INTEGER, - ip VARCHAR(15), - action_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, - resource_type VARCHAR(15) NOT NULL, - resource_id INTEGER NOT NULL, - action texera_db.action_enum NOT NULL -); - --- Copy data -INSERT INTO user_action (uid, ip, action_time, resource_type, resource_id, action) -SELECT - CASE WHEN ua.uid = 0 OR u.uid IS NULL THEN NULL ELSE ua.uid END AS uid, - ua.ip, - ua.activity_time AS action_time, - ua."type" AS resource_type, - ua.id AS resource_id, - lower(ua.activate)::texera_db.action_enum AS action -FROM user_action_old ua - LEFT JOIN "user" u ON u.uid = ua.uid; - --- Add FK -ALTER TABLE user_action - ADD CONSTRAINT fk_user_action_uid - FOREIGN KEY (uid) REFERENCES "user"(uid) ON DELETE SET NULL; - --- Drop the old table -DROP TABLE user_action_old; - -COMMIT; diff --git a/sql/updates/14.sql b/sql/updates/14.sql deleted file mode 100644 index 25092ef842e..00000000000 --- a/sql/updates/14.sql +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -\c texera_db -SET search_path TO texera_db; - -BEGIN; - -ALTER TABLE "user" - ADD COLUMN IF NOT EXISTS account_creation_time TIMESTAMPTZ; - -WITH ts AS ( - SELECT '2025-01-01 00:00:00-00'::timestamptz AS t -) - -UPDATE "user" u -SET account_creation_time = ts.t -FROM ts -WHERE u.account_creation_time IS NULL; - -ALTER TABLE "user" - ALTER COLUMN account_creation_time SET NOT NULL, - ALTER COLUMN account_creation_time SET DEFAULT now(); - -COMMIT; \ No newline at end of file diff --git a/sql/updates/15.sql b/sql/updates/15.sql deleted file mode 100644 index fa1959d984b..00000000000 --- a/sql/updates/15.sql +++ /dev/null @@ -1,38 +0,0 @@ --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, --- software distributed under the License is distributed on an --- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --- KIND, either express or implied. See the License for the --- specific language governing permissions and limitations --- under the License. - --- ============================================ --- 1. Connect to the texera_db database --- ============================================ -\c texera_db - -SET search_path TO texera_db; - --- ============================================ --- 2. Update the table schema --- ============================================ -BEGIN; - --- 1. Add new column repository_name to dataset table. -ALTER TABLE dataset - ADD COLUMN repository_name varchar(128); - --- 2. Copy the data from name column to repository_name column. -UPDATE dataset -SET repository_name = name; - -COMMIT; diff --git a/sql/updates/16.sql b/sql/updates/16.sql deleted file mode 100644 index 8776415c466..00000000000 --- a/sql/updates/16.sql +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -\c texera_db - -SET search_path TO texera_db; - -BEGIN; - -ALTER TABLE "user" - ADD COLUMN IF NOT EXISTS affiliation VARCHAR(128); - -COMMIT; diff --git a/sql/updates/17.sql b/sql/updates/17.sql deleted file mode 100644 index 9436c405286..00000000000 --- a/sql/updates/17.sql +++ /dev/null @@ -1,66 +0,0 @@ --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, --- software distributed under the License is distributed on an --- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --- KIND, either express or implied. See the License for the --- specific language governing permissions and limitations --- under the License. - --- ============================================ --- 1. Connect to the texera_db database --- ============================================ -\c texera_db - -SET search_path TO texera_db; - --- ============================================ --- 2. Update the table schema --- ============================================ -BEGIN; - --- 1. Drop old tables (if exist) -DROP TABLE IF EXISTS dataset_upload_session CASCADE; -DROP TABLE IF EXISTS dataset_upload_session_part CASCADE; - --- 2. Create dataset upload session table -CREATE TABLE IF NOT EXISTS dataset_upload_session -( - did INT NOT NULL, - uid INT NOT NULL, - file_path TEXT NOT NULL, - upload_id VARCHAR(256) NOT NULL UNIQUE, - physical_address TEXT, - num_parts_requested INT NOT NULL, - - PRIMARY KEY (uid, did, file_path), - - FOREIGN KEY (did) REFERENCES dataset(did) ON DELETE CASCADE, - FOREIGN KEY (uid) REFERENCES "user"(uid) ON DELETE CASCADE - ); - --- 3. Create dataset upload session parts table -CREATE TABLE IF NOT EXISTS dataset_upload_session_part -( - upload_id VARCHAR(256) NOT NULL, - part_number INT NOT NULL, - etag TEXT NOT NULL DEFAULT '', - - PRIMARY KEY (upload_id, part_number), - - CONSTRAINT chk_part_number_positive CHECK (part_number > 0), - - FOREIGN KEY (upload_id) - REFERENCES dataset_upload_session(upload_id) - ON DELETE CASCADE - ); - -COMMIT; diff --git a/sql/updates/18.sql b/sql/updates/18.sql deleted file mode 100644 index 501bbae8e55..00000000000 --- a/sql/updates/18.sql +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -\c texera_db - -SET search_path TO texera_db; - -BEGIN; - --- 1. Add new column cover_image to dataset table. -ALTER TABLE dataset - ADD COLUMN cover_image varchar(246); - -COMMIT; diff --git a/sql/updates/19.sql b/sql/updates/19.sql deleted file mode 100644 index 92d2f998c74..00000000000 --- a/sql/updates/19.sql +++ /dev/null @@ -1,60 +0,0 @@ --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, --- software distributed under the License is distributed on an --- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --- KIND, either express or implied. See the License for the --- specific language governing permissions and limitations --- under the License. - --- ============================================ --- 1. Connect to the texera_db database --- ============================================ -\c texera_db -SET search_path TO texera_db, public; - --- ============================================ --- 2. Update the table schema --- ============================================ -BEGIN; - --- Add the 2 columns (defaults backfill existing rows safely) -ALTER TABLE dataset_upload_session - ADD COLUMN IF NOT EXISTS file_size_bytes BIGINT NOT NULL DEFAULT 1, - ADD COLUMN IF NOT EXISTS part_size_bytes BIGINT NOT NULL DEFAULT 5242880; - --- Drop any old/alternate constraint names from previous attempts (so we end up with exactly the new names) -ALTER TABLE dataset_upload_session - DROP CONSTRAINT IF EXISTS dataset_upload_session_num_parts_requested_positive, - DROP CONSTRAINT IF EXISTS chk_dataset_upload_session_num_parts_requested_positive, - DROP CONSTRAINT IF EXISTS chk_dataset_upload_session_file_size_bytes_positive, - DROP CONSTRAINT IF EXISTS chk_dataset_upload_session_part_size_bytes_positive, - DROP CONSTRAINT IF EXISTS dataset_upload_session_part_size_bytes_positive, - DROP CONSTRAINT IF EXISTS dataset_upload_session_part_size_bytes_s3_upper_bound, - DROP CONSTRAINT IF EXISTS chk_dataset_upload_session_part_size_bytes_s3_upper_bound; - --- Add constraints exactly like the new CREATE TABLE -ALTER TABLE dataset_upload_session - ADD CONSTRAINT chk_dataset_upload_session_num_parts_requested_positive - CHECK (num_parts_requested >= 1), - ADD CONSTRAINT chk_dataset_upload_session_file_size_bytes_positive - CHECK (file_size_bytes > 0), - ADD CONSTRAINT chk_dataset_upload_session_part_size_bytes_positive - CHECK (part_size_bytes > 0), - ADD CONSTRAINT chk_dataset_upload_session_part_size_bytes_s3_upper_bound - CHECK (part_size_bytes <= 5368709120); - --- Match CREATE TABLE (no defaults) -ALTER TABLE dataset_upload_session - ALTER COLUMN file_size_bytes DROP DEFAULT, - ALTER COLUMN part_size_bytes DROP DEFAULT; - -COMMIT; diff --git a/sql/updates/20.sql b/sql/updates/20.sql deleted file mode 100644 index 058abb1d48a..00000000000 --- a/sql/updates/20.sql +++ /dev/null @@ -1,37 +0,0 @@ --- Licensed to the Apache Software Foundation (ASF) under one --- or more contributor license agreements. See the NOTICE file --- distributed with this work for additional information --- regarding copyright ownership. The ASF licenses this file --- to you under the Apache License, Version 2.0 (the --- "License"); you may not use this file except in compliance --- with the License. You may obtain a copy of the License at --- --- http://www.apache.org/licenses/LICENSE-2.0 --- --- Unless required by applicable law or agreed to in writing, --- software distributed under the License is distributed on an --- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --- KIND, either express or implied. See the License for the --- specific language governing permissions and limitations --- under the License. - --- ============================================ --- 1. Connect to the texera_db database --- ============================================ -\c texera_db -SET search_path TO texera_db, public; - -BEGIN; - --- Step 1: Add the column (no default yet) -ALTER TABLE dataset_upload_session - ADD COLUMN IF NOT EXISTS created_at TIMESTAMPTZ; - --- Step 2: Add the default for future inserts -ALTER TABLE dataset_upload_session - ALTER COLUMN created_at SET DEFAULT now(); - -ALTER TABLE dataset_upload_session - ALTER COLUMN created_at SET NOT NULL; - -COMMIT; diff --git a/sql/updates/21.sql b/sql/updates/21.sql deleted file mode 100644 index 4a140d9a128..00000000000 --- a/sql/updates/21.sql +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -\c texera_db - -SET search_path TO texera_db; - -BEGIN; - -ALTER TABLE "user" - ADD COLUMN IF NOT EXISTS joining_reason VARCHAR(500); - -COMMIT; diff --git a/sql/updates/22.sql b/sql/updates/22.sql deleted file mode 100644 index a04eb022c71..00000000000 --- a/sql/updates/22.sql +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -\c texera_db - -SET search_path TO texera_db; - -BEGIN; - --- Change description column from VARCHAR to TEXT to support Markdown content. -ALTER TABLE dataset -ALTER COLUMN description TYPE TEXT; - -ALTER TABLE workflow -ALTER COLUMN description TYPE TEXT; - -COMMIT; From d2c09bd61d547f1aebf04ebe9cbd4c5e694e4d5c Mon Sep 17 00:00:00 2001 From: Xinyuan Lin Date: Fri, 28 Aug 2026 23:35:58 -0700 Subject: [PATCH 2/5] feat(sql): leave a recovery breadcrumb where 01-22 stood Review asked that the retired manual-upgrade scripts stay reachable rather than only implicitly recoverable. Adds sql/updates/README.md: what the directory is, why 01-22 were never enrolled in the Liquibase chain, and the exact git commands to read or reassemble them. The breadcrumb has to be a non-.sql file inside sql/updates/, which the DDL-change notification workflow would otherwise pick up as an added migration -- it globbed the whole directory -- and mail dev@ an instruction to apply a README to Postgres. Narrow that diff to '*.sql' and skip the send when nothing was added, which also silences the empty-filename mail this deletion-only PR would have triggered on its own. --- .../automatic-email-notif-on-ddl-change.yml | 6 +- sql/updates/README.md | 55 +++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 sql/updates/README.md diff --git a/.github/workflows/automatic-email-notif-on-ddl-change.yml b/.github/workflows/automatic-email-notif-on-ddl-change.yml index 5190cd63061..3e839c268d2 100644 --- a/.github/workflows/automatic-email-notif-on-ddl-change.yml +++ b/.github/workflows/automatic-email-notif-on-ddl-change.yml @@ -40,9 +40,13 @@ jobs: FILE=$(git diff --name-only --diff-filter=A \ ${{ github.event.pull_request.base.sha }} \ ${{ github.event.pull_request.merge_commit_sha }} \ - -- 'sql/updates/') + -- 'sql/updates/*.sql') echo "sql_file=$FILE" >> $GITHUB_OUTPUT + # A ddl-change PR that adds no migration -- it only edits or deletes + # files under sql/updates/ -- leaves operators nothing to apply, so it + # must not mail out an instruction naming an empty file. - name: Send email + if: steps.get_sql_file.outputs.sql_file != '' run: | curl --ssl-reqd \ --url "smtps://smtp.gmail.com:465" \ diff --git a/sql/updates/README.md b/sql/updates/README.md new file mode 100644 index 00000000000..0de32a54d8d --- /dev/null +++ b/sql/updates/README.md @@ -0,0 +1,55 @@ + + +# `sql/updates/` + +One file per schema migration. A file is live only when +[`sql/changelog.xml`](../changelog.xml) references it as a Liquibase +changeSet — the directory itself is never globbed for work to do, so an +unreferenced file here is inert. + +## The retired scripts, `01.sql`–`22.sql` + +They are not in the working tree; they are in git history. + +These 22 predate Liquibase. Operators applied them by hand, prompted by the +DDL-change notification e-mail. Liquibase arrived with +[#4401](https://github.com/apache/texera/pull/4401), which started the chain +fresh at `23.sql` and enrolled none of the 22 — so no runner in the repository +has been able to execute them since. They are also why the live files are +unpadded: the retired set is `01.sql`, the current set `23.sql`. + +Only an operator whose database was created before changeset 23 would need +them. Any database past that point applied them long ago, and a fresh one is +bootstrapped from [`sql/texera_ddl.sql`](../texera_ddl.sql), which already has +the post-migration shape. + +To read one, or to reassemble the whole set, from any commit that precedes the +removal — `363537e` is one: + +```bash +git show 363537e:sql/updates/07.sql +for n in $(seq -w 1 22); do git show "363537e:sql/updates/$n.sql"; done > 01-22.sql +``` + +To locate the removal itself: + +```bash +git log --diff-filter=D -- sql/updates/01.sql +``` From 3cc6743fa98ae9b3c6e7af66e7835337c697bdb8 Mon Sep 17 00:00:00 2001 From: Xinyuan Lin Date: Mon, 31 Aug 2026 05:55:26 -0700 Subject: [PATCH 3/5] fix(ci): join multi-migration paths before writing $GITHUB_OUTPUT git diff --name-only prints one path per line, so a ddl-change PR that adds two migrations wrote a bare second line into $GITHUB_OUTPUT -- no key=, which makes the runner reject the whole file and fail the step, sending no notification at all. Join on ", " so the value stays one line. Pre-existing; this PR narrowed the pathspec, which makes it less likely rather than more. Matches the normalize-before-write pattern already in benchmarks-pr-comment.yml. --- .github/workflows/automatic-email-notif-on-ddl-change.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/automatic-email-notif-on-ddl-change.yml b/.github/workflows/automatic-email-notif-on-ddl-change.yml index 3e839c268d2..34d746f6698 100644 --- a/.github/workflows/automatic-email-notif-on-ddl-change.yml +++ b/.github/workflows/automatic-email-notif-on-ddl-change.yml @@ -41,7 +41,10 @@ jobs: ${{ github.event.pull_request.base.sha }} \ ${{ github.event.pull_request.merge_commit_sha }} \ -- 'sql/updates/*.sql') - echo "sql_file=$FILE" >> $GITHUB_OUTPUT + # git diff prints one path per line, so a PR adding two migrations + # would put a bare second line in $GITHUB_OUTPUT -- no key=, which + # makes the runner reject the whole file and the step fail. + echo "sql_file=${FILE//$'\n'/, }" >> $GITHUB_OUTPUT # A ddl-change PR that adds no migration -- it only edits or deletes # files under sql/updates/ -- leaves operators nothing to apply, so it # must not mail out an instruction naming an empty file. From 16aaa2caccde4fd1b0ea778522df8290a6d9c0e6 Mon Sep 17 00:00:00 2001 From: Xinyuan Lin Date: Mon, 31 Aug 2026 09:04:46 -0700 Subject: [PATCH 4/5] docs(ci): name the case the *.sql pathspec exists for The aside listed edits and deletes but not the case that made the guard necessary: this PR adds sql/updates/README.md, which is neither. A ddl-change PR can also touch no sql/updates/ file at all, since the labeler applies the label to any **/*.sql in the repo. --- .github/workflows/automatic-email-notif-on-ddl-change.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/automatic-email-notif-on-ddl-change.yml b/.github/workflows/automatic-email-notif-on-ddl-change.yml index 34d746f6698..9c103a6bcab 100644 --- a/.github/workflows/automatic-email-notif-on-ddl-change.yml +++ b/.github/workflows/automatic-email-notif-on-ddl-change.yml @@ -45,9 +45,10 @@ jobs: # would put a bare second line in $GITHUB_OUTPUT -- no key=, which # makes the runner reject the whole file and the step fail. echo "sql_file=${FILE//$'\n'/, }" >> $GITHUB_OUTPUT - # A ddl-change PR that adds no migration -- it only edits or deletes - # files under sql/updates/ -- leaves operators nothing to apply, so it - # must not mail out an instruction naming an empty file. + # A ddl-change PR need not add a migration: it may edit or delete files + # under sql/updates/, add a non-.sql file such as this README, or touch + # a .sql file elsewhere in the repo. Any of those leaves operators + # nothing to apply, so no instruction goes out. - name: Send email if: steps.get_sql_file.outputs.sql_file != '' run: | From 1fbd85616ecd483f7c5daec20ae39e9c2a2f6290 Mon Sep 17 00:00:00 2001 From: Xinyuan Lin Date: Mon, 31 Aug 2026 10:54:25 -0700 Subject: [PATCH 5/5] docs(sql): drop an unfalsifiable padding claim from the breadcrumb The pair 01.sql / 23.sql shows nothing about padding: 01 is the padded name and 23 needs no padding, and every live file is 23-42, all two digits, so whether the convention pads is unobservable. What the paragraph establishes is the numbering restart, so say that instead. --- sql/updates/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/updates/README.md b/sql/updates/README.md index 0de32a54d8d..644a7a18f08 100644 --- a/sql/updates/README.md +++ b/sql/updates/README.md @@ -32,8 +32,8 @@ These 22 predate Liquibase. Operators applied them by hand, prompted by the DDL-change notification e-mail. Liquibase arrived with [#4401](https://github.com/apache/texera/pull/4401), which started the chain fresh at `23.sql` and enrolled none of the 22 — so no runner in the repository -has been able to execute them since. They are also why the live files are -unpadded: the retired set is `01.sql`, the current set `23.sql`. +has been able to execute them since. They are also why the live numbering +starts at `23.sql` rather than `01.sql`. Only an operator whose database was created before changeset 23 would need them. Any database past that point applied them long ago, and a fresh one is