 
 
 --
--- Name: az_irradiance_data_every_15_minutes; Type: ACL; Schema: public; Owner: eileen
---
-
-REVOKE ALL ON TABLE az_irradiance_data_every_15_minutes FROM PUBLIC;
-REVOKE ALL ON TABLE az_irradiance_data_every_15_minutes FROM eileen;
-GRANT ALL ON TABLE az_irradiance_data_every_15_minutes TO eileen;
-GRANT ALL ON TABLE az_irradiance_data_every_15_minutes TO sepgroup;
-GRANT SELECT ON TABLE az_irradiance_data_every_15_minutes TO sepgroupreadonly;
+-- Name: az_noaa_weather_data; Type: ACL; Schema: public; Owner: eileen
+--
+
+REVOKE ALL ON TABLE az_noaa_weather_data FROM PUBLIC;
+REVOKE ALL ON TABLE az_noaa_weather_data FROM eileen;
+GRANT ALL ON TABLE az_noaa_weather_data TO eileen;
+GRANT ALL ON TABLE az_noaa_weather_data TO sepgroup;
+GRANT SELECT ON TABLE az_noaa_weather_data TO sepgroupreadonly;
+
+
+--
+-- Name: readings_by_meter_location_history; Type: ACL; Schema: public; Owner: postgres
+--
+
+REVOKE ALL ON TABLE readings_by_meter_location_history FROM PUBLIC;
+REVOKE ALL ON TABLE readings_by_meter_location_history FROM postgres;
+GRANT ALL ON TABLE readings_by_meter_location_history TO postgres;
+GRANT ALL ON TABLE readings_by_meter_location_history TO sepgroup;
+GRANT SELECT ON TABLE readings_by_meter_location_history TO sepgroupreadonly;
+
+
+--
+-- Name: cd_readings_channel_as_columns_by_service_point; Type: ACL; Schema: public; Owner: eileen
+--
+
+REVOKE ALL ON TABLE cd_readings_channel_as_columns_by_service_point FROM PUBLIC;
+REVOKE ALL ON TABLE cd_readings_channel_as_columns_by_service_point FROM eileen;
+GRANT ALL ON TABLE cd_readings_channel_as_columns_by_service_point TO eileen;
+GRANT ALL ON TABLE cd_readings_channel_as_columns_by_service_point TO sepgroup;
+GRANT SELECT ON TABLE cd_readings_channel_as_columns_by_service_point TO sepgroupreadonly;
+
+
+--
+-- Name: az_readings_channel_as_columns_by_spid; Type: ACL; Schema: public; Owner: eileen
+--
+
+REVOKE ALL ON TABLE az_readings_channel_as_columns_by_spid FROM PUBLIC;
+REVOKE ALL ON TABLE az_readings_channel_as_columns_by_spid FROM eileen;
+GRANT ALL ON TABLE az_readings_channel_as_columns_by_spid TO eileen;
+GRANT ALL ON TABLE az_readings_channel_as_columns_by_spid TO sepgroup;
+GRANT SELECT ON TABLE az_readings_channel_as_columns_by_spid TO sepgroupreadonly;
+
+
+--
+-- Name: readings_by_meter_location_history_new_spid; Type: ACL; Schema: public; Owner: eileen
+--
+
+REVOKE ALL ON TABLE readings_by_meter_location_history_new_spid FROM PUBLIC;
+REVOKE ALL ON TABLE readings_by_meter_location_history_new_spid FROM eileen;
+GRANT ALL ON TABLE readings_by_meter_location_history_new_spid TO eileen;
+GRANT ALL ON TABLE readings_by_meter_location_history_new_spid TO sepgroup;
+GRANT SELECT ON TABLE readings_by_meter_location_history_new_spid TO sepgroupreadonly;
+
+
+--
+-- Name: readings_channel_as_columns_by_new_spid; Type: ACL; Schema: public; Owner: eileen
+--
+
+REVOKE ALL ON TABLE readings_channel_as_columns_by_new_spid FROM PUBLIC;
+REVOKE ALL ON TABLE readings_channel_as_columns_by_new_spid FROM eileen;
+GRANT ALL ON TABLE readings_channel_as_columns_by_new_spid TO eileen;
+GRANT ALL ON TABLE readings_channel_as_columns_by_new_spid TO sepgroup;
+GRANT SELECT ON TABLE readings_channel_as_columns_by_new_spid TO sepgroupreadonly;
+
+
+--
+-- Name: az_readings_channels_as_columns_new_spid; Type: ACL; Schema: public; Owner: eileen
+--
+
+REVOKE ALL ON TABLE az_readings_channels_as_columns_new_spid FROM PUBLIC;
+REVOKE ALL ON TABLE az_readings_channels_as_columns_new_spid FROM eileen;
+GRANT ALL ON TABLE az_readings_channels_as_columns_new_spid TO eileen;
+GRANT ALL ON TABLE az_readings_channels_as_columns_new_spid TO sepgroup;
+GRANT SELECT ON TABLE az_readings_channels_as_columns_new_spid TO sepgroupreadonly;
 
 
 --

ALTER TABLE public.cd_houses_with_pv_no_pv_meter OWNER TO eileen;

