mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
feat: refresh new workspace feature (#5834)
This commit is contained in:
@@ -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 {
|
||||
CommonFeature,
|
||||
FeatureKind,
|
||||
Features,
|
||||
FeatureType,
|
||||
} 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) {
|
||||
const waitingList = await prisma.newFeaturesWaitingList.findMany();
|
||||
for (const oldUser of waitingList) {
|
||||
|
||||
Reference in New Issue
Block a user