summaryrefslogtreecommitdiffstats
path: root/cps-ri/src/main/resources
diff options
context:
space:
mode:
authorRuslan Kashapov <ruslan.kashapov@pantheon.tech>2021-01-11 16:44:32 +0200
committerRishi Chail <rishi.chail@est.tech>2021-01-13 10:18:31 +0000
commit49fe075361e4f0f3b2a1a561bc01f831983a3efb (patch)
treea4cd3e36428f0d3d922e01c22700344088dd4bd2 /cps-ri/src/main/resources
parenta6c59f024092ac339d851a372aa6deae36de622d (diff)
Decouple anchor from fragment in persistence module
Issue-ID: CPS-161 Change-Id: Ia446b26ee4eca9281e86bd2be3dd6836aa201597 Signed-off-by: Ruslan Kashapov <ruslan.kashapov@pantheon.tech>
Diffstat (limited to 'cps-ri/src/main/resources')
-rwxr-xr-xcps-ri/src/main/resources/schema.sql17
1 files changed, 12 insertions, 5 deletions
diff --git a/cps-ri/src/main/resources/schema.sql b/cps-ri/src/main/resources/schema.sql
index 58b3c63c82..d37d932aad 100755
--- a/cps-ri/src/main/resources/schema.sql
+++ b/cps-ri/src/main/resources/schema.sql
@@ -53,18 +53,25 @@ CREATE TABLE IF NOT EXISTS MODULE
CONSTRAINT MODULE_DATASPACE FOREIGN KEY (DATASPACE_ID) REFERENCES DATASPACE (id) ON UPDATE CASCADE ON DELETE CASCADE
);
+CREATE TABLE IF NOT EXISTS ANCHOR
+(
+ ID BIGSERIAL PRIMARY KEY,
+ NAME TEXT,
+ SCHEMA_SET_ID INTEGER REFERENCES SCHEMA_SET(ID),
+ DATASPACE_ID INTEGER NOT NULL REFERENCES DATASPACE(ID),
+ UNIQUE (DATASPACE_ID, NAME)
+);
+
CREATE TABLE IF NOT EXISTS FRAGMENT
(
ID BIGSERIAL PRIMARY KEY,
XPATH TEXT NOT NULL,
ATTRIBUTES JSONB,
- ANCHOR_NAME TEXT,
- ANCHOR_ID BIGINT REFERENCES FRAGMENT(ID),
+ ANCHOR_ID BIGINT REFERENCES ANCHOR(ID),
PARENT_ID BIGINT REFERENCES FRAGMENT(ID),
- SCHEMA_SET_ID INTEGER REFERENCES SCHEMA_SET(ID),
DATASPACE_ID INTEGER NOT NULL REFERENCES DATASPACE(ID),
SCHEMA_NODE_ID INTEGER REFERENCES SCHEMA_NODE(ID),
- UNIQUE (DATASPACE_ID, ANCHOR_NAME, XPATH)
+ UNIQUE (DATASPACE_ID, ANCHOR_ID, XPATH)
);
CREATE TABLE IF NOT EXISTS RELATION
@@ -78,9 +85,9 @@ CREATE TABLE IF NOT EXISTS RELATION
);
CREATE INDEX IF NOT EXISTS "FKI_FRAGMENT_DATASPACE_ID_FK" ON FRAGMENT USING BTREE(DATASPACE_ID) ;
-CREATE INDEX IF NOT EXISTS "FKI_FRAGMENT_SCHEMA_SET_ID_FK" ON FRAGMENT USING BTREE(SCHEMA_SET_ID) ;
CREATE INDEX IF NOT EXISTS "FKI_FRAGMENT_PARENT_ID_FK" ON FRAGMENT USING BTREE(PARENT_ID) ;
CREATE INDEX IF NOT EXISTS "FKI_FRAGMENT_ANCHOR_ID_FK" ON FRAGMENT USING BTREE(ANCHOR_ID) ;
+CREATE INDEX IF NOT EXISTS "FKI_ANCHOR_SCHEMA_SET_ID_FK" ON ANCHOR USING BTREE(SCHEMA_SET_ID) ;
CREATE INDEX IF NOT EXISTS "PERF_SCHEMA_NODE_SCHEMA_NODE_ID" ON SCHEMA_NODE USING BTREE(SCHEMA_NODE_IDENTIFIER) ;
CREATE INDEX IF NOT EXISTS "FKI_SCHEMA_NODE_ID_TO_ID" ON FRAGMENT USING BTREE(SCHEMA_NODE_ID) ;
CREATE INDEX IF NOT EXISTS "FKI_RELATION_TYPE_ID_FK" ON RELATION USING BTREE(RELATION_TYPE_ID);