--
-- Name: readings_by_meter_location_history; Type: VIEW; Schema: public; Owner: postgres
--

CREATE VIEW readings_by_meter_location_history AS
    SELECT "MeterLocationHistory".meter_name, "MeterLocationHistory".old_service_point_id AS service_point_id, "MeterLocationHistory".service_point_latitude, "MeterLocationHistory".service_point_longitude, "MeterLocationHistory".location, "MeterLocationHistory".address, "MeterLocationHistory".latitude, "MeterLocationHistory".longitude, "MeterLocationHistory".installed, "MeterLocationHistory".uninstalled, "Reading".channel, "Reading".raw_value, "Reading".value, "Reading".uom, "Interval".end_time, "MeterData".meter_data_id FROM (((("MeterLocationHistory" JOIN "MeterData" ON ((("MeterLocationHistory".meter_name)::bpchar = "MeterData".meter_name))) JOIN "IntervalReadData" ON (("MeterData".meter_data_id = "IntervalReadData".meter_data_id))) JOIN "Interval" ON (("IntervalReadData".interval_read_data_id = "Interval".interval_read_data_id))) JOIN "Reading" ON (((("Interval".interval_id = "Reading".interval_id) AND ("Interval".end_time >= "MeterLocationHistory".installed)) AND CASE WHEN ("MeterLocationHistory".uninstalled IS NULL) THEN true ELSE ("Interval".end_time < "MeterLocationHistory".uninstalled) END)));


ALTER TABLE public.readings_by_meter_location_history OWNER TO postgres;

--
-- Name: VIEW readings_by_meter_location_history; Type: COMMENT; Schema: public; Owner: postgres
--

COMMENT ON VIEW readings_by_meter_location_history IS 'Readings that are referenced by the MLH. @author Daniel Zhang (張道博)';


--
-- Name: cd_readings_channel_as_columns_by_service_point; Type: VIEW; Schema: public; Owner: eileen
--

CREATE VIEW cd_readings_channel_as_columns_by_service_point AS
    SELECT readings_by_meter_location_history.service_point_id, max(CASE WHEN (readings_by_meter_location_history.channel = (1)::smallint) THEN readings_by_meter_location_history.value ELSE NULL::real END) AS "Energy to House kwH", max(CASE WHEN (readings_by_meter_location_history.channel = (2)::smallint) THEN readings_by_meter_location_history.value ELSE NULL::real END) AS "Energy from House kwH(rec)", max(CASE WHEN (readings_by_meter_location_history.channel = (3)::smallint) THEN readings_by_meter_location_history.value ELSE NULL::real END) AS "Net Energy to House KwH", max(CASE WHEN (readings_by_meter_location_history.channel = (4)::smallint) THEN readings_by_meter_location_history.value ELSE NULL::real END) AS "voltage at house", readings_by_meter_location_history.end_time, max(readings_by_meter_location_history.service_point_latitude) AS service_point_latitude, max(readings_by_meter_location_history.service_point_longitude) AS service_point_longitude, max((readings_by_meter_location_history.location)::text) AS "location_ID", max((readings_by_meter_location_history.address)::text) AS address, max(readings_by_meter_location_history.latitude) AS location_latitude, max(readings_by_meter_location_history.longitude) AS location_longitude FROM readings_by_meter_location_history GROUP BY readings_by_meter_location_history.service_point_id, readings_by_meter_location_history.end_time;


ALTER TABLE public.cd_readings_channel_as_columns_by_service_point OWNER TO eileen;

--
-- Name: cd_monthly_summary; Type: VIEW; Schema: public; Owner: eileen
--


ALTER TABLE public."_IrradianceFifteenMinIntervals" OWNER TO postgres;

--
-- Name: az_ashkan1; Type: VIEW; Schema: public; Owner: christian
--

CREATE VIEW az_ashkan1 AS
    SELECT DISTINCT avg("IrradianceData".irradiance_w_per_m2) AS "irradiance w/m2", date_trunc('hour'::text, "IrradianceData"."timestamp") AS "time hr", avg("KiheiSCADATemperatureHumidity".met_air_temp_degf) AS temperature, avg("KiheiSCADATemperatureHumidity".met_rel_humid_pct) AS "humidity pct" FROM ("IrradianceData" JOIN "KiheiSCADATemperatureHumidity" ON (("IrradianceData"."timestamp" = "KiheiSCADATemperatureHumidity"."timestamp"))) GROUP BY "IrradianceData"."timestamp" ORDER BY date_trunc('hour'::text, "IrradianceData"."timestamp") LIMIT 1000;


ALTER TABLE public.az_ashkan1 OWNER TO christian;

--
-- Name: az_houses_all_with_smart_meter; Type: VIEW; Schema: public; Owner: eileen
--

CREATE VIEW az_houses_all_with_smart_meter AS
    SELECT "MeterLocationHistory".address, "MeterLocationHistory".service_point_id, "MeterLocationHistory".service_point_id AS new_service_point_id FROM "MeterLocationHistory" WHERE ("MeterLocationHistory".uninstalled IS NULL);


ALTER TABLE public.az_houses_all_with_smart_meter OWNER TO eileen;
