--
--


--
-- 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, 'GREEN'::character varying, 'RED'::character varying, 'RED_GREEN'::character varying, 'RED_BLUE'::character varying, '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, 'GREEN'::character varying, '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: -; Tablespace: 
--

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

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

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

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

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: -; 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: experiments; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

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

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

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

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

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

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

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

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

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

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	1	2
3	5	6	\N	1	3
4	7	8	\N	2	1
5	9	10	\N	2	2
6	11	12	\N	2	3
7	13	14	\N	3	1
8	15	16	\N	3	2
9	17	18	\N	3	3
10	19	20	\N	4	1
11	21	22	\N	4	2
12	23	24	\N	4	3
13	25	26	\N	5	1
14	27	28	\N	5	2
15	29	30	\N	5	3
16	31	32	\N	6	1
17	33	34	\N	6	2
18	35	36	\N	6	3
\.


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

SELECT pg_catalog.setval('acquired_images_id_seq', 18, 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	2	1	\N	\N	\N	f	1	1
2	2	2	\N	\N	\N	f	1	1
3	1	1	\N	\N	\N	t	1	1
4	1	2	\N	\N	\N	f	1	1
5	3	1	\N	\N	\N	f	1	1
6	3	2	\N	\N	\N	f	1	1
\.


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

SELECT pg_catalog.setval('channel_stacks_id_seq', 6, 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	CY3	Cy3	\N	\N	255	0	0	1	\N
2	DAPI	DAPI	\N	\N	0	0	255	1	\N
3	GFP	GFP	\N	\N	0	255	0	1	\N
\.


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

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


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

COPY containers (id, perm_id, spots_width, spots_height, expe_id) FROM stdin;
1	20161010125004966-2	24	16	1
\.


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

SELECT pg_catalog.setval('containers_id_seq', 1, 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;
023	sql/imaging/postgresql/023/schema-023.sql	SUCCESS	2016-10-10 12:39:36.96	\\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: experiments; Type: TABLE DATA; Schema: public; Owner: -
--

COPY experiments (id, perm_id, image_transformer_factory) FROM stdin;
1	20161010125004951-1	\N
\.


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

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


--
-- 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	20161010125005326-6	3	2	\N	f	\N	\N	1
\.


--
-- 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	20161010125004966-3		1392	1040	8	\N
2	f	1	20161010125005326-4	thumbnails.h5ar	256	191	24	png
3	f	1	20161010125005326-5	thumbnails_512x512.h5ar	512	383	24	png
\.


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

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


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

COPY images (id, path, image_id, color) FROM stdin;
1	original/PLATE1/PLATE1_A01_02_Cy3.jpg	\N	\N
2	wA1_d2-1_cCy3	\N	\N
3	original/PLATE1/PLATE1_A01_02_DAPI.jpg	\N	\N
4	wA1_d2-1_cDAPI	\N	\N
5	original/PLATE1/PLATE1_A01_02_GFP.jpg	\N	\N
6	wA1_d2-1_cGFP	\N	\N
7	original/PLATE1/PLATE1_A01_05_Cy3.jpg	\N	\N
8	wA1_d2-2_cCy3	\N	\N
9	original/PLATE1/PLATE1_A01_05_DAPI.jpg	\N	\N
10	wA1_d2-2_cDAPI	\N	\N
11	original/PLATE1/PLATE1_A01_05_GFP.jpg	\N	\N
12	wA1_d2-2_cGFP	\N	\N
13	original/PLATE1/PLATE1_A01_01_Cy3.jpg	\N	\N
14	wA1_d1-1_cCy3	\N	\N
15	original/PLATE1/PLATE1_A01_01_DAPI.jpg	\N	\N
16	wA1_d1-1_cDAPI	\N	\N
17	original/PLATE1/PLATE1_A01_01_GFP.jpg	\N	\N
18	wA1_d1-1_cGFP	\N	\N
19	original/PLATE1/PLATE1_A01_04_Cy3.jpg	\N	\N
20	wA1_d1-2_cCy3	\N	\N
21	original/PLATE1/PLATE1_A01_04_DAPI.jpg	\N	\N
22	wA1_d1-2_cDAPI	\N	\N
23	original/PLATE1/PLATE1_A01_04_GFP.jpg	\N	\N
24	wA1_d1-2_cGFP	\N	\N
25	original/PLATE1/PLATE1_A01_03_Cy3.jpg	\N	\N
26	wA1_d3-1_cCy3	\N	\N
27	original/PLATE1/PLATE1_A01_03_DAPI.jpg	\N	\N
28	wA1_d3-1_cDAPI	\N	\N
29	original/PLATE1/PLATE1_A01_03_GFP.jpg	\N	\N
30	wA1_d3-1_cGFP	\N	\N
31	original/PLATE1/PLATE1_A01_06_Cy3.jpg	\N	\N
32	wA1_d3-2_cCy3	\N	\N
33	original/PLATE1/PLATE1_A01_06_DAPI.jpg	\N	\N
34	wA1_d3-2_cDAPI	\N	\N
35	original/PLATE1/PLATE1_A01_06_GFP.jpg	\N	\N
36	wA1_d3-2_cGFP	\N	\N
\.


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

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


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

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


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

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


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

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

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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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


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

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

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

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


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

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


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

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

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

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


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

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


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

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


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

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

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

CREATE INDEX channel_stacks_ds_idx ON channel_stacks USING btree (ds_id);


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

CREATE INDEX channel_stacks_spot_idx ON channel_stacks USING btree (spot_id);


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

CREATE INDEX channels_ds_idx ON channels USING btree (ds_id);


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

CREATE INDEX containers_expe_idx ON containers USING btree (expe_id);


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

CREATE INDEX feature_defs_ds_idx ON feature_defs USING btree (ds_id);


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

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

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

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

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

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

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

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

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

CREATE INDEX images_channel_idx ON acquired_images USING btree (channel_id);


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

CREATE INDEX images_channel_stack_idx ON acquired_images USING btree (channel_stack_id);


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

CREATE INDEX images_img_idx ON acquired_images USING btree (img_id);


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

CREATE INDEX images_thumbnail_idx ON acquired_images USING btree (thumbnail_id);


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

CREATE INDEX spots_cont_idx ON spots USING btree (cont_id);


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

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;
GRANT ALL ON SCHEMA public TO PUBLIC;


--
--

