6 print "CREATE TEMP TABLE legacy_closing (lib text, cstart int, cend int, reason text);\n";
7 print "COPY legacy_closing (lib,cstart,cend,reason) FROM STDIN;\n";
10 my ($lib,$s,$e) = split '\|';
11 my @start = split ' ', $s;
12 my @end = split ' ', $e;
14 for (my $x = 0; $x < @start; $x++) {
15 print "$lib\t$start[$x]\t$end[$x]\tLegacy Closing\n";
23 DELETE FROM actor.org_unit_closed;
25 CREATE TEMP VIEW legacy_closing_view AS
26 SELECT au.id AS org_unit,
27 ('epoch'::TIMESTAMPTZ + (l.cstart || ' seconds')::INTERVAL)::DATE AS close_start,
28 ('epoch'::TIMESTAMPTZ + (l.cend || ' seconds')::INTERVAL + '1 day'::INTERVAL)::DATE - '1 second'::INTERVAL AS close_end,
31 JOIN actor.org_unit au ON (au.shortname = l.lib);
33 INSERT INTO actor.org_unit_closed (org_unit, close_start, close_end, reason)
34 SELECT * from legacy_closing_view;
36 INSERT INTO actor.org_unit_closed (org_unit, close_start, close_end, reason)
37 SELECT au.id AS org_unit,
38 '2006-09-02' AS close_start,
39 '2006-09-05'::DATE - '1 second'::INTERVAL AS close_end,
40 'Evergreen Migration' AS reason
41 FROM actor.org_unit au;