mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-22 19:53:48 +08:00
feat: refresh new workspace feature (#5834)
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
|||||||
|
import { PrismaClient } from '@prisma/client';
|
||||||
|
|
||||||
|
import { FeatureType } from '../../core/features';
|
||||||
|
import { upsertLatestFeatureVersion } from './utils/user-features';
|
||||||
|
|
||||||
|
export class RefreshUnlimitedWorkspaceFeature1708321519830 {
|
||||||
|
// do the migration
|
||||||
|
static async up(db: PrismaClient) {
|
||||||
|
// add unlimited workspace feature
|
||||||
|
await upsertLatestFeatureVersion(db, FeatureType.UnlimitedWorkspace);
|
||||||
|
}
|
||||||
|
|
||||||
|
// revert the migration
|
||||||
|
static async down(_db: PrismaClient) {}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import { Prisma, PrismaClient } from '@prisma/client';
|
|||||||
import {
|
import {
|
||||||
CommonFeature,
|
CommonFeature,
|
||||||
FeatureKind,
|
FeatureKind,
|
||||||
|
Features,
|
||||||
FeatureType,
|
FeatureType,
|
||||||
} from '../../../core/features';
|
} from '../../../core/features';
|
||||||
|
|
||||||
@@ -33,6 +34,16 @@ export async function upsertFeature(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function upsertLatestFeatureVersion(
|
||||||
|
db: PrismaClient,
|
||||||
|
type: FeatureType
|
||||||
|
) {
|
||||||
|
const feature = Features.filter(f => f.feature === type);
|
||||||
|
feature.sort((a, b) => b.version - a.version);
|
||||||
|
const latestFeature = feature[0];
|
||||||
|
await upsertFeature(db, latestFeature);
|
||||||
|
}
|
||||||
|
|
||||||
export async function migrateNewFeatureTable(prisma: PrismaClient) {
|
export async function migrateNewFeatureTable(prisma: PrismaClient) {
|
||||||
const waitingList = await prisma.newFeaturesWaitingList.findMany();
|
const waitingList = await prisma.newFeaturesWaitingList.findMany();
|
||||||
for (const oldUser of waitingList) {
|
for (const oldUser of waitingList) {
|
||||||
|
|||||||
Reference in New Issue
Block a user