From a9274c8f167d60c82fc23221c51125160b2017f0 Mon Sep 17 00:00:00 2001 From: Stephen Cresswell <229672+cressie176@users.noreply.github.com> Date: Sun, 7 Jan 2024 11:27:04 +0000 Subject: [PATCH] More tests --- README.md | 2 +- .../migrations/0003.initial-park-data.yaml | 98 +++++------ .../migrations/0004.park-calendars-2020.yaml | 98 +++++------ .../migrations/0005.park-calendars-2021.yaml | 122 ++++++------- examples/migrations/0006.add-richmond.yaml | 34 ++-- .../0007.rename-richmond-to-skegness.yaml | 35 ++-- .../migrations/0008.park-calendars-2022.yaml | 154 ++++++++--------- .../migrations/0010.park-calendars-2023.yaml | 162 +++++++++--------- index.js | 6 +- lib/schema.json | 20 +-- lib/template.hbs | 4 +- .../006.create-rdf-change-set-relations.sql | 4 +- ...08.create-rdf-projection-change-log-vw.sql | 2 +- test/api.test.js | 6 +- test/dsl.test.js | 37 ++-- test/schema.test.js | 12 +- 16 files changed, 390 insertions(+), 406 deletions(-) diff --git a/README.md b/README.md index 43f66b5..af41ebe 100644 --- a/README.md +++ b/README.md @@ -294,7 +294,7 @@ add hooks: # Add a change set containing one or more data frames for the previously defined entities add change set: - effective_from: 2019-01-01T00:00:00Z + effective: 2019-01-01T00:00:00Z notes: Initial Data frames: - entity: park diff --git a/examples/migrations/0003.initial-park-data.yaml b/examples/migrations/0003.initial-park-data.yaml index 0b6262f..0b99b38 100644 --- a/examples/migrations/0003.initial-park-data.yaml +++ b/examples/migrations/0003.initial-park-data.yaml @@ -1,5 +1,5 @@ add change set: - effective_from: 2019-01-01T00:00:00Z + effective: 2019-01-01T00:00:00Z notes: Initial Data frames: - entity: park @@ -16,51 +16,51 @@ add change set: version: 1 action: POST data: - - id: 1 - park_code: DC - event: Park Open - Owners - occurs: 2019-03-01 00:00:00Z - - id: 2 - park_code: DC - event: Park Open - Guests - occurs: 2019-03-15 00:00:00Z - - id: 3 - park_code: DC - event: Park Close - Owners - occurs: 2019-11-30 00:00:00Z - - id: 4 - park_code: DC - event: Park Close - Guests - occurs: 2019-11-15 00:00:00Z - - id: 5 - park_code: PV - event: Park Open - Owners - occurs: 2019-03-01 00:00:00Z - - id: 6 - park_code: PV - event: Park Open - Guests - occurs: 2019-03-15 00:00:00Z - - id: 7 - park_code: PV - event: Park Close - Owners - occurs: 2019-11-30 00:00:00Z - - id: 8 - park_code: PV - event: Park Close - Guests - occurs: 2019-11-15 00:00:00Z - - id: 9 - park_code: GA - event: Park Open - Owners - occurs: 2019-03-01 00:00:00Z - - id: 10 - park_code: GA - event: Park Open - Guests - occurs: 2019-03-15 00:00:00Z - - id: 11 - park_code: GA - event: Park Close - Owners - occurs: 2019-11-30 00:00:00Z - - id: 12 - park_code: GA - event: Park Close - Guests - occurs: 2019-11-15 00:00:00Z + - id: 1 + park_code: DC + event: Park Open - Owners + occurs: 2019-03-01 00:00:00Z + - id: 2 + park_code: DC + event: Park Open - Guests + occurs: 2019-03-15 00:00:00Z + - id: 3 + park_code: DC + event: Park Close - Owners + occurs: 2019-11-30 00:00:00Z + - id: 4 + park_code: DC + event: Park Close - Guests + occurs: 2019-11-15 00:00:00Z + - id: 5 + park_code: PV + event: Park Open - Owners + occurs: 2019-03-01 00:00:00Z + - id: 6 + park_code: PV + event: Park Open - Guests + occurs: 2019-03-15 00:00:00Z + - id: 7 + park_code: PV + event: Park Close - Owners + occurs: 2019-11-30 00:00:00Z + - id: 8 + park_code: PV + event: Park Close - Guests + occurs: 2019-11-15 00:00:00Z + - id: 9 + park_code: GA + event: Park Open - Owners + occurs: 2019-03-01 00:00:00Z + - id: 10 + park_code: GA + event: Park Open - Guests + occurs: 2019-03-15 00:00:00Z + - id: 11 + park_code: GA + event: Park Close - Owners + occurs: 2019-11-30 00:00:00Z + - id: 12 + park_code: GA + event: Park Close - Guests + occurs: 2019-11-15 00:00:00Z diff --git a/examples/migrations/0004.park-calendars-2020.yaml b/examples/migrations/0004.park-calendars-2020.yaml index 6a7353f..4eb89da 100644 --- a/examples/migrations/0004.park-calendars-2020.yaml +++ b/examples/migrations/0004.park-calendars-2020.yaml @@ -1,56 +1,56 @@ add change set: - effective_from: 2020-01-01T00:00:00Z + effective: 2020-01-01T00:00:00Z notes: Park Calendars - 2020 frames: - entity: park_calendar version: 1 action: POST data: - - id: 13 - park_code: DC - event: Park Open - Owners - occurs: 2020-03-01 00:00:00Z - - id: 14 - park_code: DC - event: Park Open - Guests - occurs: 2020-03-15 00:00:00Z - - id: 15 - park_code: DC - event: Park Close - Owners - occurs: 2020-11-30 00:00:00Z - - id: 16 - park_code: DC - event: Park Close - Guests - occurs: 2020-11-15 00:00:00Z - - id: 17 - park_code: PV - event: Park Open - Owners - occurs: 2020-03-01 00:00:00Z - - id: 18 - park_code: PV - event: Park Open - Guests - occurs: 2020-03-15 00:00:00Z - - id: 19 - park_code: PV - event: Park Close - Owners - occurs: 2020-11-30 00:00:00Z - - id: 20 - park_code: PV - event: Park Close - Guests - occurs: 2020-11-15 00:00:00Z - - id: 21 - park_code: GA - event: Park Open - Owners - occurs: 2020-03-01 00:00:00Z - - id: 22 - park_code: GA - event: Park Open - Guests - occurs: 2020-03-15 00:00:00Z - - id: 23 - park_code: GA - event: Park Close - Owners - occurs: 2020-11-30 00:00:00Z - - id: 24 - park_code: GA - event: Park Close - Guests - occurs: 2020-11-15 00:00:00Z + - id: 13 + park_code: DC + event: Park Open - Owners + occurs: 2020-03-01 00:00:00Z + - id: 14 + park_code: DC + event: Park Open - Guests + occurs: 2020-03-15 00:00:00Z + - id: 15 + park_code: DC + event: Park Close - Owners + occurs: 2020-11-30 00:00:00Z + - id: 16 + park_code: DC + event: Park Close - Guests + occurs: 2020-11-15 00:00:00Z + - id: 17 + park_code: PV + event: Park Open - Owners + occurs: 2020-03-01 00:00:00Z + - id: 18 + park_code: PV + event: Park Open - Guests + occurs: 2020-03-15 00:00:00Z + - id: 19 + park_code: PV + event: Park Close - Owners + occurs: 2020-11-30 00:00:00Z + - id: 20 + park_code: PV + event: Park Close - Guests + occurs: 2020-11-15 00:00:00Z + - id: 21 + park_code: GA + event: Park Open - Owners + occurs: 2020-03-01 00:00:00Z + - id: 22 + park_code: GA + event: Park Open - Guests + occurs: 2020-03-15 00:00:00Z + - id: 23 + park_code: GA + event: Park Close - Owners + occurs: 2020-11-30 00:00:00Z + - id: 24 + park_code: GA + event: Park Close - Guests + occurs: 2020-11-15 00:00:00Z diff --git a/examples/migrations/0005.park-calendars-2021.yaml b/examples/migrations/0005.park-calendars-2021.yaml index d79cdaa..b960978 100644 --- a/examples/migrations/0005.park-calendars-2021.yaml +++ b/examples/migrations/0005.park-calendars-2021.yaml @@ -1,117 +1,117 @@ add change set: - effective_from: 2021-01-01T00:00:00Z + effective: 2021-01-01T00:00:00Z notes: Park Calendars - 2021 frames: - entity: park_calendar version: 1 action: DELETE data: - - id: 1 + - id: 1 - entity: park_calendar version: 1 action: DELETE data: - - id: 2 + - id: 2 - entity: park_calendar version: 1 action: DELETE data: - - id: 3 + - id: 3 - entity: park_calendar version: 1 action: DELETE data: - - id: 4 + - id: 4 - entity: park_calendar version: 1 action: DELETE data: - - id: 5 + - id: 5 - entity: park_calendar version: 1 action: DELETE data: - - id: 6 + - id: 6 - entity: park_calendar version: 1 action: DELETE data: - - id: 7 + - id: 7 - entity: park_calendar version: 1 action: DELETE data: - - id: 8 + - id: 8 - entity: park_calendar version: 1 action: DELETE data: - - id: 9 + - id: 9 - entity: park_calendar version: 1 action: DELETE data: - - id: 10 + - id: 10 - entity: park_calendar version: 1 action: DELETE data: - - id: 11 + - id: 11 - entity: park_calendar version: 1 action: DELETE data: - - id: 12 + - id: 12 - entity: park_calendar version: 1 action: POST data: - - id: 25 - park_code: DC - event: Park Open - Owners - occurs: 2021-03-01 00:00:00Z - - id: 26 - park_code: DC - event: Park Open - Guests - occurs: 2021-03-15 00:00:00Z - - id: 27 - park_code: DC - event: Park Close - Owners - occurs: 2021-11-30 00:00:00Z - - id: 28 - park_code: DC - event: Park Close - Guests - occurs: 2021-11-15 00:00:00Z - - id: 29 - park_code: PV - event: Park Open - Owners - occurs: 2021-03-01 00:00:00Z - - id: 30 - park_code: PV - event: Park Open - Guests - occurs: 2021-03-15 00:00:00Z - - id: 31 - park_code: PV - event: Park Close - Owners - occurs: 2021-11-30 00:00:00Z - - id: 32 - park_code: PV - event: Park Close - Guests - occurs: 2021-11-15 00:00:00Z - - id: 33 - park_code: GA - event: Park Open - Owners - occurs: 2021-03-01 00:00:00Z - - id: 34 - park_code: GA - event: Park Open - Guests - occurs: 2021-03-15 00:00:00Z - - id: 35 - park_code: GA - event: Park Close - Owners - occurs: 2021-11-30 00:00:00Z - - id: 36 - park_code: GA - event: Park Close - Guests - occurs: 2021-11-15 00:00:00Z + - id: 25 + park_code: DC + event: Park Open - Owners + occurs: 2021-03-01 00:00:00Z + - id: 26 + park_code: DC + event: Park Open - Guests + occurs: 2021-03-15 00:00:00Z + - id: 27 + park_code: DC + event: Park Close - Owners + occurs: 2021-11-30 00:00:00Z + - id: 28 + park_code: DC + event: Park Close - Guests + occurs: 2021-11-15 00:00:00Z + - id: 29 + park_code: PV + event: Park Open - Owners + occurs: 2021-03-01 00:00:00Z + - id: 30 + park_code: PV + event: Park Open - Guests + occurs: 2021-03-15 00:00:00Z + - id: 31 + park_code: PV + event: Park Close - Owners + occurs: 2021-11-30 00:00:00Z + - id: 32 + park_code: PV + event: Park Close - Guests + occurs: 2021-11-15 00:00:00Z + - id: 33 + park_code: GA + event: Park Open - Owners + occurs: 2021-03-01 00:00:00Z + - id: 34 + park_code: GA + event: Park Open - Guests + occurs: 2021-03-15 00:00:00Z + - id: 35 + park_code: GA + event: Park Close - Owners + occurs: 2021-11-30 00:00:00Z + - id: 36 + park_code: GA + event: Park Close - Guests + occurs: 2021-11-15 00:00:00Z diff --git a/examples/migrations/0006.add-richmond.yaml b/examples/migrations/0006.add-richmond.yaml index d9e8db0..a2a46f6 100644 --- a/examples/migrations/0006.add-richmond.yaml +++ b/examples/migrations/0006.add-richmond.yaml @@ -1,5 +1,5 @@ add change set: - effective_from: 2021-04-01T00:00:00Z + effective: 2021-04-01T00:00:00Z notes: Add Richmond frames: - entity: park @@ -13,19 +13,19 @@ add change set: version: 1 action: POST data: - - id: 37 - park_code: RI - event: Park Open - Owners - occurs: 2021-05-01T00:00:00Z - - id: 38 - park_code: RI - event: Park Open - Guests - occurs: 2021-05-15T00:00:00Z - - id: 39 - park_code: RI - event: Park Close - Owners - occurs: 2021-11-01T00:00:00Z - - id: 40 - park_code: RI - event: Park Close - Guests - occurs: 2021-11-15T00:00:00Z + - id: 37 + park_code: RI + event: Park Open - Owners + occurs: 2021-05-01T00:00:00Z + - id: 38 + park_code: RI + event: Park Open - Guests + occurs: 2021-05-15T00:00:00Z + - id: 39 + park_code: RI + event: Park Close - Owners + occurs: 2021-11-01T00:00:00Z + - id: 40 + park_code: RI + event: Park Close - Guests + occurs: 2021-11-15T00:00:00Z diff --git a/examples/migrations/0007.rename-richmond-to-skegness.yaml b/examples/migrations/0007.rename-richmond-to-skegness.yaml index 420aa8d..a7b1088 100644 --- a/examples/migrations/0007.rename-richmond-to-skegness.yaml +++ b/examples/migrations/0007.rename-richmond-to-skegness.yaml @@ -1,5 +1,5 @@ add change set: - effective_from: 2021-06-01T00:00:00Z + effective: 2021-06-01T00:00:00Z notes: Rename Richmond to Skegness frames: - entity: park @@ -19,20 +19,19 @@ add change set: version: 1 action: POST data: - - id: 37 - park_code: SK - event: Park Open - Owners - occurs: 2021-05-01T00:00:00Z - - id: 38 - park_code: SK - event: Park Open - Guests - occurs: 2021-05-15T00:00:00Z - - id: 39 - park_code: SK - event: Park Close - Owners - occurs: 2021-11-30T00:00:00Z - - id: 40 - park_code: SK - event: Park Close - Guests - occurs: 2021-11-15T00:00:00Z - + - id: 37 + park_code: SK + event: Park Open - Owners + occurs: 2021-05-01T00:00:00Z + - id: 38 + park_code: SK + event: Park Open - Guests + occurs: 2021-05-15T00:00:00Z + - id: 39 + park_code: SK + event: Park Close - Owners + occurs: 2021-11-30T00:00:00Z + - id: 40 + park_code: SK + event: Park Close - Guests + occurs: 2021-11-15T00:00:00Z diff --git a/examples/migrations/0008.park-calendars-2022.yaml b/examples/migrations/0008.park-calendars-2022.yaml index b6194b0..3988f43 100644 --- a/examples/migrations/0008.park-calendars-2022.yaml +++ b/examples/migrations/0008.park-calendars-2022.yaml @@ -1,133 +1,133 @@ add change set: - effective_from: 2022-01-01T00:00:00Z + effective: 2022-01-01T00:00:00Z notes: Park Calendars - 2022 frames: - entity: park_calendar version: 1 action: DELETE data: - - id: 13 + - id: 13 - entity: park_calendar version: 1 action: DELETE data: - - id: 14 + - id: 14 - entity: park_calendar version: 1 action: DELETE data: - - id: 15 + - id: 15 - entity: park_calendar version: 1 action: DELETE data: - - id: 16 + - id: 16 - entity: park_calendar version: 1 action: DELETE data: - - id: 17 + - id: 17 - entity: park_calendar version: 1 action: DELETE data: - - id: 18 + - id: 18 - entity: park_calendar version: 1 action: DELETE data: - - id: 19 + - id: 19 - entity: park_calendar version: 1 action: DELETE data: - - id: 20 + - id: 20 - entity: park_calendar version: 1 action: DELETE data: - - id: 21 + - id: 21 - entity: park_calendar version: 1 action: DELETE data: - - id: 22 + - id: 22 - entity: park_calendar version: 1 action: DELETE data: - - id: 23 + - id: 23 - entity: park_calendar version: 1 action: DELETE data: - - id: 24 + - id: 24 - entity: park_calendar version: 1 action: POST data: - - id: 41 - park_code: DC - event: Park Open - Owners - occurs: 2022-03-01 00:00:00Z - - id: 42 - park_code: DC - event: Park Open - Guests - occurs: 2022-03-15 00:00:00Z - - id: 43 - park_code: DC - event: Park Close - Owners - occurs: 2022-11-30 00:00:00Z - - id: 44 - park_code: DC - event: Park Close - Guests - occurs: 2022-11-15 00:00:00Z - - id: 45 - park_code: PV - event: Park Open - Owners - occurs: 2022-03-01 00:00:00Z - - id: 46 - park_code: PV - event: Park Open - Guests - occurs: 2022-03-15 00:00:00Z - - id: 47 - park_code: PV - event: Park Close - Owners - occurs: 2022-11-30 00:00:00Z - - id: 48 - park_code: PV - event: Park Close - Guests - occurs: 2022-11-15 00:00:00Z - - id: 49 - park_code: GA - event: Park Open - Owners - occurs: 2022-03-01 00:00:00Z - - id: 50 - park_code: GA - event: Park Open - Guests - occurs: 2022-03-15 00:00:00Z - - id: 51 - park_code: GA - event: Park Close - Owners - occurs: 2022-11-30 00:00:00Z - - id: 52 - park_code: GA - event: Park Close - Guests - occurs: 2022-11-15 00:00:00Z - - id: 53 - park_code: SK - event: Park Open - Owners - occurs: 2022-03-01 00:00:00Z - - id: 54 - park_code: SK - event: Park Open - Guests - occurs: 2022-03-15 00:00:00Z - - id: 55 - park_code: SK - event: Park Close - Owners - occurs: 2022-11-30 00:00:00Z - - id: 56 - park_code: SK - event: Park Close - Guests - occurs: 2022-11-15 00:00:00Z + - id: 41 + park_code: DC + event: Park Open - Owners + occurs: 2022-03-01 00:00:00Z + - id: 42 + park_code: DC + event: Park Open - Guests + occurs: 2022-03-15 00:00:00Z + - id: 43 + park_code: DC + event: Park Close - Owners + occurs: 2022-11-30 00:00:00Z + - id: 44 + park_code: DC + event: Park Close - Guests + occurs: 2022-11-15 00:00:00Z + - id: 45 + park_code: PV + event: Park Open - Owners + occurs: 2022-03-01 00:00:00Z + - id: 46 + park_code: PV + event: Park Open - Guests + occurs: 2022-03-15 00:00:00Z + - id: 47 + park_code: PV + event: Park Close - Owners + occurs: 2022-11-30 00:00:00Z + - id: 48 + park_code: PV + event: Park Close - Guests + occurs: 2022-11-15 00:00:00Z + - id: 49 + park_code: GA + event: Park Open - Owners + occurs: 2022-03-01 00:00:00Z + - id: 50 + park_code: GA + event: Park Open - Guests + occurs: 2022-03-15 00:00:00Z + - id: 51 + park_code: GA + event: Park Close - Owners + occurs: 2022-11-30 00:00:00Z + - id: 52 + park_code: GA + event: Park Close - Guests + occurs: 2022-11-15 00:00:00Z + - id: 53 + park_code: SK + event: Park Open - Owners + occurs: 2022-03-01 00:00:00Z + - id: 54 + park_code: SK + event: Park Open - Guests + occurs: 2022-03-15 00:00:00Z + - id: 55 + park_code: SK + event: Park Close - Owners + occurs: 2022-11-30 00:00:00Z + - id: 56 + park_code: SK + event: Park Close - Guests + occurs: 2022-11-15 00:00:00Z diff --git a/examples/migrations/0010.park-calendars-2023.yaml b/examples/migrations/0010.park-calendars-2023.yaml index 1bfc6a1..a316ef6 100644 --- a/examples/migrations/0010.park-calendars-2023.yaml +++ b/examples/migrations/0010.park-calendars-2023.yaml @@ -1,153 +1,153 @@ add change set: - effective_from: 2023-01-01T00:00:00Z + effective: 2023-01-01T00:00:00Z notes: Park Calendars - 2023 frames: - entity: park_calendar version: 1 action: DELETE data: - - id: 25 + - id: 25 - entity: park_calendar version: 1 action: DELETE data: - - id: 26 + - id: 26 - entity: park_calendar version: 1 action: DELETE data: - - id: 27 + - id: 27 - entity: park_calendar version: 1 action: DELETE data: - - id: 28 + - id: 28 - entity: park_calendar version: 1 action: DELETE data: - - id: 29 + - id: 29 - entity: park_calendar version: 1 action: DELETE data: - - id: 30 + - id: 30 - entity: park_calendar version: 1 action: DELETE data: - - id: 31 + - id: 31 - entity: park_calendar version: 1 action: DELETE data: - - id: 32 + - id: 32 - entity: park_calendar version: 1 action: DELETE data: - - id: 33 + - id: 33 - entity: park_calendar version: 1 action: DELETE data: - - id: 34 + - id: 34 - entity: park_calendar version: 1 action: DELETE data: - - id: 35 + - id: 35 - entity: park_calendar version: 1 action: DELETE data: - - id: 36 + - id: 36 - entity: park_calendar version: 1 action: DELETE data: - - id: 37 + - id: 37 - entity: park_calendar version: 1 action: DELETE data: - - id: 38 + - id: 38 - entity: park_calendar version: 1 action: DELETE data: - - id: 39 + - id: 39 - entity: park_calendar version: 1 action: DELETE data: - - id: 40 + - id: 40 - entity: park_calendar version: 1 action: POST data: - - id: 57 - park_code: DC - event: Park Open - Owners - occurs: 2023-03-01 00:00:00Z - - id: 58 - park_code: DC - event: Park Open - Guests - occurs: 2023-03-15 00:00:00Z - - id: 59 - park_code: DC - event: Park Close - Owners - occurs: 2023-11-30 00:00:00Z - - id: 60 - park_code: DC - event: Park Close - Guests - occurs: 2023-11-15 00:00:00Z - - id: 61 - park_code: PV - event: Park Open - Owners - occurs: 2023-03-01 00:00:00Z - - id: 62 - park_code: PV - event: Park Open - Guests - occurs: 2023-03-15 00:00:00Z - - id: 63 - park_code: PV - event: Park Close - Owners - occurs: 2023-11-30 00:00:00Z - - id: 64 - park_code: PV - event: Park Close - Guests - occurs: 2023-11-15 00:00:00Z - - id: 65 - park_code: GA - event: Park Open - Owners - occurs: 2023-03-01 00:00:00Z - - id: 66 - park_code: GA - event: Park Open - Guests - occurs: 2023-03-15 00:00:00Z - - id: 67 - park_code: GA - event: Park Close - Owners - occurs: 2023-11-30 00:00:00Z - - id: 68 - park_code: GA - event: Park Close - Guests - occurs: 2023-11-15 00:00:00Z - - id: 69 - park_code: SK - event: Park Open - Owners - occurs: 2023-03-01 00:00:00Z - - id: 70 - park_code: SK - event: Park Open - Guests - occurs: 2023-03-15 00:00:00Z - - id: 71 - park_code: SK - event: Park Close - Owners - occurs: 2023-11-30 00:00:00Z - - id: 72 - park_code: SK - event: Park Close - Guests - occurs: 2023-11-15 00:00:00Z + - id: 57 + park_code: DC + event: Park Open - Owners + occurs: 2023-03-01 00:00:00Z + - id: 58 + park_code: DC + event: Park Open - Guests + occurs: 2023-03-15 00:00:00Z + - id: 59 + park_code: DC + event: Park Close - Owners + occurs: 2023-11-30 00:00:00Z + - id: 60 + park_code: DC + event: Park Close - Guests + occurs: 2023-11-15 00:00:00Z + - id: 61 + park_code: PV + event: Park Open - Owners + occurs: 2023-03-01 00:00:00Z + - id: 62 + park_code: PV + event: Park Open - Guests + occurs: 2023-03-15 00:00:00Z + - id: 63 + park_code: PV + event: Park Close - Owners + occurs: 2023-11-30 00:00:00Z + - id: 64 + park_code: PV + event: Park Close - Guests + occurs: 2023-11-15 00:00:00Z + - id: 65 + park_code: GA + event: Park Open - Owners + occurs: 2023-03-01 00:00:00Z + - id: 66 + park_code: GA + event: Park Open - Guests + occurs: 2023-03-15 00:00:00Z + - id: 67 + park_code: GA + event: Park Close - Owners + occurs: 2023-11-30 00:00:00Z + - id: 68 + park_code: GA + event: Park Close - Guests + occurs: 2023-11-15 00:00:00Z + - id: 69 + park_code: SK + event: Park Open - Owners + occurs: 2023-03-01 00:00:00Z + - id: 70 + park_code: SK + event: Park Open - Guests + occurs: 2023-03-15 00:00:00Z + - id: 71 + park_code: SK + event: Park Close - Owners + occurs: 2023-11-30 00:00:00Z + - id: 72 + park_code: SK + event: Park Close - Guests + occurs: 2023-11-15 00:00:00Z diff --git a/index.js b/index.js index fe52d5c..e7bc3a3 100644 --- a/index.js +++ b/index.js @@ -76,14 +76,14 @@ module.exports = class ReferenceDataFramework extends EventEmitter { async getChangeLog(projection) { return this.withTransaction(async (tx) => { - const { rows } = await tx.query('SELECT DISTINCT ON (change_set_id) change_set_id, effective_from, notes, last_modified, entity_tag FROM rdf_projection_change_log_vw WHERE projection_id = $1', [projection.id]); + const { rows } = await tx.query('SELECT DISTINCT ON (change_set_id) change_set_id, effective, notes, last_modified, entity_tag FROM rdf_projection_change_log_vw WHERE projection_id = $1', [projection.id]); return rows.map(toChangeSet); }); }; async getChangeSet(changeSetId) { return this.withTransaction(async (tx) => { - const { rows } = await tx.query('SELECT id AS change_set_id, effective_from, notes, last_modified, entity_tag FROM rdf_change_set WHERE id = $1', [changeSetId]); + const { rows } = await tx.query('SELECT id AS change_set_id, effective, notes, last_modified, entity_tag FROM rdf_change_set WHERE id = $1', [changeSetId]); return rows.map(toChangeSet)[0]; }); } @@ -147,7 +147,7 @@ WHERE h.id = $1`, function toChangeSet(row) { return { id: row.change_set_id, - effectiveFrom: new Date(row.effective_from), + effectiveFrom: new Date(row.effective), notes: row.notes, lastModified: new Date(row.last_modified), entityTag: row.entity_tag diff --git a/lib/schema.json b/lib/schema.json index 8da6c06..3151ab5 100644 --- a/lib/schema.json +++ b/lib/schema.json @@ -225,10 +225,6 @@ "type": "string", "format": "date-time" }, - "effective_from": { - "type": "string", - "format": "date-time" - }, "notes": { "type": "string" }, @@ -268,19 +264,9 @@ } } }, - "oneOf": [ - { - "required": [ - "effective from", - "frames" - ] - }, - { - "required": [ - "effective_from", - "frames" - ] - } + "required": [ + "effective", + "frames" ] } } diff --git a/lib/template.hbs b/lib/template.hbs index ea58b1f..82ebe3d 100644 --- a/lib/template.hbs +++ b/lib/template.hbs @@ -108,8 +108,8 @@ DO $$ v_entity_id INTEGER; v_frame_id INTEGER; BEGIN - INSERT INTO rdf_change_set (effective_from, notes) VALUES - ('{{effective_from}}', '{{notes}}') + INSERT INTO rdf_change_set (effective, notes) VALUES + ('{{effective}}', '{{notes}}') RETURNING id INTO v_change_set_id; {{#frames}} diff --git a/migrations/006.create-rdf-change-set-relations.sql b/migrations/006.create-rdf-change-set-relations.sql index a1fd0a3..ee80a9e 100644 --- a/migrations/006.create-rdf-change-set-relations.sql +++ b/migrations/006.create-rdf-change-set-relations.sql @@ -4,13 +4,13 @@ CREATE EXTENSION pgcrypto; CREATE TABLE rdf_change_set ( id SERIAL PRIMARY KEY, - effective_from TIMESTAMP WITH TIME ZONE NOT NULL, + effective TIMESTAMP WITH TIME ZONE NOT NULL, notes TEXT, last_modified TIMESTAMP WITH TIME ZONE NOT NULL, entity_tag TEXT NOT NULL ); -CREATE INDEX rdf_change_set_effective_from_idx ON rdf_change_set (effective_from DESC); +CREATE INDEX rdf_change_set_effective_idx ON rdf_change_set (effective DESC); CREATE FUNCTION rdf_on_new_change_set() RETURNS TRIGGER AS $$ diff --git a/migrations/008.create-rdf-projection-change-log-vw.sql b/migrations/008.create-rdf-projection-change-log-vw.sql index 56262e4..e2fd8b7 100644 --- a/migrations/008.create-rdf-projection-change-log-vw.sql +++ b/migrations/008.create-rdf-projection-change-log-vw.sql @@ -6,7 +6,7 @@ CREATE VIEW rdf_projection_change_log_vw AS ( p.name AS projection_name, p.version AS projection_version, c.id AS change_set_id, - c.effective_from, + c.effective, c.notes, c.last_modified, c.entity_tag diff --git a/test/api.test.js b/test/api.test.js index 22de7ae..7cbde83 100644 --- a/test/api.test.js +++ b/test/api.test.js @@ -96,7 +96,7 @@ describe('API', () => { (2, 1), (2, 3)` ); - await tx.query(`INSERT INTO rdf_change_set (id, effective_from, notes) VALUES + await tx.query(`INSERT INTO rdf_change_set (id, effective, notes) VALUES (1, '2020-04-05T00:00:00.000Z', 'Countries'), (2, '2020-04-05T00:00:00.000Z', '2020 VAT Rates'), (3, '2020-04-05T00:00:00.000Z', '2020 CGT Rates'), @@ -134,7 +134,7 @@ describe('API', () => { (1, 1), (1, 2)` ); - await tx.query(`INSERT INTO rdf_change_set (id, effective_from, notes) VALUES + await tx.query(`INSERT INTO rdf_change_set (id, effective, notes) VALUES (1, '2020-04-05T00:00:00.000Z', 'Everything')` ); await tx.query(`INSERT INTO rdf_data_frame (change_set_id, entity_id, action) VALUES @@ -152,7 +152,7 @@ describe('API', () => { it('should get change set by id', async () => { await rdf.withTransaction(async (tx) => { - await tx.query(`INSERT INTO rdf_change_set (id, effective_from, notes) VALUES + await tx.query(`INSERT INTO rdf_change_set (id, effective, notes) VALUES (1, '2020-04-05T00:00:00.000Z', 'Countries'), (2, '2020-04-05T00:00:00.000Z', '2020 VAT Rates'), (3, '2020-04-05T00:00:00.000Z', '2020 CGT Rates')` diff --git a/test/dsl.test.js b/test/dsl.test.js index 9a8344c..60c91aa 100644 --- a/test/dsl.test.js +++ b/test/dsl.test.js @@ -274,7 +274,7 @@ describe('DSL', () => { - name: type type: TEXT `), (err) => { - match(err.message, new RegExp("/define_entities/0 must have X required property 'identified by' or 'identified_by'")); + match(err.message, new RegExp("/define_entities/0 must have required property 'identified by' or 'identified_by'")); return true; }); @@ -290,11 +290,11 @@ describe('DSL', () => { match(err.message, new RegExp("/define_entities/0/identified_by must be an array")); return true; }); - }, { exclusive: true }); + }); }); describe('Change Sets', () => { - it('should require an effective from date', async (t) => { + it('should require an effective date', async (t) => { await rejects(() => apply(t.name, ` add change set: - frames: @@ -305,7 +305,7 @@ describe('DSL', () => { - type: standard rate: 0.10 `), (err) => { - match(err.message, new RegExp("/add_change_set/0 must have required property 'effective from' or 'effective_from'")); + match(err.message, new RegExp("/add_change_set/0 must have required property 'effective'")); return true; }) }) @@ -313,7 +313,7 @@ describe('DSL', () => { it('should require at least one frame', async (t) => { await rejects(() => apply(t.name, ` add change set: - - effective from: 2020-04-05T00:00:00.000Z + - effective: 2020-04-05T00:00:00.000Z `), (err) => { match(err.message, new RegExp("/add_change_set/0 must have required property 'frames'")); return true; @@ -321,19 +321,18 @@ describe('DSL', () => { await rejects(() => apply(t.name, ` add change set: - - effective from: 2020-04-05T00:00:00.000Z + - effective: 2020-04-05T00:00:00.000Z frames: `), (err) => { match(err.message, new RegExp("/add_change_set/0/frames must be an array")); return true; }) - }) it('should require frames to specify an entity name', async (t) => { await rejects(() => apply(t.name, ` add change set: - - effective from: 2020-04-05T00:00:00.000Z + - effective: 2020-04-05T00:00:00.000Z frames: - version: 1 action: POST @@ -349,7 +348,7 @@ describe('DSL', () => { it('should require frames to specify an entity version', async (t) => { await rejects(() => apply(t.name, ` add change set: - - effective from: 2020-04-05T00:00:00.000Z + - effective: 2020-04-05T00:00:00.000Z frames: - entity: VAT Rate action: POST @@ -365,7 +364,7 @@ describe('DSL', () => { it('should require frames to specify an valid action', async (t) => { await rejects(() => apply(t.name, ` add change set: - - effective from: 2020-04-05T00:00:00.000Z + - effective: 2020-04-05T00:00:00.000Z frames: - entity: VAT Rate version: 1 @@ -379,7 +378,7 @@ describe('DSL', () => { await rejects(() => apply(t.name, ` add change set: - - effective from: 2020-04-05T00:00:00.000Z + - effective: 2020-04-05T00:00:00.000Z frames: - entity: VAT Rate version: 1 @@ -396,7 +395,7 @@ describe('DSL', () => { it('should require frame data to specify at least one value', async (t) => { await rejects(() => apply(t.name, ` add change set: - - effective from: 2020-04-05T00:00:00.000Z + - effective: 2020-04-05T00:00:00.000Z frames: - entity: VAT Rate version: 1 @@ -410,7 +409,7 @@ describe('DSL', () => { it('should require frame data to specify at least one value', async (t) => { await rejects(() => apply(t.name, ` add change set: - - effective from: 2020-04-05T00:00:00.000Z + - effective: 2020-04-05T00:00:00.000Z frames: - entity: VAT Rate version: 1 @@ -446,7 +445,7 @@ describe('DSL', () => { add change set: - notes: 2020 VAT Rates - effective from: 2020-04-05T00:00:00.000Z + effective: 2020-04-05T00:00:00.000Z frames: - entity: VAT Rate version: 1 @@ -468,7 +467,7 @@ describe('DSL', () => { rate: 0 - notes: 2021 VAT Rates - effective from: 2021-04-05T00:00:00.000Z + effective: 2021-04-05T00:00:00.000Z frames: - entity: VAT Rate version: 1 @@ -490,7 +489,7 @@ describe('DSL', () => { rate: 0 - notes: 2022 VAT Rates - effective from: 2022-04-05T00:00:00.000Z + effective: 2022-04-05T00:00:00.000Z frames: - entity: VAT Rate version: 1 @@ -552,7 +551,7 @@ describe('DSL', () => { add change set: - notes: 2020 VAT Rates - effective from: 2020-04-05T00:00:00.000Z + effective: 2020-04-05T00:00:00.000Z frames: - entity: VAT Rate version: 1 @@ -574,7 +573,7 @@ describe('DSL', () => { rate: 0 - notes: 2021 VAT Rates - effective from: 2021-04-05T00:00:00.000Z + effective: 2021-04-05T00:00:00.000Z frames: - entity: VAT Rate version: 1 @@ -596,7 +595,7 @@ describe('DSL', () => { rate: 0 - notes: 2022 VAT Rates - effective from: 2022-04-05T00:00:00.000Z + effective: 2022-04-05T00:00:00.000Z frames: - entity: VAT Rate version: 1 diff --git a/test/schema.test.js b/test/schema.test.js index 4388319..8d54e4e 100644 --- a/test/schema.test.js +++ b/test/schema.test.js @@ -83,7 +83,7 @@ describe('Schema', () => { it('should prevent duplicate change sets', async () => { await rdf.withTransaction(async (tx) => { - await tx.query(`INSERT INTO rdf_change_set (id, effective_from) VALUES + await tx.query(`INSERT INTO rdf_change_set (id, effective) VALUES (1, '2023-01-01T00:00:00.000Z'), (2, '2023-01-01T00:00:00.000Z') `); @@ -91,7 +91,7 @@ describe('Schema', () => { await rejects(async () => { await rdf.withTransaction(async (tx) => { - await tx.query(`INSERT INTO rdf_change_set (id, effective_from) VALUES + await tx.query(`INSERT INTO rdf_change_set (id, effective) VALUES (3, '2023-01-01T00:00:00.000Z'), (3, '2023-01-01T00:00:00.000Z')` ); @@ -102,10 +102,10 @@ describe('Schema', () => { }) }); - it('should enforce change sets have effective_from dates', async () => { + it('should enforce change sets have effective dates', async () => { await rejects(async () => { await rdf.withTransaction(async (tx) => { - await tx.query("INSERT INTO rdf_change_set (id, effective_from) VALUES (1, NULL)"); + await tx.query("INSERT INTO rdf_change_set (id, effective) VALUES (1, NULL)"); }); }, (err) => { eq(err.code, '23502'); @@ -117,7 +117,7 @@ describe('Schema', () => { const before = new Date(); await rdf.withTransaction(async (tx) => { - await tx.query(`INSERT INTO rdf_change_set (id, effective_from, notes) VALUES + await tx.query(`INSERT INTO rdf_change_set (id, effective, notes) VALUES (1, '2020-04-05T00:00:00.000Z', 'Countries')` ); }); @@ -128,7 +128,7 @@ describe('Schema', () => { it('should default entity tag to random hex', async () => { await rdf.withTransaction(async (tx) => { - await tx.query(`INSERT INTO rdf_change_set (id, effective_from, notes) VALUES + await tx.query(`INSERT INTO rdf_change_set (id, effective, notes) VALUES (1, '2020-04-05T00:00:00.000Z', 'Countries')` ); });