 
 
 --
--- Name: deprecated_YU_energy_to_houses_without_PV_copy; Type: ACL; Schema: public; Owner: yuma
---
-
-REVOKE ALL ON TABLE "deprecated_YU_energy_to_houses_without_PV_copy" FROM PUBLIC;
-REVOKE ALL ON TABLE "deprecated_YU_energy_to_houses_without_PV_copy" FROM yuma;
-GRANT ALL ON TABLE "deprecated_YU_energy_to_houses_without_PV_copy" TO yuma;
-GRANT ALL ON TABLE "deprecated_YU_energy_to_houses_without_PV_copy" TO sepgroup;
-
-
---
--- Name: deprecated_meter_ids_for_houses_without_pv_with_locations; Type: ACL; Schema: public; Owner: postgres
---
-
-REVOKE ALL ON TABLE deprecated_meter_ids_for_houses_without_pv_with_locations FROM PUBLIC;
-REVOKE ALL ON TABLE deprecated_meter_ids_for_houses_without_pv_with_locations FROM postgres;
-GRANT ALL ON TABLE deprecated_meter_ids_for_houses_without_pv_with_locations TO postgres;
-GRANT ALL ON TABLE deprecated_meter_ids_for_houses_without_pv_with_locations TO sepgroup;
-
-
---
--- Name: deprecated_dz_energy_voltages_for_houses_without_pv; Type: ACL; Schema: public; Owner: daniel
---
-
-REVOKE ALL ON TABLE deprecated_dz_energy_voltages_for_houses_without_pv FROM PUBLIC;
-REVOKE ALL ON TABLE deprecated_dz_energy_voltages_for_houses_without_pv FROM daniel;
-GRANT ALL ON TABLE deprecated_dz_energy_voltages_for_houses_without_pv TO daniel;
-GRANT ALL ON TABLE deprecated_dz_energy_voltages_for_houses_without_pv TO postgres;
-GRANT ALL ON TABLE deprecated_dz_energy_voltages_for_houses_without_pv TO sepgroup;
-
-
---
--- Name: deprecated_get_kwh_meter_locations; Type: ACL; Schema: public; Owner: postgres
---
-
-REVOKE ALL ON TABLE deprecated_get_kwh_meter_locations FROM PUBLIC;
-REVOKE ALL ON TABLE deprecated_get_kwh_meter_locations FROM postgres;
-GRANT ALL ON TABLE deprecated_get_kwh_meter_locations TO postgres;
-GRANT ALL ON TABLE deprecated_get_kwh_meter_locations TO sepgroup;
-
-
---
--- Name: deprecated_get_meter_readings_locations; Type: ACL; Schema: public; Owner: postgres
---
-
-REVOKE ALL ON TABLE deprecated_get_meter_readings_locations FROM PUBLIC;
-REVOKE ALL ON TABLE deprecated_get_meter_readings_locations FROM postgres;
-GRANT ALL ON TABLE deprecated_get_meter_readings_locations TO postgres;
-GRANT ALL ON TABLE deprecated_get_meter_readings_locations TO sepgroup;
-
-
---
--- Name: deprecated_new_energy_readings_with_location_address; Type: ACL; Schema: public; Owner: postgres
---
-
-REVOKE ALL ON TABLE deprecated_new_energy_readings_with_location_address FROM PUBLIC;
-REVOKE ALL ON TABLE deprecated_new_energy_readings_with_location_address FROM postgres;
-GRANT ALL ON TABLE deprecated_new_energy_readings_with_location_address TO postgres;
-GRANT ALL ON TABLE deprecated_new_energy_readings_with_location_address TO sepgroup;
-
-
---
--- Name: deprecated_readings_by_meter_location_history; Type: ACL; Schema: public; Owner: daniel
---
-
-REVOKE ALL ON TABLE deprecated_readings_by_meter_location_history FROM PUBLIC;
-REVOKE ALL ON TABLE deprecated_readings_by_meter_location_history FROM daniel;
-GRANT ALL ON TABLE deprecated_readings_by_meter_location_history TO daniel;
-GRANT ALL ON TABLE deprecated_readings_by_meter_location_history TO sepgroup;
-
-
---
 -- Name: meter_ids_for_houses_without_pv; Type: ACL; Schema: public; Owner: postgres
 --
 

