From 27d67a33e5c61cc29751eae36c4e85ddff059fcc Mon Sep 17 00:00:00 2001 From: Mildred Ki'Lya Date: Tue, 16 Jan 2024 23:46:01 +0100 Subject: [PATCH] fix: #808 Payment referenceType NULL due to bad migration --- backend/patches/index.ts | 6 ++++++ backend/patches/setPaymentReferenceType.ts | 9 +++++++++ 2 files changed, 15 insertions(+) create mode 100644 backend/patches/setPaymentReferenceType.ts diff --git a/backend/patches/index.ts b/backend/patches/index.ts index 9dee78bb..5d59c1d9 100644 --- a/backend/patches/index.ts +++ b/backend/patches/index.ts @@ -4,6 +4,7 @@ import createInventoryNumberSeries from './createInventoryNumberSeries'; import fixRoundOffAccount from './fixRoundOffAccount'; import testPatch from './testPatch'; import updateSchemas from './updateSchemas'; +import setPaymentReferenceType from './setPaymentReferenceType'; export default [ { name: 'testPatch', version: '0.5.0-beta.0', patch: testPatch }, @@ -28,4 +29,9 @@ export default [ version: '0.6.6-beta.0', patch: createInventoryNumberSeries, }, + { + name: 'setPaymentReferenceType', + version: '0.21.0', + patch: setPaymentReferenceType, + }, ] as Patch[]; diff --git a/backend/patches/setPaymentReferenceType.ts b/backend/patches/setPaymentReferenceType.ts new file mode 100644 index 00000000..a141e201 --- /dev/null +++ b/backend/patches/setPaymentReferenceType.ts @@ -0,0 +1,9 @@ +import { DatabaseManager } from '../database/manager'; + +async function execute(dm: DatabaseManager) { + await dm.db!.knex!('Payment') + .where({ referenceType: null }) + .update({ referenceType: 'SalesInvoice' }); +} + +export default { execute, beforeMigrate: true };