This is an automated email from the ASF dual-hosted git repository. github-merge-queue[bot] pushed a commit to branch gh-readonly-queue/main/pr-5055-7deed35fddf58bc910991af920f0cf4d16c46f9b in repository https://gitbox.apache.org/repos/asf/texera.git
commit 04ed22f58720e3b9f756522e0058577bc6424885 Author: Ryan Zhang <[email protected]> AuthorDate: Fri Jun 5 02:46:57 2026 -0700 feat(python-notebook-migration): add database tables for Notebook Migration tool (#5055) <!-- Thanks for sending a pull request (PR)! Here are some tips for you: 1. If this is your first time, please read our contributor guidelines: [Contributing to Texera](https://github.com/apache/texera/blob/main/CONTRIBUTING.md) 2. Ensure you have added or run the appropriate tests for your PR 3. If the PR is work in progress, mark it a draft on GitHub. 4. Please write your PR title to summarize what this PR proposes, we are following Conventional Commits style for PR titles as well. 5. Be sure to keep the PR description updated to reflect all changes. --> ### What changes were proposed in this PR? <!-- Please clarify what changes you are proposing. The purpose of this section is to outline the changes. Here are some tips for you: 1. If you propose a new API, clarify the use case for a new API. 2. If you fix a bug, you can clarify why it is a bug. 3. If it is a refactoring, clarify what has been changed. 3. It would be helpful to include a before-and-after comparison using screenshots or GIFs. 4. Please consider writing useful notes for better and faster reviews. --> This PR adds two new tables to the database, `notebook` and `workflow_notebook_mapping`. These tables will be used in the new Python Notebook Migration tool to store the user-uploaded notebook and the generated mapping between the notebook and workflow. ### Any related issues, documentation, discussions? <!-- Please use this section to link other resources if not mentioned already. 1. If this PR fixes an issue, please include `Fixes #1234`, `Resolves #1234` or `Closes #1234`. If it is only related, simply mention the issue number. 2. If there is design documentation, please add the link. 3. If there is a discussion in the mailing list, please add the link. --> Closes #5054 The parent issue is #4301 #### Schema <img width="1580" height="838" alt="image" src="https://github.com/user-attachments/assets/33896320-56c5-45d6-bbd4-6d74fc365a49" /> ### How was this PR tested? <!-- If tests were added, say they were added here. Or simply mention that if the PR is tested with existing test cases. Make sure to include/update test cases that check the changes thoroughly including negative and positive cases if possible. If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future. If tests were not added, please describe why they were not added and/or why it was difficult to add. --> New tables were manually confirmed to be created successfully and usable. ### Was this PR authored or co-authored using generative AI tooling? <!-- If generative AI tooling has been used in the process of authoring this PR, please include the phrase: 'Generated-by: ' followed by the name of the tool and its version. If no, write 'No'. Please refer to the [ASF Generative Tooling Guidance](https://www.apache.org/legal/generative-tooling.html) for details. --> No --------- Co-authored-by: Meng Wang <[email protected]> --- sql/changelog.xml | 5 +++++ sql/texera_ddl.sql | 24 ++++++++++++++++++++++++ sql/updates/23.sql | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) diff --git a/sql/changelog.xml b/sql/changelog.xml index 7e6bd1606a..4825321b20 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"> + <!-- Add notebook and workflow_notebook_mapping tables --> + <changeSet id="23" author="zyratlo"> + <sqlFile path="sql/updates/23.sql"/> + </changeSet> + <!-- example changeSet <changeSet id="1" author="author"> <sqlFile path="sql/updates/1.sql"/> diff --git a/sql/texera_ddl.sql b/sql/texera_ddl.sql index d6b488e582..83ed0abb50 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 UNIQUE, + notebook JSONB NOT NULL, + UNIQUE (wid, nid), + 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 (vid) REFERENCES workflow_version(vid) ON DELETE CASCADE, + FOREIGN KEY (wid, nid) REFERENCES notebook(wid, 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 0000000000..537e96a337 --- /dev/null +++ b/sql/updates/23.sql @@ -0,0 +1,51 @@ +/* + * 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 +-- ============================================ +SET search_path TO texera_db; + +-- ============================================ +-- 2. Create the tables to store notebook and mapping +-- ============================================ + +BEGIN; + +CREATE TABLE IF NOT EXISTS notebook +( + nid SERIAL NOT NULL PRIMARY KEY, + wid INT NOT NULL UNIQUE, + notebook JSONB NOT NULL, + UNIQUE (wid, nid), + FOREIGN KEY (wid) REFERENCES workflow(wid) ON DELETE CASCADE +); + +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 (vid) REFERENCES workflow_version(vid) ON DELETE CASCADE, + FOREIGN KEY (wid, nid) REFERENCES notebook(wid, nid) ON DELETE CASCADE +); + +COMMIT;
