From 11131045e574ee5fb3dac672528d4c798e43d61a Mon Sep 17 00:00:00 2001 From: OleksandrVidinieiev <56632770+OleksandrVidinieiev@users.noreply.github.com> Date: Fri, 8 Sep 2023 13:29:51 +0300 Subject: [PATCH 1/4] CIRCSTORE-445: Create constraints only if they don't exist (#424) * CIRCSTORE-445 Create constraints only if they don't exist * CIRCSTORE-445 Create column only when it does not exist --- .../insertEmptyCirculationRulesRecord.sql | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/resources/templates/db_scripts/insertEmptyCirculationRulesRecord.sql b/src/main/resources/templates/db_scripts/insertEmptyCirculationRulesRecord.sql index 649f7cc09..636c7e646 100644 --- a/src/main/resources/templates/db_scripts/insertEmptyCirculationRulesRecord.sql +++ b/src/main/resources/templates/db_scripts/insertEmptyCirculationRulesRecord.sql @@ -1,7 +1,20 @@ -- ensure that there will be one row only -ALTER TABLE ${myuniversity}_${mymodule}.${table.tableName} - ADD COLUMN IF NOT EXISTS - lock boolean DEFAULT true UNIQUE CHECK(lock=true); +DO $$ +BEGIN + -- create constraints only if they do not exist, otherwise they are piling up + IF NOT EXISTS ( + SELECT constraint_name + FROM information_schema.constraint_column_usage + WHERE table_schema = '${myuniversity}_${mymodule}' + AND table_name = '${table.tableName}' + AND column_name = 'lock' + AND constraint_name LIKE '${table.tableName}_lock_%' + ) THEN + ALTER TABLE ${myuniversity}_${mymodule}.${table.tableName} + -- this will create constraints even when column already exists + ADD COLUMN IF NOT EXISTS lock boolean DEFAULT true UNIQUE CHECK(lock=true); + END IF; +END $$; INSERT INTO ${myuniversity}_${mymodule}.${table.tableName} SELECT id, jsonb_build_object('id', id, 'rulesAsText', '') FROM (SELECT md5('${myuniversity}_${mymodule}.${table.tableName}.rulesAsText')::uuid AS id) AS alias From 964e6293e2f7aeb40888ffbec4076f2b4b5b2fc0 Mon Sep 17 00:00:00 2001 From: OleksandrVidinieiev <56632770+OleksandrVidinieiev@users.noreply.github.com> Date: Wed, 13 Sep 2023 17:44:37 +0300 Subject: [PATCH 2/4] CIRCSTORE-409: Add missing descriptions to JSON-schemas (#427) * CIRCSTORE-409 Add missing descriptions to JSON-schemas * CIRCSTORE-409 Add missing description * CIRCSTORE-409 Fix typos --- ramls/anonymize-storage-loans-response.json | 1 + ramls/cancellation-reason.json | 5 +++++ ramls/fixed-due-date-schedule.json | 3 +++ ramls/kv-configuration.json | 9 +++++++++ ramls/kv-configurations.json | 2 ++ ramls/loan-policy.json | 7 +++++++ ramls/patron-notice-policy.json | 9 +++++++++ ramls/period.json | 1 + ramls/scheduled-notice.json | 2 ++ ramls/staff-slip.json | 5 +++++ 10 files changed, 44 insertions(+) diff --git a/ramls/anonymize-storage-loans-response.json b/ramls/anonymize-storage-loans-response.json index 0b4a8fe3e..e113cc777 100644 --- a/ramls/anonymize-storage-loans-response.json +++ b/ramls/anonymize-storage-loans-response.json @@ -11,6 +11,7 @@ } }, "notAnonymizedLoans": { + "description": "Not anonymized loan IDs", "type": "array", "items": { "description": "Collection of loans", diff --git a/ramls/cancellation-reason.json b/ramls/cancellation-reason.json index 2aec1416c..46270d5ac 100644 --- a/ramls/cancellation-reason.json +++ b/ramls/cancellation-reason.json @@ -1,20 +1,25 @@ { "$schema": "http://json-schema.org/draft-04/schema#", + "description": "Request cancellation reason", "type": "object", "properties": { "id": { "type": "string" }, "name": { + "description": "Reason name", "type": "string" }, "description" : { + "description": "Internal reason description", "type": "string" }, "publicDescription": { + "description": "Public reason description", "type": "string" }, "requiresAdditionalInformation": { + "description": "Flag that indicates whether reason requires additional information", "type": "boolean" }, "source": { diff --git a/ramls/fixed-due-date-schedule.json b/ramls/fixed-due-date-schedule.json index 162edcb72..f99c71929 100644 --- a/ramls/fixed-due-date-schedule.json +++ b/ramls/fixed-due-date-schedule.json @@ -9,13 +9,16 @@ "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" }, "name": { + "description": "Schedule name", "type": "string" }, "description": { + "description": "Schedule description", "type": "string" }, "schedules": { "id": "schedules", + "description": "List date ranges with a due date for each", "type": "array", "items": { "type": "object", diff --git a/ramls/kv-configuration.json b/ramls/kv-configuration.json index f7bec6b6c..ffcb73a7d 100644 --- a/ramls/kv-configuration.json +++ b/ramls/kv-configuration.json @@ -1,33 +1,42 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", + "description": "Configuration entry", "properties": { "id": { "type": "string", "$ref": "raml-util/schemas/uuid.schema" }, "module": { + "description": "Name of a FOLIO module", "type": "string" }, "configName": { + "description": "Configuration name", "type": "string" }, "code": { + "description": "Configuration code", "type": "string" }, "description": { + "description": "Configuration description", "type": "string" }, "default": { + "description": "Flag that indicates whether this is the default configuration", "type": "boolean" }, "enabled": { + "description": "Flag that indicates whether this configuration is enabled", "type": "boolean" }, "value": { + "description": "Configuration value", "type": "string" }, "userId": { + "description": "User ID", "type": "string" }, "metadata": { diff --git a/ramls/kv-configurations.json b/ramls/kv-configurations.json index 0125ab572..cb8e1a8cf 100644 --- a/ramls/kv-configurations.json +++ b/ramls/kv-configurations.json @@ -1,9 +1,11 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", + "description": "Collection of configuration entries", "properties": { "configs": { "id": "configurationData", + "description": "An array of configuration entries", "type": "array", "items": { "type": "object", diff --git a/ramls/loan-policy.json b/ramls/loan-policy.json index a54bf12d2..6599c50eb 100644 --- a/ramls/loan-policy.json +++ b/ramls/loan-policy.json @@ -15,10 +15,12 @@ "type": "string" }, "loanable": { + "description": "Flag that indicates whether this policy allows loans", "type": "boolean" }, "loansPolicy": { "type": "object", + "description": "Settings for loans", "additionalProperties": false, "properties": { "profileId": { @@ -62,6 +64,7 @@ }, "renewalsPolicy": { "type": "object", + "description": "Settings for renewals", "properties": { "unlimited": { "type": "boolean", @@ -92,10 +95,12 @@ }, "requestManagement": { "type": "object", + "description": "Settings for various request types", "additionalProperties": false, "properties": { "recalls": { "type": "object", + "description": "Settings for recall requests", "additionalProperties": false, "properties": { "alternateGracePeriod": { @@ -127,6 +132,7 @@ }, "holds": { "type": "object", + "description": "Settings for hold requests", "additionalProperties": false, "properties": { "alternateCheckoutLoanPeriod": { @@ -147,6 +153,7 @@ }, "pages": { "type": "object", + "description": "Settings for page requests", "additionalProperties": false, "properties": { "alternateCheckoutLoanPeriod": { diff --git a/ramls/patron-notice-policy.json b/ramls/patron-notice-policy.json index 24fb7676f..c42c7e4c6 100644 --- a/ramls/patron-notice-policy.json +++ b/ramls/patron-notice-policy.json @@ -67,6 +67,7 @@ }, "sendOptions": { "type": "object", + "description": "Notice sending options", "additionalProperties": false, "properties": { "sendHow": { @@ -93,10 +94,12 @@ }, "sendBy": { "type": "object", + "description": "Delay before the first attempt to send a notice", "$ref": "interval.json" }, "sendEvery": { "type": "object", + "description": "Interval between attempts to send a recurring notice", "$ref": "interval.json" } }, @@ -154,6 +157,7 @@ }, "sendOptions": { "type": "object", + "description": "Notice sending options", "additionalProperties": false, "properties": { "sendHow": { @@ -177,10 +181,12 @@ }, "sendBy": { "type": "object", + "description": "Delay before the first attempt to send a notice", "$ref": "interval.json" }, "sendEvery": { "type": "object", + "description": "Interval between attempts to send a recurring notice", "$ref": "interval.json" } }, @@ -238,6 +244,7 @@ }, "sendOptions": { "type": "object", + "description": "Notice sending options", "additionalProperties": false, "properties": { "sendHow": { @@ -264,10 +271,12 @@ }, "sendBy": { "type": "object", + "description": "Delay before the first attempt to send a notice", "$ref": "interval.json" }, "sendEvery": { "type": "object", + "description": "Interval between attempts to send a recurring notice", "$ref": "interval.json" } }, diff --git a/ramls/period.json b/ramls/period.json index eba9c1fc4..2588155d9 100644 --- a/ramls/period.json +++ b/ramls/period.json @@ -1,6 +1,7 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", + "description": "Time interval defined by its duration", "properties": { "duration": { "type": "integer", diff --git a/ramls/scheduled-notice.json b/ramls/scheduled-notice.json index d87643127..5c921d340 100644 --- a/ramls/scheduled-notice.json +++ b/ramls/scheduled-notice.json @@ -1,6 +1,7 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", + "description": "Scheduled patron notice", "properties": { "id": { "type": "string", @@ -55,6 +56,7 @@ }, "noticeConfig": { "type": "object", + "description": "Scheduled notice configuration", "properties": { "timing": { "type": "string", diff --git a/ramls/staff-slip.json b/ramls/staff-slip.json index 36c65b933..02868e662 100644 --- a/ramls/staff-slip.json +++ b/ramls/staff-slip.json @@ -1,20 +1,25 @@ { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", + "description": "Staff slip", "properties": { "id": { "type": "string" }, "name": { + "description": "Staff slip name", "type": "string" }, "description": { + "description": "Staff slip description", "type": "string" }, "active": { + "description": "Flag that indicates whether staff slip is active", "type": "boolean" }, "template": { + "description": "Staff slip template", "type": "string" }, "metadata": { From 24fbd2fc318ce41162786c45a2cc68423d94fe4b Mon Sep 17 00:00:00 2001 From: Roman Barannyk <53909129+roman-barannyk@users.noreply.github.com> Date: Thu, 14 Sep 2023 17:30:27 +0300 Subject: [PATCH 3/4] CIRCSTORE-272 add action index (#425) --- src/main/resources/templates/db_scripts/schema.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/resources/templates/db_scripts/schema.json b/src/main/resources/templates/db_scripts/schema.json index bd55a00c5..53857ce04 100644 --- a/src/main/resources/templates/db_scripts/schema.json +++ b/src/main/resources/templates/db_scripts/schema.json @@ -122,6 +122,12 @@ "caseSensitive": false, "removeAccents": false, "sqlExpression": "(jsonb->'agedToLostDelayedBilling'->>'dateLostItemShouldBeBilled')" + }, + { + "fieldName": "action", + "tOps": "ADD", + "caseSensitive": false, + "removeAccents": true } ], "fullTextIndex": [ From 0919867f38521c9f9f81c0e8ab4d7a6ae351f642 Mon Sep 17 00:00:00 2001 From: Niels Erik Nielsen Date: Mon, 2 Oct 2023 09:41:33 +0200 Subject: [PATCH 4/4] Update interface version (CIRCSTORE-452) - scheduled-notice-storage 0.5 -> 0.6 due to added enum value for triggering event. --- descriptors/ModuleDescriptor-template.json | 2 +- ramls/scheduled-notice-storage.raml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json index 7fb206d51..4a6d92716 100644 --- a/descriptors/ModuleDescriptor-template.json +++ b/descriptors/ModuleDescriptor-template.json @@ -403,7 +403,7 @@ }, { "id": "scheduled-notice-storage", - "version": "0.5", + "version": "0.6", "handlers": [ { "methods": ["GET"], diff --git a/ramls/scheduled-notice-storage.raml b/ramls/scheduled-notice-storage.raml index 573a64fc9..3583dc6e0 100644 --- a/ramls/scheduled-notice-storage.raml +++ b/ramls/scheduled-notice-storage.raml @@ -1,6 +1,6 @@ #%RAML 1.0 title: Scheduled Notice Storage -version: v0.5 +version: v0.6 protocols: [ HTTP, HTTPS ] baseUri: http://localhost:9130