Data migration script fails due to FK constraint

Description

Overview

When upgrading from v3.0.1 (Edelweiss) to v3.1.0 (FameFlower), data migration scripts for invoices and vouchers fail because of a foreign key constraint.

The issue is that we have data migration scripts which update invoice and voucher records to add a new required field (batchGroupId). The value we use for this is the "default" batch group, which we insert as "system" data - akin to reference or sample data, but always loaded. Since that data doesn't get loaded until after the db migration scripts run, the batch group doesn't exist when the migration scripts are run, causing them to fail because they violate the FK constraint.

Relevant log snippet:

CSP Request Details

None

CSP Rejection Details

None

Potential Workaround

None

Checklist

hide

TestRail: Results

Activity

Show:

Andrei Makaranka March 30, 2020 at 7:06 PM
Edited

Verified locally:

1. Checkout and build mod-invoice-storage-3.0.1
2. Start it up locally, pointing to a local database

3. Call the tenant API directly, with loadSample: true - this is what OKAPI is doing when you enable the module for a tenant:

Then look at your db and see the new schema for your tenant, and the sample data loaded

4. Stop the module
5. Checkout and build mod-invoice-storage HEAD of master
6. Start it up locally, pointing to the same local database
7. Call the tenant API directly again, this time specifying both module_from and module_to (see comments in ticket for details) - This is what OKAPI is doing when upgrading from 3.0.1 -> 3.1.1

8. If that call returns successfully (201) you're pretty much all set. Log output from the module is right in the console

Logs:

Craig McNally March 30, 2020 at 2:28 PM
Edited

Verified locally:

1) Deploy mod-invoice-storage-3.0.1 with sample data

2) Deploy mod-invoice-storage-3.1.1-SNAPSHOT and directly hit tenant API to upgrade to 3.1.1

Log Snippets:

Done

Details

Assignee

Reporter

Tester Assignee

Priority

Story Points

Sprint

Development Team

Thunderjet

Fix versions

TestRail: Cases

Open TestRail: Cases

TestRail: Runs

Open TestRail: Runs

Created March 27, 2020 at 5:09 AM
Updated April 6, 2020 at 10:06 PM
Resolved March 30, 2020 at 7:12 PM
TestRail: Cases
TestRail: Runs