Skip to content

Commit

Permalink
BCDA-6530: 2022 manual sql file for EOY (#817)
Browse files Browse the repository at this point in the history
  • Loading branch information
krobertson3314 authored Dec 31, 2022
1 parent 9dbcbd5 commit af64f95
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions db/migrations/manual/20221231-runout.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- This is a manual DB wrangle to convert Dec CCLF attribution into runouts
-- We will undo this and convert back to Dec CCLF once the runout for 2023 is received

BEGIN;
DO $$

DECLARE cclfids integer ARRAY;
BEGIN
cclfids := ARRAY(SELECT id FROM cclf_files WHERE timestamp > '2022-11-30' AND type = 0 AND aco_cms_id NOT LIKE ALL(ARRAY['A999%', 'V99%', 'E999%']);
-- This array should ONLY have type == 0

-- You can store the array in Box and ensure the right IDs are affected when undoing this
raise notice 'Following IDs affected: %', cclfids;
-- value of 1 is runout, and 0 is not
UPDATE cclf_files SET type = 1 where id = ANY(cclfids);
END;

$$;

COMMIT;

0 comments on commit af64f95

Please sign in to comment.