--
--


-- Started on 2024-04-04 14:25:18

SELECT pg_catalog.set_config('search_path', '', false);

--
-- TOC entry 4 (class 2615 OID 2200)
-- Name: public; Type: SCHEMA; Schema: -; Owner: test
--


ALTER SCHEMA public OWNER TO test;

--
-- TOC entry 3405 (class 0 OID 0)
-- Dependencies: 4
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: test
--

COMMENT ON SCHEMA public IS 'standard public schema';




--
-- TOC entry 212 (class 1259 OID 16396)
-- Name: anchor; Type: TABLE; Schema: public; Owner: test
--

CREATE TABLE public.anchor (
    id bigint NOT NULL,
    name text,
    schema_set_id integer,
    dataspace_id integer NOT NULL
);


ALTER TABLE public.anchor OWNER TO test;

--
-- TOC entry 211 (class 1259 OID 16395)
-- Name: anchor_id_seq; Type: SEQUENCE; Schema: public; Owner: test
--

ALTER TABLE public.anchor ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.anchor_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 210 (class 1259 OID 16390)
-- Name: databasechangelog; Type: TABLE; Schema: public; Owner: test
--

CREATE TABLE public.databasechangelog (
    id character varying(255) NOT NULL,
    author character varying(255) NOT NULL,
    filename character varying(255) NOT NULL,
    dateexecuted timestamp without time zone NOT NULL,
    orderexecuted integer NOT NULL,
    exectype character varying(10) NOT NULL,
    md5sum character varying(35),
    description character varying(255),
    comments character varying(255),
    tag character varying(255),
    liquibase character varying(20),
    contexts character varying(255),
    labels character varying(255),
    deployment_id character varying(10)
);


ALTER TABLE public.databasechangelog OWNER TO test;

--
-- TOC entry 209 (class 1259 OID 16385)
-- Name: databasechangeloglock; Type: TABLE; Schema: public; Owner: test
--

CREATE TABLE public.databasechangeloglock (
    id integer NOT NULL,
    locked boolean NOT NULL,
    lockgranted timestamp without time zone,
    lockedby character varying(255)
);


ALTER TABLE public.databasechangeloglock OWNER TO test;

--
-- TOC entry 222 (class 1259 OID 16441)
-- Name: dataspace; Type: TABLE; Schema: public; Owner: test
--

CREATE TABLE public.dataspace (
    id integer NOT NULL,
    name text NOT NULL
);


ALTER TABLE public.dataspace OWNER TO test;

--
-- TOC entry 221 (class 1259 OID 16440)
-- Name: dataspace_id_seq; Type: SEQUENCE; Schema: public; Owner: test
--

ALTER TABLE public.dataspace ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.dataspace_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 216 (class 1259 OID 16417)
-- Name: fragment; Type: TABLE; Schema: public; Owner: test
--

CREATE TABLE public.fragment (
    id bigint NOT NULL,
    xpath text NOT NULL,
    attributes jsonb,
    anchor_id bigint NOT NULL,
    parent_id bigint,
    schema_node_id integer
);


ALTER TABLE public.fragment OWNER TO test;

--
-- TOC entry 226 (class 1259 OID 16582)
-- Name: fragment_id_seq; Type: SEQUENCE; Schema: public; Owner: test
--

CREATE SEQUENCE public.fragment_id_seq
    START WITH 100
    INCREMENT BY 100
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


ALTER SEQUENCE public.fragment_id_seq OWNER TO test;

--
-- TOC entry 213 (class 1259 OID 16403)
-- Name: relation; Type: TABLE; Schema: public; Owner: test
--

CREATE TABLE public.relation (
    from_fragment_id bigint NOT NULL,
    to_fragment_id bigint NOT NULL,
    relation_type_id integer NOT NULL,
    from_rel_xpath text NOT NULL,
    to_rel_xpath text NOT NULL
);


ALTER TABLE public.relation OWNER TO test;

