--
--



--
-- 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: channel_color; Type: DOMAIN; Schema: public; Owner: -
--

CREATE DOMAIN channel_color AS character varying(20)
	CONSTRAINT channel_color_check CHECK (((VALUE)::text = ANY (ARRAY[('BLUE'::character varying)::text, ('GREEN'::character varying)::text, ('RED'::character varying)::text, ('RED_GREEN'::character varying)::text, ('RED_BLUE'::character varying)::text, ('GREEN_BLUE'::character varying)::text])));


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

CREATE DOMAIN code AS character varying(40);


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

CREATE DOMAIN color_component AS character varying(40)
	CONSTRAINT color_component_check CHECK (((VALUE)::text = ANY (ARRAY[('RED'::character varying)::text, ('GREEN'::character varying)::text, ('BLUE'::character varying)::text])));


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

CREATE DOMAIN description AS character varying(200);


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

CREATE DOMAIN file_path AS character varying(1000);


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

CREATE DOMAIN long_name AS text;


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

CREATE DOMAIN tech_id AS bigint;


--
-- Name: channel_stacks_check(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION channel_stacks_check() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
DECLARE
   v_cont_id  CODE;
BEGIN

   select cont_id into v_cont_id from image_data_sets where id = NEW.ds_id;

   -- Check that if there is no spot than there is no dataset container as well
   if v_cont_id IS NULL then
      if NEW.spot_id IS NOT NULL then
         RAISE EXCEPTION 'Insert/Update of CHANNEL_STACKS failed, as the dataset container is not set, but spot is (spot id = %).',NEW.spot_id;
      end if;
	 else
      if NEW.spot_id IS NULL then
         RAISE EXCEPTION 'Insert/Update of CHANNEL_STACKS failed, as the dataset container is set (id = %), but spot is not set.',v_cont_id;
      end if; 
   end if;
   RETURN NEW;
END;
$$;


--
-- Name: delete_empty_acquired_images(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION delete_empty_acquired_images() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
	delete from acquired_images where id = OLD.id;
	RETURN NEW;
END;
$$;


--
-- Name: delete_unused_images(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION delete_unused_images() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
   delete from images where id = OLD.img_id or id = OLD.thumbnail_id;
   RETURN NEW;
END;
$$;


--
-- Name: delete_unused_nulled_images(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION delete_unused_nulled_images() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
BEGIN
	if NEW.img_id IS NULL then
		if OLD.img_id IS NOT NULL then
		  delete from images where id = OLD.img_id;
		end if;
	end if;
	if NEW.thumbnail_id IS NULL then
		if OLD.thumbnail_id IS NOT NULL then
		  delete from images where id = OLD.thumbnail_id;
		end if;
	end if;
	RETURN NEW;
END;
$$;


--
-- Name: image_transformations_default_check(); Type: FUNCTION; Schema: public; Owner: -
--

CREATE FUNCTION image_transformations_default_check() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
DECLARE
   v_is_default boolean;
BEGIN
   if NEW.is_default = 'T' then
	   select is_default into v_is_default from IMAGE_TRANSFORMATIONS 
	   	where is_default = 'T' 
	   			  and channel_id = NEW.channel_id
	   				and id != NEW.id;
	   if v_is_default is NOT NULL then
	      RAISE EXCEPTION 'Insert/Update of image transformation (Code: %) failed, as the new record has is_default set to true and there is already a default record defined.', NEW.code;
	   end if;
   end if;

   RETURN NEW;
END;
$$;




--
-- Name: acquired_images; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE acquired_images (
    id bigint NOT NULL,
    img_id tech_id,
    thumbnail_id tech_id,
    image_transformer_factory bytea,
    channel_stack_id tech_id NOT NULL,
    channel_id tech_id NOT NULL
);


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

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


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

ALTER SEQUENCE acquired_images_id_seq OWNED BY acquired_images.id;


--
-- Name: analysis_data_sets; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE analysis_data_sets (
    id bigint NOT NULL,
    perm_id code NOT NULL,
    cont_id tech_id
);


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

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


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

ALTER SEQUENCE analysis_data_sets_id_seq OWNED BY analysis_data_sets.id;


--
-- Name: channel_stacks; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE channel_stacks (
    id bigint NOT NULL,
    x integer,
    y integer,
    z_in_m real,
    t_in_sec real,
    series_number integer,
    is_representative boolean_char DEFAULT false NOT NULL,
    ds_id tech_id NOT NULL,
    spot_id tech_id
);


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

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


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

ALTER SEQUENCE channel_stacks_id_seq OWNED BY channel_stacks.id;


--
-- Name: channels; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE channels (
    id bigint NOT NULL,
    code long_name NOT NULL,
    label long_name NOT NULL,
    description description,
    wavelength integer,
    red_cc integer NOT NULL,
    green_cc integer NOT NULL,
    blue_cc integer NOT NULL,
    ds_id tech_id,
    exp_id tech_id,
    CONSTRAINT channels_ds_exp_arc_ck CHECK ((((ds_id IS NOT NULL) AND (exp_id IS NULL)) OR ((ds_id IS NULL) AND (exp_id IS NOT NULL))))
);


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

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


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

ALTER SEQUENCE channels_id_seq OWNED BY channels.id;


--
-- Name: containers; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE containers (
    id bigint NOT NULL,
    perm_id code NOT NULL,
    spots_width integer,
    spots_height integer,
    expe_id tech_id NOT NULL
);


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

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


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

ALTER SEQUENCE containers_id_seq OWNED BY containers.id;


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

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: -
--

CREATE TABLE events (
    last_seen_deletion_event_id tech_id NOT NULL
);


--
-- Name: experiments; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE experiments (
    id bigint NOT NULL,
    perm_id code NOT NULL,
    image_transformer_factory bytea
);


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

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


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

ALTER SEQUENCE experiments_id_seq OWNED BY experiments.id;


--
-- Name: feature_defs; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE feature_defs (
    id bigint NOT NULL,
    code long_name NOT NULL,
    label long_name NOT NULL,
    description description,
    ds_id tech_id NOT NULL
);


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

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


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

ALTER SEQUENCE feature_defs_id_seq OWNED BY feature_defs.id;


--
-- Name: feature_values; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE feature_values (
    id bigint NOT NULL,
    z_in_m real,
    t_in_sec real,
    "values" bytea NOT NULL,
    fd_id tech_id NOT NULL
);


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

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


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

ALTER SEQUENCE feature_values_id_seq OWNED BY feature_values.id;


--
-- Name: feature_vocabulary_terms; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE feature_vocabulary_terms (
    id bigint NOT NULL,
    code long_name NOT NULL,
    sequence_number integer NOT NULL,
    fd_id tech_id NOT NULL
);


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

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


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

ALTER SEQUENCE feature_vocabulary_terms_id_seq OWNED BY feature_vocabulary_terms.id;


--
-- Name: image_data_sets; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE image_data_sets (
    id bigint NOT NULL,
    perm_id code NOT NULL,
    fields_width integer,
    fields_height integer,
    image_transformer_factory bytea,
    is_multidimensional boolean_char NOT NULL,
    image_library_name long_name,
    image_library_reader_name long_name,
    cont_id tech_id
);


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

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


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

ALTER SEQUENCE image_data_sets_id_seq OWNED BY image_data_sets.id;


--
-- Name: image_transformations; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE image_transformations (
    id bigint NOT NULL,
    code long_name NOT NULL,
    label long_name NOT NULL,
    description character varying(1000),
    image_transformer_factory bytea NOT NULL,
    is_editable boolean_char NOT NULL,
    is_default boolean_char DEFAULT false NOT NULL,
    channel_id tech_id NOT NULL
);


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

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


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

ALTER SEQUENCE image_transformations_id_seq OWNED BY image_transformations.id;


--
-- Name: image_zoom_level_transformations; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE image_zoom_level_transformations (
    id bigint NOT NULL,
    zoom_level_id tech_id NOT NULL,
    channel_id tech_id NOT NULL,
    image_transformation_id tech_id NOT NULL
);


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

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


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

ALTER SEQUENCE image_zoom_level_transformations_id_seq OWNED BY image_zoom_level_transformations.id;


--
-- Name: image_zoom_levels; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE image_zoom_levels (
    id bigint NOT NULL,
    is_original boolean_char NOT NULL,
    container_dataset_id tech_id NOT NULL,
    physical_dataset_perm_id text NOT NULL,
    path file_path,
    width integer,
    height integer,
    color_depth integer,
    file_type character varying(20)
);


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

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


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

ALTER SEQUENCE image_zoom_levels_id_seq OWNED BY image_zoom_levels.id;


--
-- Name: images; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE images (
    id bigint NOT NULL,
    path file_path NOT NULL,
    image_id code,
    color color_component
);


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

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


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

ALTER SEQUENCE images_id_seq OWNED BY images.id;


--
-- Name: spots; Type: TABLE; Schema: public; Owner: -
--

CREATE TABLE spots (
    id bigint NOT NULL,
    x integer,
    y integer,
    cont_id tech_id NOT NULL
);


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

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


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

ALTER SEQUENCE spots_id_seq OWNED BY spots.id;


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

ALTER TABLE ONLY acquired_images ALTER COLUMN id SET DEFAULT nextval('acquired_images_id_seq'::regclass);


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

ALTER TABLE ONLY analysis_data_sets ALTER COLUMN id SET DEFAULT nextval('analysis_data_sets_id_seq'::regclass);


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

ALTER TABLE ONLY channel_stacks ALTER COLUMN id SET DEFAULT nextval('channel_stacks_id_seq'::regclass);


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

ALTER TABLE ONLY channels ALTER COLUMN id SET DEFAULT nextval('channels_id_seq'::regclass);


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

ALTER TABLE ONLY containers ALTER COLUMN id SET DEFAULT nextval('containers_id_seq'::regclass);


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

ALTER TABLE ONLY experiments ALTER COLUMN id SET DEFAULT nextval('experiments_id_seq'::regclass);


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

ALTER TABLE ONLY feature_defs ALTER COLUMN id SET DEFAULT nextval('feature_defs_id_seq'::regclass);


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

ALTER TABLE ONLY feature_values ALTER COLUMN id SET DEFAULT nextval('feature_values_id_seq'::regclass);


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

ALTER TABLE ONLY feature_vocabulary_terms ALTER COLUMN id SET DEFAULT nextval('feature_vocabulary_terms_id_seq'::regclass);


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

ALTER TABLE ONLY image_data_sets ALTER COLUMN id SET DEFAULT nextval('image_data_sets_id_seq'::regclass);


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

ALTER TABLE ONLY image_transformations ALTER COLUMN id SET DEFAULT nextval('image_transformations_id_seq'::regclass);


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

ALTER TABLE ONLY image_zoom_level_transformations ALTER COLUMN id SET DEFAULT nextval('image_zoom_level_transformations_id_seq'::regclass);


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

ALTER TABLE ONLY image_zoom_levels ALTER COLUMN id SET DEFAULT nextval('image_zoom_levels_id_seq'::regclass);


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

ALTER TABLE ONLY images ALTER COLUMN id SET DEFAULT nextval('images_id_seq'::regclass);


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

ALTER TABLE ONLY spots ALTER COLUMN id SET DEFAULT nextval('spots_id_seq'::regclass);


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

COPY acquired_images (id, img_id, thumbnail_id, image_transformer_factory, channel_stack_id, channel_id) FROM stdin;
1	1	2	\N	1	1
2	3	4	\N	2	1
3	5	6	\N	3	1
4	7	8	\N	4	1
5	9	10	\N	5	1
6	11	12	\N	6	1
7	13	14	\N	7	1
8	15	16	\N	8	1
9	17	18	\N	9	1
10	19	20	\N	10	1
11	21	22	\N	11	1
12	23	24	\N	12	1
13	25	26	\N	13	1
14	27	28	\N	14	1
15	29	30	\N	15	1
16	31	32	\N	16	1
17	33	34	\N	17	1
18	35	36	\N	18	1
19	37	38	\N	19	1
20	39	40	\N	20	1
21	41	42	\N	21	1
22	43	44	\N	22	1
23	45	46	\N	23	1
24	47	48	\N	24	1
25	49	50	\N	25	1
26	51	52	\N	26	1
27	53	54	\N	27	1
28	55	56	\N	28	1
29	57	58	\N	29	1
30	59	60	\N	30	1
\.


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

SELECT pg_catalog.setval('acquired_images_id_seq', 30, true);


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

COPY analysis_data_sets (id, perm_id, cont_id) FROM stdin;
\.


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

SELECT pg_catalog.setval('analysis_data_sets_id_seq', 1, false);


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

COPY channel_stacks (id, x, y, z_in_m, t_in_sec, series_number, is_representative, ds_id, spot_id) FROM stdin;
1	1	1	0	9	\N	f	1	\N
2	1	1	0	7	\N	f	1	\N
3	1	1	3	2	\N	f	1	\N
4	1	1	6	0	\N	f	1	\N
5	1	1	6	3	\N	f	1	\N
6	1	1	6	8	\N	f	1	\N
7	1	1	6	9	\N	f	1	\N
8	1	1	0	1	\N	f	1	\N
9	1	1	3	0	\N	f	1	\N
10	1	1	0	5	\N	f	1	\N
11	1	1	6	2	\N	f	1	\N
12	1	1	0	8	\N	f	1	\N
13	1	1	3	7	\N	f	1	\N
14	1	1	6	5	\N	f	1	\N
15	1	1	0	4	\N	f	1	\N
16	1	1	3	9	\N	f	1	\N
17	1	1	3	1	\N	f	1	\N
18	1	1	6	7	\N	f	1	\N
19	1	1	3	3	\N	f	1	\N
20	1	1	0	2	\N	f	1	\N
21	1	1	3	5	\N	f	1	\N
22	1	1	6	1	\N	f	1	\N
23	1	1	3	8	\N	f	1	\N
24	1	1	0	0	\N	t	1	\N
25	1	1	6	4	\N	f	1	\N
26	1	1	3	6	\N	f	1	\N
27	1	1	6	6	\N	f	1	\N
28	1	1	3	4	\N	f	1	\N
29	1	1	0	3	\N	f	1	\N
30	1	1	0	6	\N	f	1	\N
\.


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

SELECT pg_catalog.setval('channel_stacks_id_seq', 30, true);


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

COPY channels (id, code, label, description, wavelength, red_cc, green_cc, blue_cc, ds_id, exp_id) FROM stdin;
1	RGB	RGB	\N	\N	0	0	255	1	\N
\.


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

SELECT pg_catalog.setval('channels_id_seq', 1, true);


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

COPY containers (id, perm_id, spots_width, spots_height, expe_id) FROM stdin;
\.


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

SELECT pg_catalog.setval('containers_id_seq', 1, false);


--
-- 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;
023	sql/imaging/postgresql/023/schema-023.sql	SUCCESS	2013-04-16 17:30:26.145	\\x[BLOB]	\N
\.


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

COPY events (last_seen_deletion_event_id) FROM stdin;
175
\.


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

COPY experiments (id, perm_id, image_transformer_factory) FROM stdin;
\.


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

SELECT pg_catalog.setval('experiments_id_seq', 1, false);


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

COPY feature_defs (id, code, label, description, ds_id) FROM stdin;
\.


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

SELECT pg_catalog.setval('feature_defs_id_seq', 1, false);


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

COPY feature_values (id, z_in_m, t_in_sec, "values", fd_id) FROM stdin;
\.


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

SELECT pg_catalog.setval('feature_values_id_seq', 1, false);


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

COPY feature_vocabulary_terms (id, code, sequence_number, fd_id) FROM stdin;
\.


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

SELECT pg_catalog.setval('feature_vocabulary_terms_id_seq', 1, false);


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

COPY image_data_sets (id, perm_id, fields_width, fields_height, image_transformer_factory, is_multidimensional, image_library_name, image_library_reader_name, cont_id) FROM stdin;
1	20130417094937144-429	1	1	\N	t	\N	\N	\N
\.


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

SELECT pg_catalog.setval('image_data_sets_id_seq', 1, true);


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

COPY image_transformations (id, code, label, description, image_transformer_factory, is_editable, is_default, channel_id) FROM stdin;
\.


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

SELECT pg_catalog.setval('image_transformations_id_seq', 1, false);


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

COPY image_zoom_level_transformations (id, zoom_level_id, channel_id, image_transformation_id) FROM stdin;
\.


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

SELECT pg_catalog.setval('image_zoom_level_transformations_id_seq', 1, false);


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

COPY image_zoom_levels (id, is_original, container_dataset_id, physical_dataset_perm_id, path, width, height, color_depth, file_type) FROM stdin;
1	t	1	20130417094936021-428		512	512	32	\N
2	f	1	20130417094934693-427	thumbnails_128x128.h5ar	128	128	32	png
\.


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

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


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

COPY images (id, path, image_id, color) FROM stdin;
1	original/SERIES-1/bPLATE_w_s1_z0_t9_cRGB.png	\N	\N
2	d1-1_t9.0_h0.0_cRGB	\N	\N
3	original/SERIES-1/bPLATE_w_s1_z0_t7_cRGB.png	\N	\N
4	d1-1_t7.0_h0.0_cRGB	\N	\N
5	original/SERIES-1/bPLATE_w_s1_z3_t2_cRGB.png	\N	\N
6	d1-1_t2.0_h3.0_cRGB	\N	\N
7	original/SERIES-1/bPLATE_w_s1_z6_t0_cRGB.png	\N	\N
8	d1-1_t0.0_h6.0_cRGB	\N	\N
9	original/SERIES-1/bPLATE_w_s1_z6_t3_cRGB.png	\N	\N
10	d1-1_t3.0_h6.0_cRGB	\N	\N
11	original/SERIES-1/bPLATE_w_s1_z6_t8_cRGB.png	\N	\N
12	d1-1_t8.0_h6.0_cRGB	\N	\N
13	original/SERIES-1/bPLATE_w_s1_z6_t9_cRGB.png	\N	\N
14	d1-1_t9.0_h6.0_cRGB	\N	\N
15	original/SERIES-1/bPLATE_w_s1_z0_t1_cRGB.png	\N	\N
16	d1-1_t1.0_h0.0_cRGB	\N	\N
17	original/SERIES-1/bPLATE_w_s1_z3_t0_cRGB.png	\N	\N
18	d1-1_t0.0_h3.0_cRGB	\N	\N
19	original/SERIES-1/bPLATE_w_s1_z0_t5_cRGB.png	\N	\N
20	d1-1_t5.0_h0.0_cRGB	\N	\N
21	original/SERIES-1/bPLATE_w_s1_z6_t2_cRGB.png	\N	\N
22	d1-1_t2.0_h6.0_cRGB	\N	\N
23	original/SERIES-1/bPLATE_w_s1_z0_t8_cRGB.png	\N	\N
24	d1-1_t8.0_h0.0_cRGB	\N	\N
25	original/SERIES-1/bPLATE_w_s1_z3_t7_cRGB.png	\N	\N
26	d1-1_t7.0_h3.0_cRGB	\N	\N
27	original/SERIES-1/bPLATE_w_s1_z6_t5_cRGB.png	\N	\N
28	d1-1_t5.0_h6.0_cRGB	\N	\N
29	original/SERIES-1/bPLATE_w_s1_z0_t4_cRGB.png	\N	\N
30	d1-1_t4.0_h0.0_cRGB	\N	\N
31	original/SERIES-1/bPLATE_w_s1_z3_t9_cRGB.png	\N	\N
32	d1-1_t9.0_h3.0_cRGB	\N	\N
33	original/SERIES-1/bPLATE_w_s1_z3_t1_cRGB.png	\N	\N
34	d1-1_t1.0_h3.0_cRGB	\N	\N
35	original/SERIES-1/bPLATE_w_s1_z6_t7_cRGB.png	\N	\N
36	d1-1_t7.0_h6.0_cRGB	\N	\N
37	original/SERIES-1/bPLATE_w_s1_z3_t3_cRGB.png	\N	\N
38	d1-1_t3.0_h3.0_cRGB	\N	\N
39	original/SERIES-1/bPLATE_w_s1_z0_t2_cRGB.png	\N	\N
40	d1-1_t2.0_h0.0_cRGB	\N	\N
41	original/SERIES-1/bPLATE_w_s1_z3_t5_cRGB.png	\N	\N
42	d1-1_t5.0_h3.0_cRGB	\N	\N
43	original/SERIES-1/bPLATE_w_s1_z6_t1_cRGB.png	\N	\N
44	d1-1_t1.0_h6.0_cRGB	\N	\N
45	original/SERIES-1/bPLATE_w_s1_z3_t8_cRGB.png	\N	\N
46	d1-1_t8.0_h3.0_cRGB	\N	\N
47	original/SERIES-1/bPLATE_w_s1_z0_t0_cRGB.png	\N	\N
48	d1-1_t0.0_h0.0_cRGB	\N	\N
49	original/SERIES-1/bPLATE_w_s1_z6_t4_cRGB.png	\N	\N
50	d1-1_t4.0_h6.0_cRGB	\N	\N
51	original/SERIES-1/bPLATE_w_s1_z3_t6_cRGB.png	\N	\N
52	d1-1_t6.0_h3.0_cRGB	\N	\N
53	original/SERIES-1/bPLATE_w_s1_z6_t6_cRGB.png	\N	\N
54	d1-1_t6.0_h6.0_cRGB	\N	\N
55	original/SERIES-1/bPLATE_w_s1_z3_t4_cRGB.png	\N	\N
56	d1-1_t4.0_h3.0_cRGB	\N	\N
57	original/SERIES-1/bPLATE_w_s1_z0_t3_cRGB.png	\N	\N
58	d1-1_t3.0_h0.0_cRGB	\N	\N
59	original/SERIES-1/bPLATE_w_s1_z0_t6_cRGB.png	\N	\N
60	d1-1_t6.0_h0.0_cRGB	\N	\N
\.


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

SELECT pg_catalog.setval('images_id_seq', 60, true);


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

COPY spots (id, x, y, cont_id) FROM stdin;
\.


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

SELECT pg_catalog.setval('spots_id_seq', 1, false);


--
-- Name: acquired_images_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY acquired_images
    ADD CONSTRAINT acquired_images_pkey PRIMARY KEY (id);


--
-- Name: analysis_data_sets_perm_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY analysis_data_sets
    ADD CONSTRAINT analysis_data_sets_perm_id_key UNIQUE (perm_id);


--
-- Name: analysis_data_sets_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY analysis_data_sets
    ADD CONSTRAINT analysis_data_sets_pkey PRIMARY KEY (id);


--
-- Name: channel_stacks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY channel_stacks
    ADD CONSTRAINT channel_stacks_pkey PRIMARY KEY (id);


--
-- Name: channels_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY channels
    ADD CONSTRAINT channels_pkey PRIMARY KEY (id);


--
-- Name: channels_uk_1; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY channels
    ADD CONSTRAINT channels_uk_1 UNIQUE (code, ds_id);


--
-- Name: channels_uk_2; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY channels
    ADD CONSTRAINT channels_uk_2 UNIQUE (code, exp_id);


--
-- Name: containers_perm_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY containers
    ADD CONSTRAINT containers_perm_id_key UNIQUE (perm_id);


--
-- Name: containers_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY containers
    ADD CONSTRAINT containers_pkey PRIMARY KEY (id);


--
-- Name: experiments_perm_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY experiments
    ADD CONSTRAINT experiments_perm_id_key UNIQUE (perm_id);


--
-- Name: experiments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY experiments
    ADD CONSTRAINT experiments_pkey PRIMARY KEY (id);


--
-- Name: feature_defs_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY feature_defs
    ADD CONSTRAINT feature_defs_pkey PRIMARY KEY (id);


--
-- Name: feature_defs_uk_1; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY feature_defs
    ADD CONSTRAINT feature_defs_uk_1 UNIQUE (code, ds_id);


--
-- Name: feature_values_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY feature_values
    ADD CONSTRAINT feature_values_pkey PRIMARY KEY (id);


--
-- Name: feature_vocabulary_terms_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY feature_vocabulary_terms
    ADD CONSTRAINT feature_vocabulary_terms_pkey PRIMARY KEY (id);


--
-- Name: image_data_sets_perm_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY image_data_sets
    ADD CONSTRAINT image_data_sets_perm_id_key UNIQUE (perm_id);


--
-- Name: image_data_sets_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY image_data_sets
    ADD CONSTRAINT image_data_sets_pkey PRIMARY KEY (id);


--
-- Name: image_transformations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY image_transformations
    ADD CONSTRAINT image_transformations_pkey PRIMARY KEY (id);


--
-- Name: image_transformations_uk_1; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY image_transformations
    ADD CONSTRAINT image_transformations_uk_1 UNIQUE (code, channel_id);


--
-- Name: image_zoom_level_transformations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY image_zoom_level_transformations
    ADD CONSTRAINT image_zoom_level_transformations_pkey PRIMARY KEY (id);


--
-- Name: image_zoom_levels_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY image_zoom_levels
    ADD CONSTRAINT image_zoom_levels_pkey PRIMARY KEY (id);


--
-- Name: images_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY images
    ADD CONSTRAINT images_pkey PRIMARY KEY (id);


--
-- Name: spots_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY spots
    ADD CONSTRAINT spots_pkey PRIMARY KEY (id);


--
-- Name: analysis_data_sets_cont_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX analysis_data_sets_cont_idx ON analysis_data_sets USING btree (cont_id);


--
-- Name: channel_stacks_dim_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX channel_stacks_dim_idx ON channel_stacks USING btree (x, y, z_in_m, t_in_sec);


--
-- Name: channel_stacks_ds_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX channel_stacks_ds_idx ON channel_stacks USING btree (ds_id);


--
-- Name: channel_stacks_spot_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX channel_stacks_spot_idx ON channel_stacks USING btree (spot_id);


--
-- Name: channels_ds_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX channels_ds_idx ON channels USING btree (ds_id);


--
-- Name: containers_expe_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX containers_expe_idx ON containers USING btree (expe_id);


--
-- Name: feature_defs_ds_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX feature_defs_ds_idx ON feature_defs USING btree (ds_id);


--
-- Name: feature_values_fd_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX feature_values_fd_idx ON feature_values USING btree (fd_id);


--
-- Name: feature_values_z_and_t_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX feature_values_z_and_t_idx ON feature_values USING btree (z_in_m, t_in_sec);


--
-- Name: feature_vocabulary_terms_fd_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX feature_vocabulary_terms_fd_idx ON feature_vocabulary_terms USING btree (fd_id);


--
-- Name: image_data_sets_cont_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX image_data_sets_cont_idx ON image_data_sets USING btree (cont_id);


--
-- Name: image_transformations_channels_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX image_transformations_channels_idx ON image_transformations USING btree (channel_id);


--
-- Name: image_zoom_level_transformations_zlid_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX image_zoom_level_transformations_zlid_idx ON image_zoom_level_transformations USING btree (zoom_level_id);


--
-- Name: image_zoom_levels_cont_fk_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX image_zoom_levels_cont_fk_idx ON image_zoom_levels USING btree (container_dataset_id);


--
-- Name: image_zoom_levels_phys_ds_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX image_zoom_levels_phys_ds_idx ON image_zoom_levels USING btree (physical_dataset_perm_id);


--
-- Name: images_channel_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX images_channel_idx ON acquired_images USING btree (channel_id);


--
-- Name: images_channel_stack_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX images_channel_stack_idx ON acquired_images USING btree (channel_stack_id);


--
-- Name: images_img_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX images_img_idx ON acquired_images USING btree (img_id);


--
-- Name: images_thumbnail_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX images_thumbnail_idx ON acquired_images USING btree (thumbnail_id);


--
-- Name: spots_cont_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX spots_cont_idx ON spots USING btree (cont_id);


--
-- Name: spots_coords_idx; Type: INDEX; Schema: public; Owner: -
--

CREATE INDEX spots_coords_idx ON spots USING btree (cont_id, x, y);


--
-- Name: channel_stacks_check; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER channel_stacks_check BEFORE INSERT OR UPDATE ON channel_stacks FOR EACH ROW EXECUTE PROCEDURE channel_stacks_check();


--
-- Name: empty_acquired_images; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER empty_acquired_images BEFORE UPDATE ON acquired_images FOR EACH ROW WHEN (((new.img_id IS NULL) AND (new.thumbnail_id IS NULL))) EXECUTE PROCEDURE delete_empty_acquired_images();


--
-- Name: image_transformations_default_check; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER image_transformations_default_check BEFORE INSERT OR UPDATE ON image_transformations FOR EACH ROW EXECUTE PROCEDURE image_transformations_default_check();


--
-- Name: unused_images; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER unused_images AFTER DELETE ON acquired_images FOR EACH ROW EXECUTE PROCEDURE delete_unused_images();


--
-- Name: unused_nulled_images; Type: TRIGGER; Schema: public; Owner: -
--

CREATE TRIGGER unused_nulled_images AFTER UPDATE ON acquired_images FOR EACH ROW EXECUTE PROCEDURE delete_unused_nulled_images();


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

ALTER TABLE ONLY analysis_data_sets
    ADD CONSTRAINT fk_analysis_data_set_1 FOREIGN KEY (cont_id) REFERENCES containers(id) ON UPDATE CASCADE ON DELETE CASCADE;


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

ALTER TABLE ONLY channel_stacks
    ADD CONSTRAINT fk_channel_stacks_1 FOREIGN KEY (spot_id) REFERENCES spots(id) ON UPDATE CASCADE ON DELETE CASCADE;


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

ALTER TABLE ONLY channel_stacks
    ADD CONSTRAINT fk_channel_stacks_2 FOREIGN KEY (ds_id) REFERENCES image_data_sets(id) ON UPDATE CASCADE ON DELETE CASCADE;


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

ALTER TABLE ONLY channels
    ADD CONSTRAINT fk_channels_1 FOREIGN KEY (ds_id) REFERENCES image_data_sets(id) ON UPDATE CASCADE ON DELETE CASCADE;


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

ALTER TABLE ONLY channels
    ADD CONSTRAINT fk_channels_2 FOREIGN KEY (exp_id) REFERENCES experiments(id) ON UPDATE CASCADE ON DELETE CASCADE;


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

ALTER TABLE ONLY feature_defs
    ADD CONSTRAINT fk_feature_defs_1 FOREIGN KEY (ds_id) REFERENCES analysis_data_sets(id) ON UPDATE CASCADE ON DELETE CASCADE;


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

ALTER TABLE ONLY feature_values
    ADD CONSTRAINT fk_feature_values_1 FOREIGN KEY (fd_id) REFERENCES feature_defs(id) ON UPDATE CASCADE ON DELETE CASCADE;


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

ALTER TABLE ONLY feature_vocabulary_terms
    ADD CONSTRAINT fk_feature_vocabulary_terms_1 FOREIGN KEY (fd_id) REFERENCES feature_defs(id) ON UPDATE CASCADE ON DELETE CASCADE;


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

ALTER TABLE ONLY image_data_sets
    ADD CONSTRAINT fk_image_data_set_1 FOREIGN KEY (cont_id) REFERENCES containers(id) ON UPDATE CASCADE ON DELETE CASCADE;


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

ALTER TABLE ONLY image_transformations
    ADD CONSTRAINT fk_image_transformations_channel FOREIGN KEY (channel_id) REFERENCES channels(id) ON UPDATE CASCADE ON DELETE CASCADE;


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

ALTER TABLE ONLY image_zoom_level_transformations
    ADD CONSTRAINT fk_image_zoom_level_transformations_1 FOREIGN KEY (zoom_level_id) REFERENCES image_zoom_levels(id) ON UPDATE CASCADE ON DELETE CASCADE;


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

ALTER TABLE ONLY image_zoom_level_transformations
    ADD CONSTRAINT fk_image_zoom_level_transformations_2 FOREIGN KEY (channel_id) REFERENCES channels(id) ON UPDATE CASCADE ON DELETE CASCADE;


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

ALTER TABLE ONLY image_zoom_levels
    ADD CONSTRAINT fk_image_zoom_levels_1 FOREIGN KEY (container_dataset_id) REFERENCES image_data_sets(id) ON UPDATE CASCADE ON DELETE CASCADE;


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

ALTER TABLE ONLY acquired_images
    ADD CONSTRAINT fk_images_1 FOREIGN KEY (channel_stack_id) REFERENCES channel_stacks(id) ON UPDATE CASCADE ON DELETE CASCADE;


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

ALTER TABLE ONLY acquired_images
    ADD CONSTRAINT fk_images_2 FOREIGN KEY (channel_id) REFERENCES channels(id) ON UPDATE CASCADE ON DELETE CASCADE;


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

ALTER TABLE ONLY acquired_images
    ADD CONSTRAINT fk_images_3 FOREIGN KEY (img_id) REFERENCES images(id) ON UPDATE CASCADE ON DELETE SET NULL;


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

ALTER TABLE ONLY acquired_images
    ADD CONSTRAINT fk_images_4 FOREIGN KEY (thumbnail_id) REFERENCES images(id) ON UPDATE CASCADE ON DELETE SET NULL;


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

ALTER TABLE ONLY containers
    ADD CONSTRAINT fk_sample_1 FOREIGN KEY (expe_id) REFERENCES experiments(id) ON UPDATE CASCADE ON DELETE CASCADE;


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

ALTER TABLE ONLY spots
    ADD CONSTRAINT fk_spot_1 FOREIGN KEY (cont_id) REFERENCES containers(id) ON UPDATE CASCADE ON DELETE CASCADE;


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

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


--
--

