Skip to content

Commit

Permalink
feat: free plan migration
Browse files Browse the repository at this point in the history
  • Loading branch information
darkskygit authored and EYHN committed Apr 9, 2024
1 parent 347398d commit 3c7e573
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { PrismaClient } from '@prisma/client';

import { Quotas } from '../../core/quota';
import { upgradeQuotaVersion } from './utils/user-quotas';

export class RefreshFreePlan1712224382221 {
// do the migration
static async up(db: PrismaClient) {
// free plan 1.0
const quota = Quotas[4];
await upgradeQuotaVersion(db, quota, 'free plan 1.1 migration');
}

// revert the migration
static async down(_db: PrismaClient) {}
}
2 changes: 1 addition & 1 deletion packages/backend/server/tests/quota.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ test('should be able to set quota', async t => {
const q1 = await quota.getUserQuota(u1.id);
t.truthy(q1, 'should have quota');
t.is(q1?.feature.name, QuotaType.FreePlanV1, 'should be free plan');
t.is(q1?.feature.version, 3, 'should be version 2');
t.is(q1?.feature.version, 4, 'should be version 2');

await quota.switchUserQuota(u1.id, QuotaType.ProPlanV1);

Expand Down

0 comments on commit 3c7e573

Please sign in to comment.