Uploaded image for project: 'mod-finance-storage'
  1. mod-finance-storage
  2. MODFISTO-213

ledgerfy does not exist when migating from v4.2.2 to v6.0.1

    XMLWordPrintable

Details

    • ACQ Sprint 110, ACQ Sprint 111
    • 2
    • Thunderjet
    • R1 2021 Bug Fix

    Description

      Overview:
      pending_payment_cross_module.ftl contains a migration script for ledgerFy since v5.0.0.
      However, ledgerFy has been delete since v6.0.0.
      Steps to Reproduce:
      Migrate mod-finance-storage from v4.2.2 (Fameflower) to v6.0.1 (Honeysuckle):

      # in first console
      docker run --name postgres5433 -e POSTGRES_PASSWORD=postgres -p 5433:5432 -d postgres:10-alpine
      export DB_DATABASE=postgres DB_HOST=172.17.0.1 DB_PASSWORD=postgres DB_PORT=5433 DB_RUNNER_PORT=5430 DB_USERNAME=postgres
      git checkout v4.2.2
      # use Java 8
      mvn clean package -DskipTests
      java -jar target/mod-finance-storage-fat.jar
      
      # in second console
      curl '-w\n' -s -S -D - -H 'Content-type: application/json' -H 'x-okapi-url-to: http://localhost:8081' -H 'x-okapi-tenant: diku' -XPOST -d '{ "module_to": "", "parameters": [{ "key": "loadReference", "value": "true" }]}' http://localhost:8081/_/tenant
      
      # in first console
      # stop java by pressing Ctrl+C
      git checkout v6.0.1
      # delete lines 9-63 of pending_payment_cross_module.ftl to remove
      # illegal cross-module mod_invoice_storage access that shades this issue
      # use Java 11
      mvn clean package -DskipTests
      java -jar target/mod-finance-storage-fat.jar
      
      # in second console
      curl '-w\n' -s -S -D - -H 'Content-type: application/json' -H 'x-okapi-url-to: http://localhost:8081' -H 'x-okapi-tenant: diku' -XPOST -d '{"module_from": "mod-finance-storage-4.2.2", "module_to": "mod-finance-storage-6.0.1" }' http://localhost:8081/_/tenant
      

      Expected Results:
      Migration succeeds
      Actual Results:
      Migration fails with this error in the log in the first console:

      2021-01-18T17:15:06,868 INFO  [vert.x-worker-thread-1   ] PostgresClient trying to execute:  UPDATE diku_mod_finance_storage.ledgerFy as ledger_fy   SET     jsonb = jsonb || jsonb_build_object('available', (jsonb->>'available')::decimal - sub.total,                                         'unavailable', (jsonb->>'unavailable')::decimal + sub.total)   FROM (SELECT ledger.id AS ledgerId, transactions.fiscalYearId AS fiscalYearId, sum((transactions.jsonb->>'amount')::decimal) AS total         FROM diku_mod_finance_storage.transaction AS transactions         LEFT JOIN diku_mod_invoice_storage.invoices AS invoices ON transactions.jsonb->>'sourceInvoiceId'=invoices.id::text         LEFT JOIN diku_mod_finance_storage.fund AS fund ON transactions.fromFundId = fund.id         LEFT JOIN diku_mod_finance_storage.ledger AS ledger ON fund.ledgerId = ledger.id         WHERE invoices.jsonb->>'status' = 'Approved'           AND transactions.jsonb->>'transactionType'='Pending payment'           AND NOT transactions.jsonb ? 'awaitingPayment'         GROUP BY ledger.id, transactions.fiscalYearI
      2021-01-18T17:15:06,873 ERROR [vert.x-worker-thread-1   ] PostgresClient ERROR: relation "diku_mod_finance_storage.ledgerfy" does not exist
        Position: 9
      org.postgresql.util.PSQLException: ERROR: relation "diku_mod_finance_storage.ledgerfy" does not exist
        Position: 9
              at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2310) ~[mod-finance-storage-fat.jar:?]
      

      Task:
      Remove the ledgerfy migration code pending_payment_cross_module.ftl.
      Credits:
      This bug has been reported by Ingolf Kuss from hbz on #sys-ops Slack channel.
      Workaround:
      Deploy mod-finance-storage:5.0.2 and after that deploy mod-finance-storage:6.0.1

      TestRail: Results

        Attachments

          Issue Links

            Activity

              People

                siarhei_hrabko Siarhei Hrabko
                julianladisch Julian Ladisch
                Votes:
                1 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved:

                  TestRail: Runs

                    TestRail: Cases