diff --git a/backend/patches/index.ts b/backend/patches/index.ts index 9dee78bb9..5d59c1d98 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 000000000..a141e201c --- /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 };