--
--


-- Started on 2017-05-18 14:48:05 CEST

-- SET check_function_bodies = false;
-- SET client_min_messages = warning;
-- SET row_security = off;

--
-- TOC entry 15 (class 2615 OID 24074)
-- Name: fews; Type: SCHEMA; Schema: -; Owner: postgres
--

CREATE SCHEMA fews;


ALTER SCHEMA fews OWNER TO postgres;

--
-- TOC entry 14 (class 2615 OID 24075)
-- Name: monitoring; Type: SCHEMA; Schema: -; Owner: webapp
--

CREATE SCHEMA monitoring;


ALTER SCHEMA monitoring OWNER TO webapp;

--
-- TOC entry 9 (class 2615 OID 32859)
-- Name: ratingcurve; Type: SCHEMA; Schema: -; Owner: postgres
--

CREATE SCHEMA ratingcurve;


ALTER SCHEMA ratingcurve OWNER TO postgres;


--
-- TOC entry 1409 (class 1255 OID 24076)
-- Name: check_at_least_one_parameter_per_location(); Type: FUNCTION; Schema: fews; Owner: postgres
--

CREATE FUNCTION check_at_least_one_parameter_per_location() RETURNS trigger
    LANGUAGE plpgsql
    AS $$
  DECLARE paramcount integer;
    BEGIN
    select count(*) from fews.locationparameters where fews.locationparameters.locationkey = NEW.locationkey into paramcount;
    IF paramcount > 0 THEN 
        RETURN NEW;
    END IF;
    RAISE EXCEPTION 'location must have parameters, please insert into locationparameters first';
  END;    
  $$;


ALTER FUNCTION fews.check_at_least_one_parameter_per_location() OWNER TO postgres;


--
-- TOC entry 1410 (class 1255 OID 24077)
-- Name: pivotcode(character varying, character varying, character varying, character varying, character varying); Type: FUNCTION; Schema: monitoring; Owner: postgres
--

CREATE FUNCTION pivotcode(tablename character varying, rowc character varying, colc character varying, cellc character varying, celldatatype character varying) RETURNS character varying
    LANGUAGE plpgsql
    AS $$
  declare
      dynsql1 varchar;
      dynsql2 varchar;
      columnlist varchar;
  begin
      -- 1. retrieve list of column names.
      dynsql1 = 'select string_agg(distinct ''_''||'||colc||'||'' '||celldatatype||''','','' order by ''_''||'||colc||'||'' '||celldatatype||''') from '||tablename||';';
      execute dynsql1 into columnlist;
      -- 2. set up the crosstab query
      dynsql2 = 'select * from crosstab (
   ''select '||rowc||', '||colc||', '||cellc||' from '||tablename||' group by 1,2 order by 1,2'',
   ''select distinct '||colc||' from '||tablename||' order by 1''
   )
   as newtable (
   '||rowc||' varchar,'||columnlist||'
   );';
      return dynsql2;
  end
  $$;


ALTER FUNCTION monitoring.pivotcode(tablename character varying, rowc character varying, colc character varying, cellc character varying, celldatatype character varying) OWNER TO postgres;


--
-- TOC entry 215 (class 1259 OID 24078)
-- Name: AggregationPeriods_aggregationperiodkey_seq; Type: SEQUENCE; Schema: fews; Owner: postgres
--

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


ALTER TABLE "AggregationPeriods_aggregationperiodkey_seq" OWNER TO postgres;

--
-- TOC entry 216 (class 1259 OID 24080)
-- Name: FeatureClass_featureclasskey_seq; Type: SEQUENCE; Schema: fews; Owner: postgres
--

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


ALTER TABLE "FeatureClass_featureclasskey_seq" OWNER TO postgres;

--
-- TOC entry 217 (class 1259 OID 24082)
-- Name: Filters_filterkey_seq; Type: SEQUENCE; Schema: fews; Owner: postgres
--

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


ALTER TABLE "Filters_filterkey_seq" OWNER TO postgres;

--
-- TOC entry 218 (class 1259 OID 24084)
-- Name: Locations_locationkey_seq; Type: SEQUENCE; Schema: fews; Owner: postgres
--

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


ALTER TABLE "Locations_locationkey_seq" OWNER TO postgres;

--
-- TOC entry 219 (class 1259 OID 24086)
-- Name: ModuleInstances_moduleinstancekey_seq; Type: SEQUENCE; Schema: fews; Owner: postgres
--

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


ALTER TABLE "ModuleInstances_moduleinstancekey_seq" OWNER TO postgres;

--
-- TOC entry 220 (class 1259 OID 24088)
-- Name: ParameterGroups_groupkey_seq; Type: SEQUENCE; Schema: fews; Owner: postgres
--

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


ALTER TABLE "ParameterGroups_groupkey_seq" OWNER TO postgres;

--
-- TOC entry 221 (class 1259 OID 24090)
-- Name: ParametersTable_parameterkey_seq; Type: SEQUENCE; Schema: fews; Owner: postgres
--

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


ALTER TABLE "ParametersTable_parameterkey_seq" OWNER TO postgres;

--
-- TOC entry 222 (class 1259 OID 24092)
-- Name: QualifierSets_qualifiersetkey_seq; Type: SEQUENCE; Schema: fews; Owner: postgres
--

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


ALTER TABLE "QualifierSets_qualifiersetkey_seq" OWNER TO postgres;

--
-- TOC entry 223 (class 1259 OID 24094)
-- Name: Qualifiers_qualifierkey_seq; Type: SEQUENCE; Schema: fews; Owner: postgres
--

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


ALTER TABLE "Qualifiers_qualifierkey_seq" OWNER TO postgres;

