Rishi.Chail | 48830f1 | 2020-11-09 03:28:44 +0000 | [diff] [blame] | 1 | CREATE TABLE IF NOT EXISTS RELATION_TYPE
|
| 2 | (
|
| 3 | RELATION_TYPE TEXT NOT NULL,
|
| 4 | ID SERIAL PRIMARY KEY
|
| 5 | );
|
| 6 |
|
| 7 | CREATE TABLE IF NOT EXISTS DATASPACE
|
| 8 | (
|
| 9 | ID SERIAL PRIMARY KEY,
|
| 10 | NAME TEXT NOT NULL,
|
| 11 | CONSTRAINT "UQ_NAME" UNIQUE (NAME)
|
| 12 | );
|
| 13 |
|
| 14 | CREATE TABLE IF NOT EXISTS SCHEMA_NODE
|
| 15 | (
|
| 16 | SCHEMA_NODE_IDENTIFIER TEXT NOT NULL,
|
| 17 | ID SERIAL PRIMARY KEY
|
| 18 | );
|
| 19 |
|
Ruslan Kashapov | cb03544 | 2020-11-24 11:13:43 +0200 | [diff] [blame^] | 20 | CREATE TABLE IF NOT EXISTS SCHEMA_SET
|
| 21 | (
|
| 22 | ID SERIAL PRIMARY KEY,
|
| 23 | NAME TEXT NOT NULL,
|
| 24 | DATASPACE_ID BIGINT NOT NULL,
|
| 25 | UNIQUE (NAME, DATASPACE_ID),
|
| 26 | CONSTRAINT SCHEMA_SET_DATASPACE FOREIGN KEY (DATASPACE_ID) REFERENCES DATASPACE(ID) ON UPDATE CASCADE ON DELETE CASCADE
|
| 27 | );
|
| 28 |
|
| 29 | CREATE TABLE IF NOT EXISTS YANG_RESOURCE
|
| 30 | (
|
| 31 | ID SERIAL PRIMARY KEY,
|
| 32 | CHECKSUM TEXT NOT NULL,
|
| 33 | CONTENT TEXT NOT NULL,
|
| 34 | UNIQUE (CHECKSUM)
|
| 35 | );
|
| 36 |
|
| 37 | CREATE TABLE IF NOT EXISTS SCHEMA_SET_YANG_RESOURCES
|
| 38 | (
|
| 39 | SCHEMA_SET_ID BIGINT NOT NULL,
|
| 40 | YANG_RESOURCE_ID BIGINT NOT NULL REFERENCES YANG_RESOURCE(ID),
|
| 41 | CONSTRAINT SCHEMA_SET_RESOURCE FOREIGN KEY (SCHEMA_SET_ID) REFERENCES SCHEMA_SET(ID) ON DELETE CASCADE
|
| 42 | );
|
| 43 |
|
Rishi.Chail | 48830f1 | 2020-11-09 03:28:44 +0000 | [diff] [blame] | 44 | CREATE TABLE IF NOT EXISTS MODULE
|
| 45 | (
|
| 46 | ID SERIAL PRIMARY KEY,
|
| 47 | NAMESPACE TEXT NOT NULL,
|
| 48 | REVISION TEXT NOT NULL,
|
| 49 | MODULE_CONTENT TEXT NOT NULL,
|
| 50 | DATASPACE_ID BIGINT NOT NULL,
|
| 51 | UNIQUE (DATASPACE_ID, NAMESPACE, REVISION),
|
| 52 | CONSTRAINT MODULE_DATASPACE FOREIGN KEY (DATASPACE_ID) REFERENCES DATASPACE (id) ON UPDATE CASCADE ON DELETE CASCADE
|
| 53 | );
|
| 54 |
|
| 55 | CREATE TABLE IF NOT EXISTS FRAGMENT
|
| 56 | (
|
| 57 | ID BIGSERIAL PRIMARY KEY,
|
| 58 | XPATH TEXT NOT NULL,
|
| 59 | ATTRIBUTES JSONB,
|
| 60 | ANCHOR_NAME TEXT,
|
| 61 | ANCHOR_ID BIGINT REFERENCES FRAGMENT(ID),
|
| 62 | PARENT_ID BIGINT REFERENCES FRAGMENT(ID),
|
| 63 | MODULE_ID INTEGER REFERENCES MODULE(ID),
|
| 64 | DATASPACE_ID INTEGER NOT NULL REFERENCES DATASPACE(ID),
|
| 65 | SCHEMA_NODE_ID INTEGER REFERENCES SCHEMA_NODE(ID),
|
| 66 | UNIQUE (DATASPACE_ID, ANCHOR_NAME, XPATH)
|
| 67 | );
|
| 68 |
|
| 69 | CREATE TABLE IF NOT EXISTS RELATION
|
| 70 | (
|
| 71 | FROM_FRAGMENT_ID BIGINT NOT NULL REFERENCES FRAGMENT(ID),
|
| 72 | TO_FRAGMENT_ID BIGINT NOT NULL REFERENCES FRAGMENT(ID),
|
| 73 | RELATION_TYPE_ID INTEGER NOT NULL REFERENCES RELATION_TYPE(ID),
|
| 74 | FROM_REL_XPATH TEXT NOT NULL,
|
| 75 | TO_REL_XPATH TEXT NOT NULL,
|
| 76 | CONSTRAINT RELATION_PKEY PRIMARY KEY (TO_FRAGMENT_ID, FROM_FRAGMENT_ID, RELATION_TYPE_ID)
|
| 77 | );
|
| 78 |
|
| 79 | CREATE INDEX IF NOT EXISTS "FKI_FRAGMENT_DATASPACE_ID_FK" ON FRAGMENT USING BTREE(DATASPACE_ID) ;
|
| 80 | CREATE INDEX IF NOT EXISTS "FKI_FRAGMENT_MODULE_ID_FK" ON FRAGMENT USING BTREE(MODULE_ID) ;
|
| 81 | CREATE INDEX IF NOT EXISTS "FKI_FRAGMENT_PARENT_ID_FK" ON FRAGMENT USING BTREE(PARENT_ID) ;
|
| 82 | CREATE INDEX IF NOT EXISTS "FKI_FRAGMENT_ANCHOR_ID_FK" ON FRAGMENT USING BTREE(ANCHOR_ID) ;
|
| 83 | CREATE INDEX IF NOT EXISTS "PERF_SCHEMA_NODE_SCHEMA_NODE_ID" ON SCHEMA_NODE USING BTREE(SCHEMA_NODE_IDENTIFIER) ;
|
| 84 | CREATE INDEX IF NOT EXISTS "FKI_SCHEMA_NODE_ID_TO_ID" ON FRAGMENT USING BTREE(SCHEMA_NODE_ID) ;
|
| 85 | CREATE INDEX IF NOT EXISTS "FKI_RELATION_TYPE_ID_FK" ON RELATION USING BTREE(RELATION_TYPE_ID);
|
| 86 | CREATE INDEX IF NOT EXISTS "FKI_RELATIONS_FROM_ID_FK" ON RELATION USING BTREE(FROM_FRAGMENT_ID);
|
| 87 | CREATE INDEX IF NOT EXISTS "FKI_RELATIONS_TO_ID_FK" ON RELATION USING BTREE(TO_FRAGMENT_ID);
|
| 88 | CREATE INDEX IF NOT EXISTS "PERF_MODULE_MODULE_CONTENT" ON MODULE USING BTREE(MODULE_CONTENT);
|
Ruslan Kashapov | cb03544 | 2020-11-24 11:13:43 +0200 | [diff] [blame^] | 89 | CREATE UNIQUE INDEX IF NOT EXISTS "UQ_FRAGMENT_XPATH"ON FRAGMENT USING btree(xpath COLLATE pg_catalog."default" text_pattern_ops, dataspace_id);
|