Skip to content

Commit 1fe1966

Browse files
committed
Update description of row of migrated credits
1 parent 40921f7 commit 1fe1966

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

packages/billing/src/__tests__/subscription.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,8 +359,14 @@ describe('subscription', () => {
359359
})
360360

361361
expect(captures.updateSets).toHaveLength(2)
362-
expect(captures.updateSets[0]).toEqual({ balance: 0 })
363-
expect(captures.updateSets[1]).toEqual({ balance: 0 })
362+
expect(captures.updateSets[0]).toEqual({
363+
balance: 0,
364+
description: 'Migrated 300 credits to subscribe-migrate-sub-123',
365+
})
366+
expect(captures.updateSets[1]).toEqual({
367+
balance: 0,
368+
description: 'Migrated 200 credits to subscribe-migrate-sub-123',
369+
})
364370

365371
expect(captures.insertValues).toHaveLength(1)
366372
expect(captures.insertValues[0].principal).toBe(500)

packages/billing/src/subscription.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,10 @@ export async function migrateUnusedCredits(params: {
730730
for (const grant of unusedGrants) {
731731
await tx
732732
.update(schema.creditLedger)
733-
.set({ balance: 0 })
733+
.set({
734+
balance: 0,
735+
description: `Migrated ${grant.balance} credits to ${operationId}`,
736+
})
734737
.where(eq(schema.creditLedger.operation_id, grant.operation_id))
735738
}
736739

0 commit comments

Comments
 (0)