3 INSERT INTO config.upgrade_log (version) VALUES ('0470');
5 CREATE OR REPLACE FUNCTION config.update_hard_due_dates () RETURNS INT AS $func$
7 temp_value config.hard_due_date_values%ROWTYPE;
11 SELECT DISTINCT ON (hard_due_date) *
12 FROM config.hard_due_date_values
13 WHERE active_date <= NOW() -- We've passed (or are at) the rollover time
14 ORDER BY hard_due_date, active_date DESC -- Latest (nearest to us) active time
16 UPDATE config.hard_due_date
17 SET ceiling_date = temp_value.ceiling_date
18 WHERE id = temp_value.hard_due_date
19 AND ceiling_date <> temp_value.ceiling_date; -- Time is equal if we've already updated the chdd
22 updated := updated + 1;
28 $func$ LANGUAGE plpgsql;