REVOKE ALL ON TABLE meter_ids_for_houses_without_pv FROM postgres;
GRANT ALL ON TABLE meter_ids_for_houses_without_pv TO postgres;
GRANT ALL ON TABLE meter_ids_for_houses_without_pv TO sepgroup;


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

REVOKE ALL ON TABLE deprecated_readings_for_houses_without_pv FROM PUBLIC;
REVOKE ALL ON TABLE deprecated_readings_for_houses_without_pv FROM postgres;
GRANT ALL ON TABLE deprecated_readings_for_houses_without_pv TO postgres;
GRANT ALL ON TABLE deprecated_readings_for_houses_without_pv TO sepgroup;


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

REVOKE ALL ON TABLE deprecated_view_readings FROM PUBLIC;
REVOKE ALL ON TABLE deprecated_view_readings FROM postgres;
GRANT ALL ON TABLE deprecated_view_readings TO postgres;
GRANT ALL ON TABLE deprecated_view_readings TO sepgroup;


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

REVOKE ALL ON TABLE deprecated_view_readings_with_meter_id FROM PUBLIC;
REVOKE ALL ON TABLE deprecated_view_readings_with_meter_id FROM postgres;
GRANT ALL ON TABLE deprecated_view_readings_with_meter_id TO postgres;
GRANT ALL ON TABLE deprecated_view_readings_with_meter_id TO sepgroup;


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

REVOKE ALL ON TABLE deprecated_voltage_locations_highlow_events FROM PUBLIC;
REVOKE ALL ON TABLE deprecated_voltage_locations_highlow_events FROM postgres;
GRANT ALL ON TABLE deprecated_voltage_locations_highlow_events TO postgres;
GRANT ALL ON TABLE deprecated_voltage_locations_highlow_events TO sepgroup;


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


--

ALTER TABLE public.cd_energy_voltages_for_houses_with_pv 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".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_report_testing; Type: VIEW; Schema: public; Owner: eileen
--

CREATE VIEW cd_report_testing AS
    SELECT max((readings_by_meter_location_history.service_point_id)::text) AS max, sum(readings_by_meter_location_history.value) AS sum, (readings_by_meter_location_history.end_time)::date AS end_time FROM readings_by_meter_location_history WHERE (((readings_by_meter_location_history.end_time >= '2013-01-01 00:00:00'::timestamp without time zone) AND (readings_by_meter_location_history.end_time <= '2013-02-01 00:00:00'::timestamp without time zone)) AND ((readings_by_meter_location_history.service_point_id)::text = '98726'::text)) GROUP BY (readings_by_meter_location_history.end_time)::date;


ALTER TABLE public.cd_report_testing OWNER TO eileen;

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

CREATE VIEW cd_report_testing_2 AS
    SELECT readings_by_meter_location_history.service_point_id, avg(readings_by_meter_location_history.value) AS avg, date_trunc('hour'::text, readings_by_meter_location_history.end_time) AS date_trunc FROM readings_by_meter_location_history WHERE ((readings_by_meter_location_history.end_time >= '2012-12-01 00:00:00'::timestamp without time zone) AND (readings_by_meter_location_history.end_time <= '2013-01-01 00:00:00'::timestamp without time zone)) GROUP BY readings_by_meter_location_history.service_point_id, date_trunc('hour'::text, readings_by_meter_location_history.end_time);


ALTER TABLE public.cd_report_testing_2 OWNER TO eileen;

--
-- Name: cd_spid=115477_2013-01; Type: VIEW; Schema: public; Owner: eileen
--

CREATE VIEW "cd_spid=115477_2013-01" AS
    SELECT readings_by_meter_location_history.service_point_id, sum(readings_by_meter_location_history.value) AS sum, (readings_by_meter_location_history.end_time)::date AS end_time FROM readings_by_meter_location_history WHERE ((((readings_by_meter_location_history.channel = (1)::smallint) AND ((readings_by_meter_location_history.service_point_id)::text = '115477'::text)) AND (readings_by_meter_location_history.end_time >= '2013-01-01 00:00:00'::timestamp without time zone)) AND (readings_by_meter_location_history.end_time < '2013-02-01 00:00:00'::timestamp without time zone)) GROUP BY (readings_by_meter_location_history.end_time)::date, readings_by_meter_location_history.service_point_id;


ALTER TABLE public."cd_spid=115477_2013-01" OWNER TO eileen;

--
-- Name: count_of_event_duplicates; Type: VIEW; Schema: public; Owner: daniel
--

