Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sql/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down
24 changes: 24 additions & 0 deletions sql/texera_ddl.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down
56 changes: 56 additions & 0 deletions sql/updates/23.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* 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. 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;
Loading