--
-- TOC entry 215 (class 1259 OID 16409)
-- Name: relation_type; Type: TABLE; Schema: public; Owner: test
--

CREATE TABLE public.relation_type (
    relation_type text NOT NULL,
    id integer NOT NULL
);


ALTER TABLE public.relation_type OWNER TO test;

--
-- TOC entry 214 (class 1259 OID 16408)
-- Name: relation_type_id_seq; Type: SEQUENCE; Schema: public; Owner: test
--

ALTER TABLE public.relation_type ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.relation_type_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 224 (class 1259 OID 16449)
-- Name: schema_node; Type: TABLE; Schema: public; Owner: test
--

CREATE TABLE public.schema_node (
    schema_node_identifier text NOT NULL,
    id integer NOT NULL
);


ALTER TABLE public.schema_node OWNER TO test;

--
-- TOC entry 223 (class 1259 OID 16448)
-- Name: schema_node_id_seq; Type: SEQUENCE; Schema: public; Owner: test
--

ALTER TABLE public.schema_node ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.schema_node_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 218 (class 1259 OID 16425)
-- Name: schema_set; Type: TABLE; Schema: public; Owner: test
--

CREATE TABLE public.schema_set (
    id integer NOT NULL,
    name text NOT NULL,
    dataspace_id integer NOT NULL
);


ALTER TABLE public.schema_set OWNER TO test;

--
-- TOC entry 217 (class 1259 OID 16424)
-- Name: schema_set_id_seq; Type: SEQUENCE; Schema: public; Owner: test
--

ALTER TABLE public.schema_set ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.schema_set_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 225 (class 1259 OID 16456)
-- Name: schema_set_yang_resources; Type: TABLE; Schema: public; Owner: test
--

CREATE TABLE public.schema_set_yang_resources (
    schema_set_id integer NOT NULL,
    yang_resource_id integer NOT NULL
);


ALTER TABLE public.schema_set_yang_resources OWNER TO test;

--
-- TOC entry 220 (class 1259 OID 16433)
-- Name: yang_resource; Type: TABLE; Schema: public; Owner: test
--

CREATE TABLE public.yang_resource (
    id integer NOT NULL,
    file_name text NOT NULL,
    content text NOT NULL,
    checksum text NOT NULL,
    module_name text,
    revision text
);


ALTER TABLE public.yang_resource OWNER TO test;

--
-- TOC entry 219 (class 1259 OID 16432)
-- Name: yang_resource_id_seq; Type: SEQUENCE; Schema: public; Owner: test
--

ALTER TABLE public.yang_resource ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (
    SEQUENCE NAME public.yang_resource_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1
);


--
-- TOC entry 3216 (class 2606 OID 16461)
-- Name: anchor anchor_dataspace_id_name_key; Type: CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.anchor
    ADD CONSTRAINT anchor_dataspace_id_name_key UNIQUE (dataspace_id, name);


--
-- TOC entry 3218 (class 2606 OID 16402)
-- Name: anchor anchor_pkey; Type: CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.anchor
    ADD CONSTRAINT anchor_pkey PRIMARY KEY (id);


--
-- TOC entry 3214 (class 2606 OID 16389)
-- Name: databasechangeloglock databasechangeloglock_pkey; Type: CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.databasechangeloglock
    ADD CONSTRAINT databasechangeloglock_pkey PRIMARY KEY (id);


--
-- TOC entry 3243 (class 2606 OID 16447)
-- Name: dataspace dataspace_pkey; Type: CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.dataspace
    ADD CONSTRAINT dataspace_pkey PRIMARY KEY (id);


--
-- TOC entry 3231 (class 2606 OID 16548)
-- Name: fragment fragment_anchor_id_xpath_key; Type: CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.fragment
    ADD CONSTRAINT fragment_anchor_id_xpath_key UNIQUE (anchor_id, xpath);


--
-- TOC entry 3233 (class 2606 OID 16423)
-- Name: fragment fragment_pkey; Type: CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.fragment
    ADD CONSTRAINT fragment_pkey PRIMARY KEY (id);


