-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/fecgov/openFEC into develop
- Loading branch information
Showing
23 changed files
with
2,107 additions
and
191 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
data/migrations/V0113__remove_ofec_totals_pacs_and_totals_parties_mvs.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
SET search_path = public, pg_catalog; | ||
|
||
-- The following two MVs are logically depending on public.ofec_totals_pacs_parties_mv. | ||
-- public.ofec_totals_parties_mv; | ||
-- public.ofec_totals_pacs_mv; | ||
-- however, they only select from ofec_totals_pacs_parties_mv with simple filter | ||
-- therefore, a simple view should be enough, no need for MVs for them. | ||
|
||
-- later research reveals that the two models using these two views are not necessary. So both views and MVs can be deleted. | ||
|
||
-- -------------------------- | ||
DROP VIEW IF EXISTS public.ofec_totals_pacs_vw; | ||
|
||
DROP MATERIALIZED VIEW IF EXISTS public.ofec_totals_pacs_mv; | ||
|
||
-- ---------------------------- | ||
-- ---------------------------- | ||
DROP VIEW IF EXISTS public.ofec_totals_parties_vw; | ||
|
||
DROP MATERIALIZED VIEW IF EXISTS public.ofec_totals_parties_mv; |
207 changes: 207 additions & 0 deletions
207
data/migrations/V0114__add_memo_agg_to_sched_b_agg_tables.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,207 @@ | ||
--================================================================== | ||
-- disclosure.dsc_sched_b_aggregate_purpose | ||
--================================================================== | ||
DO $$ | ||
BEGIN | ||
EXECUTE format('CREATE SEQUENCE public.ofec_sched_b_aggregate_purpose_new_idx_seq1 INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;'); | ||
|
||
EXECUTE format('CREATE TABLE disclosure.dsc_sched_b_aggregate_purpose_new | ||
( | ||
cmte_id character varying(9), | ||
cycle numeric, | ||
purpose character varying, | ||
non_memo_total numeric, | ||
non_memo_count bigint, | ||
memo_total numeric, | ||
memo_count bigint, | ||
idx integer NOT NULL DEFAULT nextval(''ofec_sched_b_aggregate_purpose_new_idx_seq1''::regclass), | ||
CONSTRAINT uq_dsc_sched_b_agg_purpose_new_cmte_id_cycle_purpose_new UNIQUE (cmte_id, cycle, purpose) | ||
) | ||
WITH ( | ||
OIDS=FALSE | ||
);'); | ||
|
||
|
||
EXECUTE format('CREATE INDEX dsc_sched_b_agg_purpose_new_cmte_id | ||
ON disclosure.dsc_sched_b_aggregate_purpose_new | ||
USING btree | ||
(cmte_id COLLATE pg_catalog."default");'); | ||
|
||
EXECUTE format('CREATE INDEX dsc_sched_b_agg_purpose_new_cycle | ||
ON disclosure.dsc_sched_b_aggregate_purpose_new | ||
USING btree | ||
(cycle);'); | ||
|
||
EXECUTE format('CREATE INDEX dsc_sched_b_agg_purpose_new_cycle_cmte_id | ||
ON disclosure.dsc_sched_b_aggregate_purpose_new | ||
USING btree | ||
(cycle, cmte_id COLLATE pg_catalog."default");'); | ||
|
||
EXECUTE format('CREATE INDEX dsc_sched_b_agg_purpose_new_purpose_new | ||
ON disclosure.dsc_sched_b_aggregate_purpose_new | ||
USING btree | ||
(purpose COLLATE pg_catalog."default");'); | ||
|
||
EXECUTE format('CREATE INDEX dsc_sched_b_agg_purpose_new_non_memo_count | ||
ON disclosure.dsc_sched_b_aggregate_purpose_new | ||
USING btree | ||
(non_memo_count);'); | ||
|
||
EXECUTE format('CREATE INDEX dsc_sched_b_agg_purpose_new_non_memo_total | ||
ON disclosure.dsc_sched_b_aggregate_purpose_new | ||
USING btree | ||
(non_memo_total);'); | ||
|
||
|
||
EXCEPTION | ||
WHEN duplicate_table THEN | ||
null; | ||
WHEN others THEN | ||
RAISE NOTICE 'some other error: %, %', sqlstate, sqlerrm; | ||
END$$; | ||
|
||
ALTER TABLE IF EXISTS public.ofec_sched_b_aggregate_purpose_new_idx_seq1 OWNER TO fec; | ||
|
||
ALTER TABLE disclosure.dsc_sched_b_aggregate_purpose_new OWNER TO fec; | ||
GRANT ALL ON TABLE disclosure.dsc_sched_b_aggregate_purpose_new TO fec; | ||
GRANT SELECT ON TABLE disclosure.dsc_sched_b_aggregate_purpose_new TO fec_read; | ||
|
||
|
||
|
||
|
||
--================================================================== | ||
-- disclosure.dsc_sched_b_aggregate_recipient | ||
--================================================================== | ||
DO $$ | ||
BEGIN | ||
EXECUTE format('CREATE SEQUENCE public.ofec_sched_b_aggregate_recipient_new_idx_seq1 INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;'); | ||
|
||
EXECUTE format('CREATE TABLE disclosure.dsc_sched_b_aggregate_recipient_new | ||
( | ||
cmte_id character varying(9), | ||
cycle numeric, | ||
recipient_nm character varying(200), | ||
non_memo_total numeric, | ||
non_memo_count bigint, | ||
memo_total numeric, | ||
memo_count bigint, | ||
idx integer NOT NULL DEFAULT nextval(''ofec_sched_b_aggregate_recipient_new_idx_seq1''::regclass), | ||
CONSTRAINT uq_dsc_sched_b_agg_recpnt_new_cmte_id_cycle_recpnt_new UNIQUE (cmte_id, cycle, recipient_nm) | ||
) | ||
WITH ( | ||
OIDS=FALSE | ||
);'); | ||
|
||
EXECUTE format('CREATE INDEX dsc_sched_b_agg_recpnt_new_cmte_id | ||
ON disclosure.dsc_sched_b_aggregate_recipient_new | ||
USING btree | ||
(cmte_id COLLATE pg_catalog."default");'); | ||
|
||
EXECUTE format('CREATE INDEX dsc_sched_b_agg_recpnt_new_cycle | ||
ON disclosure.dsc_sched_b_aggregate_recipient_new | ||
USING btree | ||
(cycle);'); | ||
|
||
EXECUTE format('CREATE INDEX dsc_sched_b_agg_recpnt_new_cycle_cmte_id | ||
ON disclosure.dsc_sched_b_aggregate_recipient_new | ||
USING btree | ||
(cycle, cmte_id COLLATE pg_catalog."default");'); | ||
|
||
EXECUTE format('CREATE INDEX dsc_sched_b_agg_recpnt_new_recpnt_nm | ||
ON disclosure.dsc_sched_b_aggregate_recipient_new | ||
USING btree | ||
(recipient_nm COLLATE pg_catalog."default");'); | ||
|
||
EXECUTE format('CREATE INDEX dsc_sched_b_agg_recpnt_new_non_memo_count | ||
ON disclosure.dsc_sched_b_aggregate_recipient_new | ||
USING btree | ||
(non_memo_count);'); | ||
|
||
EXECUTE format('CREATE INDEX dsc_sched_b_agg_recpnt_new_non_memo_total | ||
ON disclosure.dsc_sched_b_aggregate_recipient_new | ||
USING btree | ||
(non_memo_total);'); | ||
|
||
EXCEPTION | ||
WHEN duplicate_table THEN | ||
null; | ||
WHEN others THEN | ||
RAISE NOTICE 'some other error: %, %', sqlstate, sqlerrm; | ||
END$$; | ||
|
||
|
||
ALTER TABLE IF EXISTS public.ofec_sched_b_aggregate_recipient_new_idx_seq1 OWNER TO fec; | ||
|
||
ALTER TABLE disclosure.dsc_sched_b_aggregate_recipient_new OWNER TO fec; | ||
GRANT ALL ON TABLE disclosure.dsc_sched_b_aggregate_recipient_new TO fec; | ||
GRANT SELECT ON TABLE disclosure.dsc_sched_b_aggregate_recipient_new TO fec_read; | ||
|
||
|
||
--================================================================== | ||
-- disclosure.dsc_sched_b_aggregate_recipient_id | ||
--================================================================== | ||
DO $$ | ||
BEGIN | ||
EXECUTE format('CREATE SEQUENCE public.ofec_sched_b_aggregate_recipient_id_new_idx_seq1 INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1;'); | ||
|
||
EXECUTE format('CREATE TABLE disclosure.dsc_sched_b_aggregate_recipient_id_new | ||
( | ||
cmte_id character varying(9), | ||
cycle numeric, | ||
recipient_cmte_id character varying, | ||
recipient_nm text, | ||
non_memo_total numeric, | ||
non_memo_count bigint, | ||
memo_total numeric, | ||
memo_count bigint, | ||
idx integer NOT NULL DEFAULT nextval(''ofec_sched_b_aggregate_recipient_id_new_idx_seq1''::regclass), | ||
CONSTRAINT uq_sched_b_agg_recpnt_id_cmte_id_cycle_recpnt_cmte_id UNIQUE (cmte_id, cycle, recipient_cmte_id) | ||
) | ||
WITH ( | ||
OIDS=FALSE | ||
);'); | ||
|
||
EXECUTE format('CREATE INDEX dsc_sched_b_agg_recpnt_id_new_cmte_id | ||
ON disclosure.dsc_sched_b_aggregate_recipient_id_new | ||
USING btree | ||
(cmte_id COLLATE pg_catalog."default");'); | ||
|
||
EXECUTE format('CREATE INDEX dsc_sched_b_agg_recpnt_id_new_cycle | ||
ON disclosure.dsc_sched_b_aggregate_recipient_id_new | ||
USING btree | ||
(cycle);'); | ||
|
||
EXECUTE format('CREATE INDEX dsc_sched_b_agg_recpnt_id_new_cycle_cmte_id | ||
ON disclosure.dsc_sched_b_aggregate_recipient_id_new | ||
USING btree | ||
(cycle, cmte_id COLLATE pg_catalog."default");'); | ||
|
||
EXECUTE format('CREATE INDEX dsc_sched_b_agg_recpnt_id_new_recpnt_cmte_id | ||
ON disclosure.dsc_sched_b_aggregate_recipient_id_new | ||
USING btree | ||
(recipient_cmte_id COLLATE pg_catalog."default");'); | ||
|
||
EXECUTE format('CREATE INDEX dsc_sched_b_agg_recpnt_id_new_non_memo_count | ||
ON disclosure.dsc_sched_b_aggregate_recipient_id_new | ||
USING btree | ||
(non_memo_count);'); | ||
|
||
EXECUTE format('CREATE INDEX dsc_sched_b_agg_recpnt_id_new_non_memo_total | ||
ON disclosure.dsc_sched_b_aggregate_recipient_id_new | ||
USING btree | ||
(non_memo_total);'); | ||
|
||
EXCEPTION | ||
WHEN duplicate_table THEN | ||
null; | ||
WHEN others THEN | ||
RAISE NOTICE 'some other error: %, %', sqlstate, sqlerrm; | ||
END$$; | ||
|
||
ALTER TABLE IF EXISTS public.ofec_sched_b_aggregate_recipient_id_new_idx_seq1 OWNER TO fec; | ||
|
||
ALTER TABLE disclosure.dsc_sched_b_aggregate_recipient_id_new OWNER TO fec; | ||
GRANT ALL ON TABLE disclosure.dsc_sched_b_aggregate_recipient_id_new TO fec; | ||
GRANT SELECT ON TABLE disclosure.dsc_sched_b_aggregate_recipient_id_new TO fec_read; | ||
|
||
--================================================================== |
Oops, something went wrong.