--
-- TOC entry 224 (class 1259 OID 24096)
-- Name: TimeSeriesKeys_serieskey_seq; Type: SEQUENCE; Schema: fews; Owner: postgres
--

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


ALTER TABLE "TimeSeriesKeys_serieskey_seq" OWNER TO postgres;

--
-- TOC entry 225 (class 1259 OID 24098)
-- Name: TimeSteps_timestepkey_seq; Type: SEQUENCE; Schema: fews; Owner: postgres
--

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


ALTER TABLE "TimeSteps_timestepkey_seq" OWNER TO postgres;

--
-- TOC entry 226 (class 1259 OID 24100)
-- Name: Users_userkey_seq; Type: SEQUENCE; Schema: fews; Owner: postgres
--

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


ALTER TABLE "Users_userkey_seq" OWNER TO postgres;


--
-- TOC entry 227 (class 1259 OID 24102)
-- Name: aggregationperiods; Type: TABLE; Schema: fews; Owner: postgres
--

CREATE TABLE aggregationperiods (
    aggregationperiodkey integer DEFAULT nextval('"AggregationPeriods_aggregationperiodkey_seq"'::regclass) NOT NULL,
    id character varying(64) NOT NULL,
    description character varying(255)
);


ALTER TABLE aggregationperiods OWNER TO postgres;

--
-- TOC entry 228 (class 1259 OID 24106)
-- Name: dual; Type: VIEW; Schema: fews; Owner: webapp
--

CREATE VIEW dual AS
 SELECT ('now'::text)::date AS date;


ALTER TABLE dual OWNER TO webapp;

--
-- TOC entry 229 (class 1259 OID 24110)
-- Name: featureclass; Type: TABLE; Schema: fews; Owner: postgres
--

CREATE TABLE featureclass (
    featureclasskey integer DEFAULT nextval('"FeatureClass_featureclasskey_seq"'::regclass) NOT NULL,
    featureclassname text
);


ALTER TABLE featureclass OWNER TO postgres;

--
-- TOC entry 230 (class 1259 OID 24117)
-- Name: filters; Type: TABLE; Schema: fews; Owner: postgres
--

CREATE TABLE filters (
    filterkey integer DEFAULT nextval('"Filters_filterkey_seq"'::regclass) NOT NULL,
    id character varying(64) NOT NULL,
    name character varying(64),
    description character varying(255),
    parentfilterid character varying(64),
    validationiconsvisible integer NOT NULL,
    mapextentid character varying(64),
    viewpermission character varying(64),
    editpermission character varying(64)
);


ALTER TABLE filters OWNER TO postgres;

--
-- TOC entry 231 (class 1259 OID 24124)
-- Name: filtertimeserieskeys; Type: TABLE; Schema: fews; Owner: postgres
--

CREATE TABLE filtertimeserieskeys (
    filterkey integer NOT NULL,
    serieskey integer NOT NULL
);


ALTER TABLE filtertimeserieskeys OWNER TO postgres;

--
-- TOC entry 232 (class 1259 OID 24127)
-- Name: locations; Type: TABLE; Schema: fews; Owner: postgres
--

CREATE TABLE locations (
    locationkey integer DEFAULT nextval('"Locations_locationkey_seq"'::regclass) NOT NULL,
    id character varying(64) NOT NULL,
    name character varying(64),
    shortname character varying(64),
    description character varying(255),
    icon character varying(64),
    tooltip character varying(64),
    parentlocationid character varying(64),
    visibilitystarttime timestamp without time zone,
    visibilityendtime timestamp without time zone,
    x double precision NOT NULL,
    y double precision NOT NULL,
    z double precision,
    srid integer
);


ALTER TABLE locations OWNER TO postgres;

--
-- TOC entry 3773 (class 0 OID 0)
-- Dependencies: 232
-- Name: COLUMN locations.x; Type: COMMENT; Schema: fews; Owner: postgres
--

COMMENT ON COLUMN locations.x IS 'Coordinates are in local reference system';


--
-- TOC entry 3774 (class 0 OID 0)
-- Dependencies: 232
-- Name: COLUMN locations.y; Type: COMMENT; Schema: fews; Owner: postgres
--

COMMENT ON COLUMN locations.y IS 'Coordinates are in local reference system';


--
-- TOC entry 3775 (class 0 OID 0)
-- Dependencies: 232
-- Name: COLUMN locations.srid; Type: COMMENT; Schema: fews; Owner: postgres
--

COMMENT ON COLUMN locations.srid IS 'SRID code for the values in the ''x'' & ''y'' columns';


--
-- TOC entry 233 (class 1259 OID 24134)
-- Name: moduleinstances; Type: TABLE; Schema: fews; Owner: postgres
--

CREATE TABLE moduleinstances (
    moduleinstancekey integer DEFAULT nextval('"ModuleInstances_moduleinstancekey_seq"'::regclass) NOT NULL,
    id character varying(64) NOT NULL,
    name character varying(64),
    description character varying(255)
);


ALTER TABLE moduleinstances OWNER TO postgres;

--
-- TOC entry 234 (class 1259 OID 24138)
-- Name: parametergroups; Type: TABLE; Schema: fews; Owner: postgres
--

CREATE TABLE parametergroups (
    groupkey integer DEFAULT nextval('"ParameterGroups_groupkey_seq"'::regclass) NOT NULL,
    id character varying(64) NOT NULL,
    name character varying(64),
    description character varying(255),
    parametertype character varying(64) NOT NULL,
    unit character varying(64),
    displayunit character varying(64)
);


ALTER TABLE parametergroups OWNER TO postgres;

--
-- TOC entry 235 (class 1259 OID 24145)
-- Name: parameterstable; Type: TABLE; Schema: fews; Owner: postgres
--

