mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 20:38:52 +00:00
feat(server): support team workspace subscription (#8919)
close AF-1724, AF-1722
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user