Skip to content

Commit

Permalink
fix: #808 Payment referenceType NULL due to bad migration
Browse files Browse the repository at this point in the history
  • Loading branch information
mildred committed Jan 16, 2024
1 parent b1be14f commit 83af275
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions backend/patches/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand All @@ -28,4 +29,9 @@ export default [
version: '0.6.6-beta.0',
patch: createInventoryNumberSeries,
},
{
name: 'setPaymentReferenceType',
version: '0.21.0',
patch: setPaymentReferenceType,
},
] as Patch[];
9 changes: 9 additions & 0 deletions backend/patches/setPaymentReferenceType.ts
Original file line number Diff line number Diff line change
@@ -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 };

0 comments on commit 83af275

Please sign in to comment.