CREATE TABLE parameterstable (
    parameterkey integer DEFAULT nextval('"ParametersTable_parameterkey_seq"'::regclass) NOT NULL,
    groupkey integer NOT NULL,
    id character varying(64) NOT NULL,
    name character varying(64),
    shortname character varying(64),
    description character varying(255),
    valueresolution double precision,
    attributea character varying(64),
    attributeb double precision,
    featureclasskey integer NOT NULL
);


ALTER TABLE parameterstable OWNER TO postgres;

--
-- TOC entry 236 (class 1259 OID 24152)
-- Name: qualifiers; Type: TABLE; Schema: fews; Owner: postgres
--

CREATE TABLE qualifiers (
    qualifierkey integer DEFAULT nextval('"Qualifiers_qualifierkey_seq"'::regclass) NOT NULL,
    id character varying(64) NOT NULL,
    name character varying(64),
    shortname character varying(64),
    description character varying(255)
);


ALTER TABLE qualifiers OWNER TO postgres;

--
-- TOC entry 237 (class 1259 OID 24156)
-- Name: qualifiersets; Type: TABLE; Schema: fews; Owner: postgres
--

CREATE TABLE qualifiersets (
    qualifiersetkey integer DEFAULT nextval('"QualifierSets_qualifiersetkey_seq"'::regclass) NOT NULL,
    id character varying(64) NOT NULL,
    qualifierkey1 integer NOT NULL,
    qualifierkey2 integer,
    qualifierkey3 integer,
    qualifierkey4 integer
);


ALTER TABLE qualifiersets OWNER TO postgres;

--
-- TOC entry 238 (class 1259 OID 24160)
-- Name: samples; Type: TABLE; Schema: fews; Owner: postgres
--

CREATE TABLE samples (
    locationkey integer NOT NULL,
    datetime timestamp without time zone NOT NULL,
    id character varying(64) NOT NULL,
    description character varying(255)
);


ALTER TABLE samples OWNER TO postgres;

--
-- TOC entry 239 (class 1259 OID 24163)
-- Name: stations; Type: VIEW; Schema: fews; Owner: postgres
--

CREATE VIEW stations AS
 SELECT locations.locationkey AS stationkey,
    locations.id AS station_id,
    locations.name AS station_name,
    public.st_transform(public.st_setsrid(public.st_point(locations.x, locations.y), locations.srid), 4326) AS geom
   FROM locations;


ALTER TABLE stations OWNER TO postgres;

--
-- TOC entry 240 (class 1259 OID 24167)
-- Name: timeseriescomments; Type: TABLE; Schema: fews; Owner: postgres
--

CREATE TABLE timeseriescomments (
    serieskey integer NOT NULL,
    datetime timestamp without time zone NOT NULL,
    commenttext character varying(64) NOT NULL
);


ALTER TABLE timeseriescomments OWNER TO postgres;

--
-- TOC entry 241 (class 1259 OID 24170)
-- Name: timeserieskeys; Type: TABLE; Schema: fews; Owner: postgres
--

CREATE TABLE timeserieskeys (
    serieskey integer DEFAULT nextval('"TimeSeriesKeys_serieskey_seq"'::regclass) NOT NULL,
    locationkey integer NOT NULL,
    parameterkey integer NOT NULL,
    qualifiersetkey integer,
    moduleinstancekey integer NOT NULL,
    timestepkey integer NOT NULL,
    aggregationperiodkey integer,
    valuetype integer DEFAULT 0 NOT NULL,
    modificationtime timestamp without time zone NOT NULL
);


ALTER TABLE timeserieskeys OWNER TO postgres;

--
-- TOC entry 242 (class 1259 OID 24175)
-- Name: timeseriesmanualeditshistory; Type: TABLE; Schema: fews; Owner: postgres
--

CREATE TABLE timeseriesmanualeditshistory (
    serieskey integer NOT NULL,
    editdatetime timestamp without time zone NOT NULL,
    datetime timestamp without time zone NOT NULL,
    userkey integer,
    scalarvalue double precision,
    flags integer NOT NULL,
    commenttext character varying(64),
    id integer
);


ALTER TABLE timeseriesmanualeditshistory OWNER TO postgres;

--
-- TOC entry 243 (class 1259 OID 24178)
-- Name: timeseriesvaluesandflags; Type: TABLE; Schema: fews; Owner: postgres
--

CREATE TABLE timeseriesvaluesandflags (
    serieskey integer NOT NULL,
    datetime timestamp without time zone NOT NULL,
    scalarvalue double precision,
    flags integer NOT NULL
);


ALTER TABLE timeseriesvaluesandflags OWNER TO postgres;

--
-- TOC entry 244 (class 1259 OID 24181)
-- Name: timesteps; Type: TABLE; Schema: fews; Owner: postgres
--

CREATE TABLE timesteps (
    timestepkey integer DEFAULT nextval('"TimeSteps_timestepkey_seq"'::regclass) NOT NULL,
    id character varying(64) NOT NULL,
    label character varying(64)
);


ALTER TABLE timesteps OWNER TO postgres;

--
-- TOC entry 245 (class 1259 OID 24185)
-- Name: users; Type: TABLE; Schema: fews; Owner: postgres
--

CREATE TABLE users (
    userkey integer DEFAULT nextval('"Users_userkey_seq"'::regclass) NOT NULL,
    id character varying(64) NOT NULL,
    name character varying(64)
);


ALTER TABLE users OWNER TO postgres;

--
-- TOC entry 246 (class 1259 OID 24189)
-- Name: wgslocations; Type: VIEW; Schema: fews; Owner: postgres
--

