Uploaded image for project: 'RAML Module Builder'
  1. RAML Module Builder
  2. RMB-877

Schema name can't replace in snippet (schema.json)

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • TBD
    • Resolution: Done
    • None
    • 33.2.0
    • None
    • CP: sprint 125
    • 1
    • Core: Platform

    Description

      When enabling mod-source-record-manager from 3.1.3 -> v3.2.0, it is throwing error. Please the screenshot. Also, I have attached full log.
      @VarunJavalkar was able to deploy other modules which are
      mod-inventory-storage v22.0.0
      mod-inventory v18.0.0
      mod-source-record-storage v5.2.0
      mod-data-import v2.2.0
      Here are environment details if you want to access https://pre-kiwi-cap1.int.aws.folio.org/settings folio/folio

       

      Migrating mod-source-record-manager fails with this error

      { "message": "type \"rule_type\" already exists", "severity": "ERROR", "code": "42710", "where": "SQL statement \"create type rule_type AS ENUM ('MARC_BIB', 'MARC_HOLDING')\"
      PL/pgSQL function inline_code_block line 1 at SQL statement", "file": "typecmds.c", "line": "1191", "routine": "DefineEnum" }" 

      while executing this snippet:

      https://github.com/folio-org/mod-source-record-manager/blob/v3.2.0/mod-source-record-manager-server/src/main/resources/templates/db_scripts/schema.json#L167-170

      {
        "run": "after",
        "snippet": "DO $$ BEGIN IF NOT EXISTS (SELECT 1 FROM pg_type t JOIN pg_enum e ON t.oid = e.enumtypid JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace WHERE t.typname = 'rule_type' AND n.nspname = '${myuniversity}_${mymodule}') THEN create type rule_type AS ENUM ('MARC_BIB', 'MARC_HOLDING'); END IF; END $$; ALTER TABLE mapping_rules ADD COLUMN IF NOT EXISTS record_type rule_type NOT NULL DEFAULT 'MARC_BIB';",
        "fromModuleVersion": "mod-source-record-manager-3.2.0"
      }

      A snippet in schema.json must be a single line. This is the snipped reformatted for readability to help with debugging this issue:

      DO $$
      BEGIN
        IF NOT EXISTS (SELECT 1 FROM pg_type t
                       JOIN pg_enum e ON t.oid = e.enumtypid
                       JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace
                       WHERE t.typname = 'rule_type' AND n.nspname = '${myuniversity}_${mymodule}')
        THEN create type rule_type AS ENUM ('MARC_BIB', 'MARC_HOLDING');
        END IF;
      END $$;
      ALTER TABLE mapping_rules
        ADD COLUMN IF NOT EXISTS record_type rule_type NOT NULL DEFAULT 'MARC_BIB';

      The log shows that the placeholder ${myuniversity}_${mymodule} is NOT replaced by the actual values:

      TestRail: Results

        Attachments

          Issue Links

            Activity

              People

                julianladisch Julian Ladisch
                Oleksii Petrenko Oleksii Petrenko
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  TestRail: Runs

                    TestRail: Cases