LP#1921057: stamp schema update
authorGalen Charlton <gmc@equinoxOLI.org>
Thu, 23 Sep 2021 14:30:57 +0000 (10:30 -0400)
committerGalen Charlton <gmc@equinoxOLI.org>
Thu, 23 Sep 2021 14:31:35 +0000 (10:31 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/upgrade/1296.schema.reporter-demographic-expansion.sql [new file with mode: 0644]
Open-ILS/src/sql/Pg/upgrade/XXXX.schema.reporter-demographic-expansion.sql [deleted file]

index 985e815..61afa1e 100644 (file)
@@ -92,7 +92,7 @@ CREATE TRIGGER no_overlapping_deps
     BEFORE INSERT OR UPDATE ON config.db_patch_dependencies
     FOR EACH ROW EXECUTE PROCEDURE evergreen.array_overlap_check ('deprecates');
 
-INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1295', :eg_version); -- berkick / cmorgan / gmcharlt
+INSERT INTO config.upgrade_log (version, applied_to) VALUES ('1296', :eg_version); -- csharp / rfrasur / gmcharlt
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
diff --git a/Open-ILS/src/sql/Pg/upgrade/1296.schema.reporter-demographic-expansion.sql b/Open-ILS/src/sql/Pg/upgrade/1296.schema.reporter-demographic-expansion.sql
new file mode 100644 (file)
index 0000000..6eb91e7
--- /dev/null
@@ -0,0 +1,38 @@
+BEGIN;
+
+SELECT evergreen.upgrade_deps_block_check('1296', :eg_version);
+
+CREATE OR REPLACE VIEW reporter.demographic AS
+SELECT  u.id,
+    u.dob,
+    CASE
+        WHEN u.dob IS NULL
+            THEN 'Adult'
+        WHEN AGE(u.dob) > '18 years'::INTERVAL
+            THEN 'Adult'
+        ELSE 'Juvenile'
+    END AS general_division,
+    CASE
+        WHEN u.dob IS NULL
+            THEN 'No Date of Birth Entered'::text
+        WHEN age(u.dob::timestamp with time zone) >= '0 years'::interval and age(u.dob::timestamp with time zone) < '6 years'::interval
+            THEN 'Child 0-5 Years Old'::text
+        WHEN age(u.dob::timestamp with time zone) >= '6 years'::interval and age(u.dob::timestamp with time zone) < '13 years'::interval
+            THEN 'Child 6-12 Years Old'::text
+        WHEN age(u.dob::timestamp with time zone) >= '13 years'::interval and age(u.dob::timestamp with time zone) < '18 years'::interval
+            THEN 'Teen 13-17 Years Old'::text
+        WHEN age(u.dob::timestamp with time zone) >= '18 years'::interval and age(u.dob::timestamp with time zone) < '26 years'::interval
+            THEN 'Adult 18-25 Years Old'::text
+        WHEN age(u.dob::timestamp with time zone) >= '26 years'::interval and age(u.dob::timestamp with time zone) < '50 years'::interval
+            THEN 'Adult 26-49 Years Old'::text
+        WHEN age(u.dob::timestamp with time zone) >= '50 years'::interval and age(u.dob::timestamp with time zone) < '60 years'::interval
+            THEN 'Adult 50-59 Years Old'::text
+        WHEN age(u.dob::timestamp with time zone) >= '60 years'::interval and age(u.dob::timestamp with time zone) < '70  years'::interval
+            THEN 'Adult 60-69 Years Old'::text
+        WHEN age(u.dob::timestamp with time zone) >= '70 years'::interval
+            THEN 'Adult 70+'::text
+        ELSE NULL::text
+    END AS age_division
+    FROM actor.usr u;
+
+COMMIT;
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.reporter-demographic-expansion.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.reporter-demographic-expansion.sql
deleted file mode 100644 (file)
index 6cc62fb..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-BEGIN;
-
--- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
-
-CREATE OR REPLACE VIEW reporter.demographic AS
-SELECT  u.id,
-    u.dob,
-    CASE
-        WHEN u.dob IS NULL
-            THEN 'Adult'
-        WHEN AGE(u.dob) > '18 years'::INTERVAL
-            THEN 'Adult'
-        ELSE 'Juvenile'
-    END AS general_division,
-    CASE
-        WHEN u.dob IS NULL
-            THEN 'No Date of Birth Entered'::text
-        WHEN age(u.dob::timestamp with time zone) >= '0 years'::interval and age(u.dob::timestamp with time zone) < '6 years'::interval
-            THEN 'Child 0-5 Years Old'::text
-        WHEN age(u.dob::timestamp with time zone) >= '6 years'::interval and age(u.dob::timestamp with time zone) < '13 years'::interval
-            THEN 'Child 6-12 Years Old'::text
-        WHEN age(u.dob::timestamp with time zone) >= '13 years'::interval and age(u.dob::timestamp with time zone) < '18 years'::interval
-            THEN 'Teen 13-17 Years Old'::text
-        WHEN age(u.dob::timestamp with time zone) >= '18 years'::interval and age(u.dob::timestamp with time zone) < '26 years'::interval
-            THEN 'Adult 18-25 Years Old'::text
-        WHEN age(u.dob::timestamp with time zone) >= '26 years'::interval and age(u.dob::timestamp with time zone) < '50 years'::interval
-            THEN 'Adult 26-49 Years Old'::text
-        WHEN age(u.dob::timestamp with time zone) >= '50 years'::interval and age(u.dob::timestamp with time zone) < '60 years'::interval
-            THEN 'Adult 50-59 Years Old'::text
-        WHEN age(u.dob::timestamp with time zone) >= '60 years'::interval and age(u.dob::timestamp with time zone) < '70  years'::interval
-            THEN 'Adult 60-69 Years Old'::text
-        WHEN age(u.dob::timestamp with time zone) >= '70 years'::interval
-            THEN 'Adult 70+'::text
-        ELSE NULL::text
-    END AS age_division
-    FROM actor.usr u;
-
-COMMIT;