From e60310e4423724ec4b1c4125a761fa38f180532a Mon Sep 17 00:00:00 2001 From: Ryan Zhang Date: Wed, 13 May 2026 12:06:50 -0700 Subject: [PATCH 1/3] added notebook and workflow_notebook_mapping tables --- sql/texera_ddl.sql | 24 +++++++++++++++++++ sql/updates/23.sql | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 sql/updates/23.sql diff --git a/sql/texera_ddl.sql b/sql/texera_ddl.sql index d6b488e582d..b59e04d481a 100644 --- a/sql/texera_ddl.sql +++ b/sql/texera_ddl.sql @@ -74,6 +74,8 @@ DROP TABLE IF EXISTS dataset_user_likes CASCADE; DROP TABLE IF EXISTS dataset_view_count CASCADE; DROP TABLE IF EXISTS site_settings CASCADE; DROP TABLE IF EXISTS computing_unit_user_access CASCADE; +DROP TABLE IF EXISTS notebook CASCADE; +DROP TABLE IF EXISTS workflow_notebook_mapping CASCADE; -- ============================================ -- 4. Create PostgreSQL enum types @@ -435,6 +437,28 @@ CREATE TABLE IF NOT EXISTS computing_unit_user_access FOREIGN KEY (uid) REFERENCES "user"(uid) ON DELETE CASCADE ); +-- notebook table +CREATE TABLE IF NOT EXISTS notebook +( + nid SERIAL NOT NULL PRIMARY KEY, + wid INT NOT NULL, + notebook JSONB NOT NULL, + FOREIGN KEY (wid) REFERENCES workflow(wid) ON DELETE CASCADE +); + +-- workflow_notebook_mapping table +CREATE TABLE IF NOT EXISTS workflow_notebook_mapping +( + wid INT NOT NULL, + vid INT NOT NULL, + nid INT NOT NULL, + mapping JSONB NOT NULL, + PRIMARY KEY (wid, vid, nid), + FOREIGN KEY (wid) REFERENCES workflow(wid) ON DELETE CASCADE, + FOREIGN KEY (vid) REFERENCES workflow_version(vid) ON DELETE CASCADE, + FOREIGN KEY (nid) REFERENCES notebook(nid) ON DELETE CASCADE +); + -- START Fulltext search index creation (DO NOT EDIT THIS LINE) CREATE EXTENSION IF NOT EXISTS pgroonga; diff --git a/sql/updates/23.sql b/sql/updates/23.sql new file mode 100644 index 00000000000..1741ea4457a --- /dev/null +++ b/sql/updates/23.sql @@ -0,0 +1,58 @@ +/* + * 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. Delete tables if they already exist +-- ============================================ + +BEGIN; + +DROP TABLE IF EXISTS notebook CASCADE; +DROP TABLE IF EXISTS workflow_notebook_mapping CASCADE; + +-- ============================================ +-- 3. Create the tables to store notebook and mapping +-- ============================================ + +CREATE TABLE notebook ( + nid SERIAL NOT NULL PRIMARY KEY, + wid INT NOT NULL, + notebook JSONB NOT NULL, + FOREIGN KEY (wid) REFERENCES workflow(wid) ON DELETE CASCADE +); + +CREATE TABLE workflow_notebook_mapping ( + wid INT NOT NULL, + vid INT NOT NULL, + nid INT NOT NULL, + mapping JSONB NOT NULL, + PRIMARY KEY (wid, vid, nid), + FOREIGN KEY (wid) REFERENCES workflow(wid) ON DELETE CASCADE, + FOREIGN KEY (vid) REFERENCES workflow_version(vid) ON DELETE CASCADE, + FOREIGN KEY (nid) REFERENCES notebook(nid) ON DELETE CASCADE +); + +COMMIT; \ No newline at end of file From 9c63915d0c3883ab9a281afe6377df092d139669 Mon Sep 17 00:00:00 2001 From: Ryan Zhang Date: Mon, 18 May 2026 14:26:47 -0700 Subject: [PATCH 2/3] removed "\c texera_db" in sql file and added changeSet element in accordance with PR #4401 --- sql/changelog.xml | 5 +++++ sql/updates/23.sql | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sql/changelog.xml b/sql/changelog.xml index 7e6bd1606a1..a550c20943e 100644 --- a/sql/changelog.xml +++ b/sql/changelog.xml @@ -24,6 +24,11 @@ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.9.xsd"> + + + + + - + diff --git a/sql/updates/23.sql b/sql/updates/23.sql index 10ad8f3c5a0..db7ff437e88 100644 --- a/sql/updates/23.sql +++ b/sql/updates/23.sql @@ -53,4 +53,4 @@ CREATE TABLE workflow_notebook_mapping ( FOREIGN KEY (nid) REFERENCES notebook(nid) ON DELETE CASCADE ); -COMMIT; \ No newline at end of file +COMMIT;