CREATE VIEW wgslocations AS
 SELECT locations.locationkey,
    locations.id,
    locations.name,
    locations.shortname,
    locations.description,
    locations.icon,
    locations.tooltip,
    locations.parentlocationid,
    locations.visibilitystarttime,
    locations.visibilityendtime,
    public.st_x(public.st_transform(public.st_setsrid(public.st_point(locations.x, locations.y), locations.srid), 4326)) AS x,
    public.st_y(public.st_transform(public.st_setsrid(public.st_point(locations.x, locations.y), locations.srid), 4326)) AS y,
    locations.z
   FROM locations;


ALTER TABLE wgslocations OWNER TO postgres;


--
-- TOC entry 247 (class 1259 OID 24193)
-- Name: dump; Type: TABLE; Schema: monitoring; Owner: webapp
--

CREATE TABLE dump (
    id integer NOT NULL,
    datetime timestamp without time zone,
    scalarvalue double precision,
    parameterid character varying(64),
    locationid character varying(64),
    flags integer,
    commenttext character varying(64)
);


ALTER TABLE dump OWNER TO webapp;

--
-- TOC entry 248 (class 1259 OID 24196)
-- Name: dump_id_seq; Type: SEQUENCE; Schema: monitoring; Owner: webapp
--

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


ALTER TABLE dump_id_seq OWNER TO webapp;

--
-- TOC entry 3791 (class 0 OID 0)
-- Dependencies: 248
-- Name: dump_id_seq; Type: SEQUENCE OWNED BY; Schema: monitoring; Owner: webapp
--

ALTER SEQUENCE dump_id_seq OWNED BY dump.id;



--
-- TOC entry 250 (class 1259 OID 32860)
-- Name: Period_periodkey_seq; Type: SEQUENCE; Schema: ratingcurve; Owner: postgres
--

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


ALTER TABLE "Period_periodkey_seq" OWNER TO postgres;

--
-- TOC entry 251 (class 1259 OID 32862)
-- Name: Segment_segmentkey_seq; Type: SEQUENCE; Schema: ratingcurve; Owner: postgres
--

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


ALTER TABLE "Segment_segmentkey_seq" OWNER TO postgres;

--
-- TOC entry 252 (class 1259 OID 32864)
-- Name: period; Type: TABLE; Schema: ratingcurve; Owner: postgres
--

CREATE TABLE period (
    periodkey integer DEFAULT nextval('"Period_periodkey_seq"'::regclass) NOT NULL,
    locationkey integer NOT NULL,
    start timestamp without time zone NOT NULL
);


ALTER TABLE period OWNER TO postgres;

--
-- TOC entry 253 (class 1259 OID 32868)
-- Name: segment; Type: TABLE; Schema: ratingcurve; Owner: postgres
--

CREATE TABLE segment (
    segmentkey integer DEFAULT nextval('"Segment_segmentkey_seq"'::regclass) NOT NULL,
    periodkey integer NOT NULL,
    low double precision NOT NULL,
    a_coef double precision NOT NULL,
    b_coef double precision NOT NULL,
    c_coef double precision NOT NULL
);


ALTER TABLE segment OWNER TO postgres;

--
-- TOC entry 3793 (class 0 OID 0)
-- Dependencies: 253
-- Name: COLUMN segment.b_coef; Type: COMMENT; Schema: ratingcurve; Owner: postgres
--

COMMENT ON COLUMN segment.b_coef IS 'h0 value';


--
-- TOC entry 3794 (class 0 OID 0)
-- Dependencies: 253
-- Name: COLUMN segment.c_coef; Type: COMMENT; Schema: ratingcurve; Owner: postgres
--

COMMENT ON COLUMN segment.c_coef IS 'Also known as alfa';



--
-- TOC entry 3551 (class 2604 OID 24198)
-- Name: id; Type: DEFAULT; Schema: monitoring; Owner: webapp
--

ALTER TABLE ONLY dump ALTER COLUMN id SET DEFAULT nextval('dump_id_seq'::regclass);



--
-- TOC entry 3555 (class 2606 OID 24200)
-- Name: pk_aggregationper; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY aggregationperiods
    ADD CONSTRAINT pk_aggregationper PRIMARY KEY (aggregationperiodkey);


--
-- TOC entry 3559 (class 2606 OID 24202)
-- Name: pk_featureclass; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY featureclass
    ADD CONSTRAINT pk_featureclass PRIMARY KEY (featureclasskey);


--
-- TOC entry 3561 (class 2606 OID 24204)
-- Name: pk_filters; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY filters
    ADD CONSTRAINT pk_filters PRIMARY KEY (filterkey);


--
-- TOC entry 3565 (class 2606 OID 24206)
-- Name: pk_filtertimeseriesk; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY filtertimeserieskeys
    ADD CONSTRAINT pk_filtertimeseriesk PRIMARY KEY (filterkey, serieskey);


--
-- TOC entry 3567 (class 2606 OID 24208)
-- Name: pk_locations; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY locations
    ADD CONSTRAINT pk_locations PRIMARY KEY (locationkey);


--
-- TOC entry 3571 (class 2606 OID 24210)
-- Name: pk_moduleinstances; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY moduleinstances
    ADD CONSTRAINT pk_moduleinstances PRIMARY KEY (moduleinstancekey);


--
-- TOC entry 3575 (class 2606 OID 24212)
-- Name: pk_parametergroups; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY parametergroups
    ADD CONSTRAINT pk_parametergroups PRIMARY KEY (groupkey);


--
-- TOC entry 3579 (class 2606 OID 24214)
-- Name: pk_parameterstable; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY parameterstable
    ADD CONSTRAINT pk_parameterstable PRIMARY KEY (parameterkey);


--
-- TOC entry 3583 (class 2606 OID 24216)
-- Name: pk_qualifiers; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY qualifiers
    ADD CONSTRAINT pk_qualifiers PRIMARY KEY (qualifierkey);


