--
--


--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;


--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
--

COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';



--
-- Name: boolean_char; Type: DOMAIN; Schema: public; Owner: -
--

CREATE DOMAIN boolean_char AS boolean DEFAULT false;


--
-- Name: code; Type: DOMAIN; Schema: public; Owner: -
--

CREATE DOMAIN code AS character varying(60);


--
-- Name: file_path; Type: DOMAIN; Schema: public; Owner: -
--

CREATE DOMAIN file_path AS character varying(1000);


--
-- Name: tech_id; Type: DOMAIN; Schema: public; Owner: -
--

CREATE DOMAIN tech_id AS bigint;


--
-- Name: time_stamp; Type: DOMAIN; Schema: public; Owner: -
--

CREATE DOMAIN time_stamp AS timestamp with time zone;




--
-- Name: data_set_files; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE data_set_files (
    id bigint NOT NULL,
    dase_id tech_id NOT NULL,
    parent_id tech_id,
    relative_path file_path NOT NULL,
    file_name file_path NOT NULL,
    size_in_bytes bigint NOT NULL,
    checksum_crc32 integer,
    is_directory boolean_char NOT NULL,
    last_modified time_stamp DEFAULT now() NOT NULL
);


--
-- Name: data_set_files_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE data_set_files_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: data_set_files_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE data_set_files_id_seq OWNED BY data_set_files.id;


--
-- Name: data_sets; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE data_sets (
    id bigint NOT NULL,
    code code NOT NULL,
    location file_path NOT NULL
);


--
-- Name: data_sets_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE data_sets_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: data_sets_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE data_sets_id_seq OWNED BY data_sets.id;


--
-- Name: database_version_logs; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE database_version_logs (
    db_version character varying(4) NOT NULL,
    module_name character varying(250),
    run_status character varying(10),
    run_status_timestamp timestamp without time zone,
    module_code bytea,
    run_exception bytea
);


--
-- Name: events; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE events (
    last_seen_deletion_event_id tech_id NOT NULL
);


--
-- Name: last_feeding_event; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE last_feeding_event (
    registration_timestamp time_stamp NOT NULL
);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY data_set_files ALTER COLUMN id SET DEFAULT nextval('data_set_files_id_seq'::regclass);


--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY data_sets ALTER COLUMN id SET DEFAULT nextval('data_sets_id_seq'::regclass);


--
-- Data for Name: data_set_files; Type: TABLE DATA; Schema: public; Owner: -
--

COPY data_set_files (id, dase_id, parent_id, relative_path, file_name, size_in_bytes, checksum_crc32, is_directory, last_modified) FROM stdin;
1	1	\N		20161010132817957-3	4598260	\N	t	2016-10-10 13:28:17+02
2	1	1	original	original	4598260	\N	t	2016-10-10 13:28:17+02
3	1	2	original/test+prot	test+prot	4598260	\N	t	2016-10-10 13:28:04+02
4	1	3	original/test+prot/example.prot.xml	example.prot.xml	4598260	-309280870	f	2016-10-10 13:28:04+02
5	1	3	original/test+prot/search.properties	search.properties	0	0	f	2016-10-10 13:28:04+02
6	2	\N		20161010133046010-5	4598260	\N	t	2016-10-10 13:30:46+02
7	2	6	original	original	4598260	\N	t	2016-10-10 13:30:46+02
8	2	7	original/test+prot	test+prot	4598260	\N	t	2016-10-10 13:30:35+02
9	2	8	original/test+prot/example.prot.xml	example.prot.xml	4598260	-309280870	f	2016-10-10 13:30:35+02
10	2	8	original/test+prot/search.properties	search.properties	0	0	f	2016-10-10 13:30:35+02
\.


--
-- Name: data_set_files_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('data_set_files_id_seq', 10, true);


--
-- Data for Name: data_sets; Type: TABLE DATA; Schema: public; Owner: -
--

COPY data_sets (id, code, location) FROM stdin;
1	20161010132817957-3	C4311C47-19F4-4175-A3B4-2F5848B1AB73/51/88/65/20161010132817957-3
2	20161010133046010-5	C4311C47-19F4-4175-A3B4-2F5848B1AB73/17/a7/0b/20161010133046010-5
\.


--
-- Name: data_sets_id_seq; Type: SEQUENCE SET; Schema: public; Owner: -
--

SELECT pg_catalog.setval('data_sets_id_seq', 2, true);


--
-- Data for Name: database_version_logs; Type: TABLE DATA; Schema: public; Owner: -
--

COPY database_version_logs (db_version, module_name, run_status, run_status_timestamp, module_code, run_exception) FROM stdin;
008	datastore_server/sql/postgresql/008/schema-008.sql	SUCCESS	2016-10-10 13:25:32.48	\\x[BLOB]	\N
\.


--
-- Data for Name: events; Type: TABLE DATA; Schema: public; Owner: -
--

COPY events (last_seen_deletion_event_id) FROM stdin;
\.


--
-- Data for Name: last_feeding_event; Type: TABLE DATA; Schema: public; Owner: -
--

COPY last_feeding_event (registration_timestamp) FROM stdin;
\.


--
-- Name: data_set_files_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY data_set_files
    ADD CONSTRAINT data_set_files_pkey PRIMARY KEY (id);


--
-- Name: data_sets_code_key; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY data_sets
    ADD CONSTRAINT data_sets_code_key UNIQUE (code);


--
-- Name: data_sets_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY data_sets
    ADD CONSTRAINT data_sets_pkey PRIMARY KEY (id);


--
-- Name: data_set_files_dase_id_file_name_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX data_set_files_dase_id_file_name_idx ON data_set_files USING btree (dase_id, file_name);


--
-- Name: data_set_files_dase_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX data_set_files_dase_id_idx ON data_set_files USING btree (dase_id);


--
-- Name: data_set_files_dase_id_parent_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX data_set_files_dase_id_parent_id_idx ON data_set_files USING btree (dase_id, parent_id);


--
-- Name: data_set_files_dase_id_relative_path_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX data_set_files_dase_id_relative_path_idx ON data_set_files USING btree (dase_id, relative_path);


--
-- Name: data_sets_code_idx; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX data_sets_code_idx ON data_sets USING btree (code);


--
-- Name: fk_data_set_files_data_sets; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY data_set_files
    ADD CONSTRAINT fk_data_set_files_data_sets FOREIGN KEY (dase_id) REFERENCES data_sets(id) ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: public; Type: ACL; Schema: -; Owner: -
--

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


--
--

