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;