--
-- TOC entry 3224 (class 2606 OID 16471)
-- Name: relation relation_pkey; Type: CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.relation
    ADD CONSTRAINT relation_pkey PRIMARY KEY (to_fragment_id, from_fragment_id, relation_type_id);


--
-- TOC entry 3226 (class 2606 OID 16415)
-- Name: relation_type relation_type_pkey; Type: CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.relation_type
    ADD CONSTRAINT relation_type_pkey PRIMARY KEY (id);


--
-- TOC entry 3248 (class 2606 OID 16455)
-- Name: schema_node schema_node_pkey; Type: CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.schema_node
    ADD CONSTRAINT schema_node_pkey PRIMARY KEY (id);


--
-- TOC entry 3235 (class 2606 OID 16550)
-- Name: schema_set schema_set_name_dataspace_id_key; Type: CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.schema_set
    ADD CONSTRAINT schema_set_name_dataspace_id_key UNIQUE (name, dataspace_id);


--
-- TOC entry 3237 (class 2606 OID 16431)
-- Name: schema_set schema_set_pkey; Type: CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.schema_set
    ADD CONSTRAINT schema_set_pkey PRIMARY KEY (id);


--
-- TOC entry 3245 (class 2606 OID 16499)
-- Name: dataspace uq_name; Type: CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.dataspace
    ADD CONSTRAINT uq_name UNIQUE (name);


--
-- TOC entry 3239 (class 2606 OID 16497)
-- Name: yang_resource yang_resource_checksum_key; Type: CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.yang_resource
    ADD CONSTRAINT yang_resource_checksum_key UNIQUE (checksum);


--
-- TOC entry 3241 (class 2606 OID 16439)
-- Name: yang_resource yang_resource_pkey; Type: CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.yang_resource
    ADD CONSTRAINT yang_resource_pkey PRIMARY KEY (id);


--
-- TOC entry 3219 (class 1259 OID 16459)
-- Name: fki_anchor_schema_set_id_fk; Type: INDEX; Schema: public; Owner: test
--

CREATE INDEX fki_anchor_schema_set_id_fk ON public.anchor USING btree (schema_set_id);


--
-- TOC entry 3227 (class 1259 OID 16472)
-- Name: fki_fragment_anchor_id_fk; Type: INDEX; Schema: public; Owner: test
--

CREATE INDEX fki_fragment_anchor_id_fk ON public.fragment USING btree (anchor_id);


--
-- TOC entry 3228 (class 1259 OID 16474)
-- Name: fki_fragment_parent_id_fk; Type: INDEX; Schema: public; Owner: test
--

CREATE INDEX fki_fragment_parent_id_fk ON public.fragment USING btree (parent_id);


--
-- TOC entry 3220 (class 1259 OID 16469)
-- Name: fki_relation_type_id_fk; Type: INDEX; Schema: public; Owner: test
--

CREATE INDEX fki_relation_type_id_fk ON public.relation USING btree (relation_type_id);


--
-- TOC entry 3221 (class 1259 OID 16467)
-- Name: fki_relations_from_id_fk; Type: INDEX; Schema: public; Owner: test
--

CREATE INDEX fki_relations_from_id_fk ON public.relation USING btree (from_fragment_id);


--
-- TOC entry 3222 (class 1259 OID 16468)
-- Name: fki_relations_to_id_fk; Type: INDEX; Schema: public; Owner: test
--

CREATE INDEX fki_relations_to_id_fk ON public.relation USING btree (to_fragment_id);


--
-- TOC entry 3229 (class 1259 OID 16475)
-- Name: fki_schema_node_id_to_id; Type: INDEX; Schema: public; Owner: test
--

CREATE INDEX fki_schema_node_id_to_id ON public.fragment USING btree (schema_node_id);


--
-- TOC entry 3249 (class 1259 OID 16563)
-- Name: fki_schema_set_yang_resources_schema_set_id_fk; Type: INDEX; Schema: public; Owner: test
--

