3 SELECT evergreen.upgrade_deps_block_check('1036', :eg_version);
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
20 AND temp_value.ceiling_date >= NOW(); -- Don't update ceiling dates to the past
23 updated := updated + 1;
29 $func$ LANGUAGE plpgsql;