Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #808 Payment referenceType NULL due to bad migration #809

Merged
merged 2 commits into from
Jan 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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',
Isaac-GC marked this conversation as resolved.
Show resolved Hide resolved
patch: setPaymentReferenceType,
},
] as Patch[];
12 changes: 12 additions & 0 deletions backend/patches/setPaymentReferenceType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { DatabaseManager } from '../database/manager';

async function execute(dm: DatabaseManager) {
await dm.db!.knex!('Payment')
.where({ referenceType: null, paymentType: 'Pay' })
.update({ referenceType: 'PurchaseInvoice' });
await dm.db!.knex!('Payment')
.where({ referenceType: null, paymentType: 'Receive' })
.update({ referenceType: 'SalesInvoice' });
}

export default { execute, beforeMigrate: true };
Loading