CREATE INDEX fki_schema_set_yang_resources_schema_set_id_fk ON public.schema_set_yang_resources USING btree (schema_set_id);


--
-- TOC entry 3246 (class 1259 OID 16510)
-- Name: perf_schema_node_schema_node_id; Type: INDEX; Schema: public; Owner: test
--

CREATE INDEX perf_schema_node_schema_node_id ON public.schema_node USING btree (schema_node_identifier);


--
-- TOC entry 3250 (class 2606 OID 16516)
-- Name: anchor anchor_dataspace_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.anchor
    ADD CONSTRAINT anchor_dataspace_id_fkey FOREIGN KEY (dataspace_id) REFERENCES public.dataspace(id);


--
-- TOC entry 3251 (class 2606 OID 16521)
-- Name: anchor anchor_schema_set_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.anchor
    ADD CONSTRAINT anchor_schema_set_id_fkey FOREIGN KEY (schema_set_id) REFERENCES public.schema_set(id);


--
-- TOC entry 3255 (class 2606 OID 16462)
-- Name: fragment fragment_anchor_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.fragment
    ADD CONSTRAINT fragment_anchor_id_fkey FOREIGN KEY (anchor_id) REFERENCES public.anchor(id);


--
-- TOC entry 3256 (class 2606 OID 16542)
-- Name: fragment fragment_parent_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.fragment
    ADD CONSTRAINT fragment_parent_id_fkey FOREIGN KEY (parent_id) REFERENCES public.fragment(id) ON DELETE CASCADE;


--
-- TOC entry 3257 (class 2606 OID 16536)
-- Name: fragment fragment_schema_node_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.fragment
    ADD CONSTRAINT fragment_schema_node_id_fkey FOREIGN KEY (schema_node_id) REFERENCES public.schema_node(id);


--
-- TOC entry 3252 (class 2606 OID 16479)
-- Name: relation relation_from_fragment_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.relation
    ADD CONSTRAINT relation_from_fragment_id_fkey FOREIGN KEY (from_fragment_id) REFERENCES public.fragment(id);


--
-- TOC entry 3253 (class 2606 OID 16526)
-- Name: relation relation_relation_type_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.relation
    ADD CONSTRAINT relation_relation_type_id_fkey FOREIGN KEY (relation_type_id) REFERENCES public.relation_type(id);


--
-- TOC entry 3254 (class 2606 OID 16484)
-- Name: relation relation_to_fragment_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.relation
    ADD CONSTRAINT relation_to_fragment_id_fkey FOREIGN KEY (to_fragment_id) REFERENCES public.fragment(id);


--
-- TOC entry 3258 (class 2606 OID 16551)
-- Name: schema_set schema_set_dataspace; Type: FK CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.schema_set
    ADD CONSTRAINT schema_set_dataspace FOREIGN KEY (dataspace_id) REFERENCES public.dataspace(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- TOC entry 3259 (class 2606 OID 16564)
-- Name: schema_set_yang_resources schema_set_resource; Type: FK CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.schema_set_yang_resources
    ADD CONSTRAINT schema_set_resource FOREIGN KEY (schema_set_id) REFERENCES public.schema_set(id) ON DELETE CASCADE;


--
-- TOC entry 3260 (class 2606 OID 16573)
-- Name: schema_set_yang_resources schema_set_yang_resources_yang_resource_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: test
--

ALTER TABLE ONLY public.schema_set_yang_resources
    ADD CONSTRAINT schema_set_yang_resources_yang_resource_id_fkey FOREIGN KEY (yang_resource_id) REFERENCES public.yang_resource(id);


--
-- TOC entry 3406 (class 0 OID 0)
-- Dependencies: 4
-- Name: SCHEMA public; Type: ACL; Schema: -; Owner: test
--

REVOKE USAGE ON SCHEMA public FROM PUBLIC;
GRANT ALL ON SCHEMA public TO PUBLIC;


-- Completed on 2024-04-04 14:25:18

--
--