--
-- TOC entry 3587 (class 2606 OID 24218)
-- Name: pk_qualifiersets; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY qualifiersets
    ADD CONSTRAINT pk_qualifiersets PRIMARY KEY (qualifiersetkey);


--
-- TOC entry 3591 (class 2606 OID 24220)
-- Name: pk_samples; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY samples
    ADD CONSTRAINT pk_samples PRIMARY KEY (locationkey, datetime);


--
-- TOC entry 3593 (class 2606 OID 24222)
-- Name: pk_timeseriescomments; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY timeseriescomments
    ADD CONSTRAINT pk_timeseriescomments PRIMARY KEY (serieskey, datetime);


--
-- TOC entry 3595 (class 2606 OID 24224)
-- Name: pk_timeserieskeys; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY timeserieskeys
    ADD CONSTRAINT pk_timeserieskeys PRIMARY KEY (serieskey);


--
-- TOC entry 3599 (class 2606 OID 24226)
-- Name: pk_timeseriesmanualedits; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY timeseriesmanualeditshistory
    ADD CONSTRAINT pk_timeseriesmanualedits PRIMARY KEY (serieskey, datetime, editdatetime);


--
-- TOC entry 3601 (class 2606 OID 24228)
-- Name: pk_timeseriesvaluesandflags; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY timeseriesvaluesandflags
    ADD CONSTRAINT pk_timeseriesvaluesandflags PRIMARY KEY (serieskey, datetime);


--
-- TOC entry 3603 (class 2606 OID 24230)
-- Name: pk_timesteps; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY timesteps
    ADD CONSTRAINT pk_timesteps PRIMARY KEY (timestepkey);


--
-- TOC entry 3607 (class 2606 OID 24232)
-- Name: pk_users; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY users
    ADD CONSTRAINT pk_users PRIMARY KEY (userkey);


--
-- TOC entry 3557 (class 2606 OID 24234)
-- Name: uniq_aggregationper_id; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY aggregationperiods
    ADD CONSTRAINT uniq_aggregationper_id UNIQUE (id);


--
-- TOC entry 3563 (class 2606 OID 24236)
-- Name: uniq_filters_id; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY filters
    ADD CONSTRAINT uniq_filters_id UNIQUE (id);


--
-- TOC entry 3569 (class 2606 OID 24238)
-- Name: uniq_locations_id; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY locations
    ADD CONSTRAINT uniq_locations_id UNIQUE (id);


--
-- TOC entry 3573 (class 2606 OID 24240)
-- Name: uniq_moduleinstances_id; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY moduleinstances
    ADD CONSTRAINT uniq_moduleinstances_id UNIQUE (id);


--
-- TOC entry 3577 (class 2606 OID 24242)
-- Name: uniq_parametergroups_id; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY parametergroups
    ADD CONSTRAINT uniq_parametergroups_id UNIQUE (id);


--
-- TOC entry 3581 (class 2606 OID 24244)
-- Name: uniq_parameterstable_id; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY parameterstable
    ADD CONSTRAINT uniq_parameterstable_id UNIQUE (id);


--
-- TOC entry 3585 (class 2606 OID 24246)
-- Name: uniq_qualifiers_id; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY qualifiers
    ADD CONSTRAINT uniq_qualifiers_id UNIQUE (id);


--
-- TOC entry 3589 (class 2606 OID 24248)
-- Name: uniq_qualifiersets_id; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY qualifiersets
    ADD CONSTRAINT uniq_qualifiersets_id UNIQUE (id);


--
-- TOC entry 3597 (class 2606 OID 24250)
-- Name: uniq_timeserieskey_compound; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY timeserieskeys
    ADD CONSTRAINT uniq_timeserieskey_compound UNIQUE (locationkey, parameterkey, qualifiersetkey, moduleinstancekey, timestepkey, aggregationperiodkey);


--
-- TOC entry 3605 (class 2606 OID 24252)
-- Name: uniq_timesteps_id; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY timesteps
    ADD CONSTRAINT uniq_timesteps_id UNIQUE (id);


--
-- TOC entry 3609 (class 2606 OID 24254)
-- Name: uniq_users_id; Type: CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY users
    ADD CONSTRAINT uniq_users_id UNIQUE (id);



--
-- TOC entry 3611 (class 2606 OID 24256)
-- Name: dump_pkey; Type: CONSTRAINT; Schema: monitoring; Owner: webapp
--

ALTER TABLE ONLY dump
    ADD CONSTRAINT dump_pkey PRIMARY KEY (id);



--
-- TOC entry 3613 (class 2606 OID 32873)
-- Name: pk_period; Type: CONSTRAINT; Schema: ratingcurve; Owner: postgres
--

ALTER TABLE ONLY period
    ADD CONSTRAINT pk_period PRIMARY KEY (periodkey);


--
-- TOC entry 3615 (class 2606 OID 32880)
-- Name: pk_segment; Type: CONSTRAINT; Schema: ratingcurve; Owner: postgres
--

ALTER TABLE ONLY segment
    ADD CONSTRAINT pk_segment PRIMARY KEY (segmentkey);



--
-- TOC entry 3616 (class 2606 OID 24257)
-- Name: fk_filtertimeseriesk_filterkey; Type: FK CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY filtertimeserieskeys
    ADD CONSTRAINT fk_filtertimeseriesk_filterkey FOREIGN KEY (filterkey) REFERENCES filters(filterkey);


--
-- TOC entry 3617 (class 2606 OID 24262)
-- Name: fk_filtertimeseriesk_serieskey; Type: FK CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY filtertimeserieskeys
    ADD CONSTRAINT fk_filtertimeseriesk_serieskey FOREIGN KEY (serieskey) REFERENCES timeserieskeys(serieskey);


