feat(server): support team workspace subscription (#8919)

close AF-1724, AF-1722
This commit is contained in:
forehalo
2024-12-05 08:31:01 +00:00
parent 4055e3aa67
commit 5bf8ed1095
26 changed files with 2208 additions and 785 deletions

View File

@@ -0,0 +1,29 @@
import { PrismaClient } from '@prisma/client';
import { loop } from './utils/loop';
export class UniversalSubscription1733125339942 {
// do the migration
static async up(db: PrismaClient) {
await loop(async (offset, take) => {
const oldSubscriptions = await db.deprecatedUserSubscription.findMany({
skip: offset,
take,
});
await db.subscription.createMany({
data: oldSubscriptions.map(s => ({
targetId: s.userId,
...s,
})),
});
return oldSubscriptions.length;
}, 50);
}
// revert the migration
static async down(_db: PrismaClient) {
// noop
}
}