--
-- TOC entry 3618 (class 2606 OID 24462)
-- Name: fk_locationst_srid; Type: FK CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY locations
    ADD CONSTRAINT fk_locationst_srid FOREIGN KEY (srid) REFERENCES public.spatial_ref_sys(srid);


--
-- TOC entry 3619 (class 2606 OID 24267)
-- Name: fk_parameterst_featureclasskey; Type: FK CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY parameterstable
    ADD CONSTRAINT fk_parameterst_featureclasskey FOREIGN KEY (featureclasskey) REFERENCES featureclass(featureclasskey);


--
-- TOC entry 3620 (class 2606 OID 24272)
-- Name: fk_parameterst_groupkey; Type: FK CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY parameterstable
    ADD CONSTRAINT fk_parameterst_groupkey FOREIGN KEY (groupkey) REFERENCES parametergroups(groupkey);


--
-- TOC entry 3621 (class 2606 OID 24277)
-- Name: fk_qualifiersets_qualifierkey1; Type: FK CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY qualifiersets
    ADD CONSTRAINT fk_qualifiersets_qualifierkey1 FOREIGN KEY (qualifierkey1) REFERENCES qualifiers(qualifierkey);


--
-- TOC entry 3622 (class 2606 OID 24282)
-- Name: fk_qualifiersets_qualifierkey2; Type: FK CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY qualifiersets
    ADD CONSTRAINT fk_qualifiersets_qualifierkey2 FOREIGN KEY (qualifierkey2) REFERENCES qualifiers(qualifierkey);


--
-- TOC entry 3623 (class 2606 OID 24287)
-- Name: fk_qualifiersets_qualifierkey3; Type: FK CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY qualifiersets
    ADD CONSTRAINT fk_qualifiersets_qualifierkey3 FOREIGN KEY (qualifierkey3) REFERENCES qualifiers(qualifierkey);


--
-- TOC entry 3624 (class 2606 OID 24292)
-- Name: fk_qualifiersets_qualifierkey4; Type: FK CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY qualifiersets
    ADD CONSTRAINT fk_qualifiersets_qualifierkey4 FOREIGN KEY (qualifierkey4) REFERENCES qualifiers(qualifierkey);


--
-- TOC entry 3625 (class 2606 OID 24297)
-- Name: fk_samples; Type: FK CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY samples
    ADD CONSTRAINT fk_samples FOREIGN KEY (locationkey) REFERENCES locations(locationkey);


--
-- TOC entry 3626 (class 2606 OID 24302)
-- Name: fk_timeseriescomments; Type: FK CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY timeseriescomments
    ADD CONSTRAINT fk_timeseriescomments FOREIGN KEY (serieskey) REFERENCES timeserieskeys(serieskey);


--
-- TOC entry 3632 (class 2606 OID 24307)
-- Name: fk_timeserieskeys_aggperkey; Type: FK CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY timeserieskeys
    ADD CONSTRAINT fk_timeserieskeys_aggperkey FOREIGN KEY (aggregationperiodkey) REFERENCES aggregationperiods(aggregationperiodkey);


--
-- TOC entry 3627 (class 2606 OID 24312)
-- Name: fk_timeserieskeys_locationkey; Type: FK CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY timeserieskeys
    ADD CONSTRAINT fk_timeserieskeys_locationkey FOREIGN KEY (locationkey) REFERENCES locations(locationkey);


--
-- TOC entry 3628 (class 2606 OID 24317)
-- Name: fk_timeserieskeys_modinskey; Type: FK CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY timeserieskeys
    ADD CONSTRAINT fk_timeserieskeys_modinskey FOREIGN KEY (moduleinstancekey) REFERENCES moduleinstances(moduleinstancekey);


--
-- TOC entry 3629 (class 2606 OID 24322)
-- Name: fk_timeserieskeys_paramkey; Type: FK CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY timeserieskeys
    ADD CONSTRAINT fk_timeserieskeys_paramkey FOREIGN KEY (parameterkey) REFERENCES parameterstable(parameterkey);


--
-- TOC entry 3630 (class 2606 OID 24327)
-- Name: fk_timeserieskeys_qualsetkey; Type: FK CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY timeserieskeys
    ADD CONSTRAINT fk_timeserieskeys_qualsetkey FOREIGN KEY (qualifiersetkey) REFERENCES qualifiersets(qualifiersetkey);


--
-- TOC entry 3631 (class 2606 OID 24332)
-- Name: fk_timeserieskeys_timestepkey; Type: FK CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY timeserieskeys
    ADD CONSTRAINT fk_timeserieskeys_timestepkey FOREIGN KEY (timestepkey) REFERENCES timesteps(timestepkey);


--
-- TOC entry 3633 (class 2606 OID 24337)
-- Name: fk_timeseriesmane_serieskey; Type: FK CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY timeseriesmanualeditshistory
    ADD CONSTRAINT fk_timeseriesmane_serieskey FOREIGN KEY (serieskey) REFERENCES timeserieskeys(serieskey);


--
-- TOC entry 3634 (class 2606 OID 24342)
-- Name: fk_timeseriesmane_userkey; Type: FK CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY timeseriesmanualeditshistory
    ADD CONSTRAINT fk_timeseriesmane_userkey FOREIGN KEY (userkey) REFERENCES users(userkey);


--
-- TOC entry 3635 (class 2606 OID 24347)
-- Name: fk_timeseriesvaluesandflags; Type: FK CONSTRAINT; Schema: fews; Owner: postgres
--

ALTER TABLE ONLY timeseriesvaluesandflags
    ADD CONSTRAINT fk_timeseriesvaluesandflags FOREIGN KEY (serieskey) REFERENCES timeserieskeys(serieskey);



--
-- TOC entry 3636 (class 2606 OID 32874)
-- Name: fk_period_location; Type: FK CONSTRAINT; Schema: ratingcurve; Owner: postgres
--

ALTER TABLE ONLY period
    ADD CONSTRAINT fk_period_location FOREIGN KEY (locationkey) REFERENCES fews.locations(locationkey);


--
-- TOC entry 3637 (class 2606 OID 32881)
-- Name: fk_segment_period; Type: FK CONSTRAINT; Schema: ratingcurve; Owner: postgres
--

ALTER TABLE ONLY segment
    ADD CONSTRAINT fk_segment_period FOREIGN KEY (periodkey) REFERENCES period(periodkey);


--
-- TOC entry 3766 (class 0 OID 0)
-- Dependencies: 15
-- Name: fews; Type: ACL; Schema: -; Owner: postgres
--

REVOKE ALL ON SCHEMA fews FROM PUBLIC;
REVOKE ALL ON SCHEMA fews FROM postgres;
GRANT ALL ON SCHEMA fews TO postgres;
GRANT ALL ON SCHEMA fews TO webapp;


--
-- TOC entry 3767 (class 0 OID 0)
-- Dependencies: 9
-- Name: ratingcurve; Type: ACL; Schema: -; Owner: postgres
--

REVOKE ALL ON SCHEMA ratingcurve FROM PUBLIC;
REVOKE ALL ON SCHEMA ratingcurve FROM postgres;
GRANT ALL ON SCHEMA ratingcurve TO postgres;
GRANT ALL ON SCHEMA ratingcurve TO webapp;



--
-- TOC entry 3768 (class 0 OID 0)
-- Dependencies: 227
-- Name: aggregationperiods; Type: ACL; Schema: fews; Owner: postgres
--

REVOKE ALL ON TABLE aggregationperiods FROM PUBLIC;
REVOKE ALL ON TABLE aggregationperiods FROM postgres;
GRANT ALL ON TABLE aggregationperiods TO postgres;
GRANT SELECT ON TABLE aggregationperiods TO webapp;


--
-- TOC entry 3769 (class 0 OID 0)
-- Dependencies: 228
-- Name: dual; Type: ACL; Schema: fews; Owner: webapp
--

REVOKE ALL ON TABLE dual FROM PUBLIC;
REVOKE ALL ON TABLE dual FROM webapp;
GRANT ALL ON TABLE dual TO webapp;


--
-- TOC entry 3770 (class 0 OID 0)
-- Dependencies: 229
-- Name: featureclass; Type: ACL; Schema: fews; Owner: postgres
--

REVOKE ALL ON TABLE featureclass FROM PUBLIC;
REVOKE ALL ON TABLE featureclass FROM postgres;
GRANT ALL ON TABLE featureclass TO postgres;
GRANT SELECT ON TABLE featureclass TO webapp;


--
-- TOC entry 3771 (class 0 OID 0)
-- Dependencies: 230
-- Name: filters; Type: ACL; Schema: fews; Owner: postgres
--

REVOKE ALL ON TABLE filters FROM PUBLIC;
REVOKE ALL ON TABLE filters FROM postgres;
GRANT ALL ON TABLE filters TO postgres;
GRANT SELECT ON TABLE filters TO webapp;


--
-- TOC entry 3772 (class 0 OID 0)
-- Dependencies: 231
-- Name: filtertimeserieskeys; Type: ACL; Schema: fews; Owner: postgres
--

REVOKE ALL ON TABLE filtertimeserieskeys FROM PUBLIC;
REVOKE ALL ON TABLE filtertimeserieskeys FROM postgres;
GRANT ALL ON TABLE filtertimeserieskeys TO postgres;
GRANT SELECT ON TABLE filtertimeserieskeys TO webapp;


--
-- TOC entry 3776 (class 0 OID 0)
-- Dependencies: 232
-- Name: locations; Type: ACL; Schema: fews; Owner: postgres
--

REVOKE ALL ON TABLE locations FROM PUBLIC;
REVOKE ALL ON TABLE locations FROM postgres;
GRANT ALL ON TABLE locations TO postgres;
GRANT SELECT ON TABLE locations TO webapp;


--
-- TOC entry 3777 (class 0 OID 0)
-- Dependencies: 233
-- Name: moduleinstances; Type: ACL; Schema: fews; Owner: postgres
--

REVOKE ALL ON TABLE moduleinstances FROM PUBLIC;
REVOKE ALL ON TABLE moduleinstances FROM postgres;
GRANT ALL ON TABLE moduleinstances TO postgres;
GRANT SELECT ON TABLE moduleinstances TO webapp;


--
-- TOC entry 3778 (class 0 OID 0)
-- Dependencies: 234
-- Name: parametergroups; Type: ACL; Schema: fews; Owner: postgres
--

REVOKE ALL ON TABLE parametergroups FROM PUBLIC;
REVOKE ALL ON TABLE parametergroups FROM postgres;
GRANT ALL ON TABLE parametergroups TO postgres;
GRANT SELECT ON TABLE parametergroups TO webapp;


--
-- TOC entry 3779 (class 0 OID 0)
-- Dependencies: 235
-- Name: parameterstable; Type: ACL; Schema: fews; Owner: postgres
--

REVOKE ALL ON TABLE parameterstable FROM PUBLIC;
REVOKE ALL ON TABLE parameterstable FROM postgres;
GRANT ALL ON TABLE parameterstable TO postgres;
GRANT SELECT ON TABLE parameterstable TO webapp;


--
-- TOC entry 3780 (class 0 OID 0)
-- Dependencies: 236
-- Name: qualifiers; Type: ACL; Schema: fews; Owner: postgres
--

REVOKE ALL ON TABLE qualifiers FROM PUBLIC;
REVOKE ALL ON TABLE qualifiers FROM postgres;
GRANT ALL ON TABLE qualifiers TO postgres;
GRANT SELECT ON TABLE qualifiers TO webapp;


--
-- TOC entry 3781 (class 0 OID 0)
-- Dependencies: 237
-- Name: qualifiersets; Type: ACL; Schema: fews; Owner: postgres
--

REVOKE ALL ON TABLE qualifiersets FROM PUBLIC;
REVOKE ALL ON TABLE qualifiersets FROM postgres;
GRANT ALL ON TABLE qualifiersets TO postgres;
GRANT SELECT ON TABLE qualifiersets TO webapp;


--
-- TOC entry 3782 (class 0 OID 0)
-- Dependencies: 238
-- Name: samples; Type: ACL; Schema: fews; Owner: postgres
--

REVOKE ALL ON TABLE samples FROM PUBLIC;
REVOKE ALL ON TABLE samples FROM postgres;
GRANT ALL ON TABLE samples TO postgres;
GRANT SELECT ON TABLE samples TO webapp;


--
-- TOC entry 3783 (class 0 OID 0)
-- Dependencies: 239
-- Name: stations; Type: ACL; Schema: fews; Owner: postgres
--

REVOKE ALL ON TABLE stations FROM PUBLIC;
REVOKE ALL ON TABLE stations FROM postgres;
GRANT ALL ON TABLE stations TO postgres;
GRANT SELECT ON TABLE stations TO webapp;


--
-- TOC entry 3784 (class 0 OID 0)
-- Dependencies: 240
-- Name: timeseriescomments; Type: ACL; Schema: fews; Owner: postgres
--

REVOKE ALL ON TABLE timeseriescomments FROM PUBLIC;
REVOKE ALL ON TABLE timeseriescomments FROM postgres;
GRANT ALL ON TABLE timeseriescomments TO postgres;
GRANT SELECT ON TABLE timeseriescomments TO webapp;


--
-- TOC entry 3785 (class 0 OID 0)
-- Dependencies: 241
-- Name: timeserieskeys; Type: ACL; Schema: fews; Owner: postgres
--

REVOKE ALL ON TABLE timeserieskeys FROM PUBLIC;
REVOKE ALL ON TABLE timeserieskeys FROM postgres;
GRANT ALL ON TABLE timeserieskeys TO postgres;
GRANT SELECT ON TABLE timeserieskeys TO webapp;


--
-- TOC entry 3786 (class 0 OID 0)
-- Dependencies: 242
-- Name: timeseriesmanualeditshistory; Type: ACL; Schema: fews; Owner: postgres
--

REVOKE ALL ON TABLE timeseriesmanualeditshistory FROM PUBLIC;
REVOKE ALL ON TABLE timeseriesmanualeditshistory FROM postgres;
GRANT ALL ON TABLE timeseriesmanualeditshistory TO postgres;
GRANT SELECT ON TABLE timeseriesmanualeditshistory TO webapp;


--
-- TOC entry 3787 (class 0 OID 0)
-- Dependencies: 243
-- Name: timeseriesvaluesandflags; Type: ACL; Schema: fews; Owner: postgres
--

REVOKE ALL ON TABLE timeseriesvaluesandflags FROM PUBLIC;
REVOKE ALL ON TABLE timeseriesvaluesandflags FROM postgres;
GRANT ALL ON TABLE timeseriesvaluesandflags TO postgres;
GRANT SELECT ON TABLE timeseriesvaluesandflags TO webapp;


--
-- TOC entry 3788 (class 0 OID 0)
-- Dependencies: 244
-- Name: timesteps; Type: ACL; Schema: fews; Owner: postgres
--

REVOKE ALL ON TABLE timesteps FROM PUBLIC;
REVOKE ALL ON TABLE timesteps FROM postgres;
GRANT ALL ON TABLE timesteps TO postgres;
GRANT SELECT ON TABLE timesteps TO webapp;


--
-- TOC entry 3789 (class 0 OID 0)
-- Dependencies: 245
-- Name: users; Type: ACL; Schema: fews; Owner: postgres
--

REVOKE ALL ON TABLE users FROM PUBLIC;
REVOKE ALL ON TABLE users FROM postgres;
GRANT ALL ON TABLE users TO postgres;
GRANT SELECT ON TABLE users TO webapp;


--
-- TOC entry 3790 (class 0 OID 0)
-- Dependencies: 246
-- Name: wgslocations; Type: ACL; Schema: fews; Owner: postgres
--

REVOKE ALL ON TABLE wgslocations FROM PUBLIC;
REVOKE ALL ON TABLE wgslocations FROM postgres;
GRANT ALL ON TABLE wgslocations TO postgres;
GRANT SELECT ON TABLE wgslocations TO webapp;



--
-- TOC entry 3792 (class 0 OID 0)
-- Dependencies: 252
-- Name: period; Type: ACL; Schema: ratingcurve; Owner: postgres
--

REVOKE ALL ON TABLE period FROM PUBLIC;
REVOKE ALL ON TABLE period FROM postgres;
GRANT ALL ON TABLE period TO postgres;
GRANT SELECT ON TABLE period TO webapp;


--
-- TOC entry 3795 (class 0 OID 0)
-- Dependencies: 253
-- Name: segment; Type: ACL; Schema: ratingcurve; Owner: postgres
--

REVOKE ALL ON TABLE segment FROM PUBLIC;
REVOKE ALL ON TABLE segment FROM postgres;
GRANT ALL ON TABLE segment TO postgres;
GRANT SELECT ON TABLE segment TO webapp;


-- Completed on 2017-05-18 14:48:05 CEST

--
--

