mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-18 18:46:19 +08:00
test(server): avoid progress get hold after tests finished (#5522)
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import '../prelude';
|
||||
|
||||
import { Logger, Module } from '@nestjs/common';
|
||||
import { CommandFactory } from 'nest-commander';
|
||||
|
||||
@@ -14,6 +16,9 @@ import { RevertCommand, RunCommand } from './commands/run';
|
||||
enableUpdateAutoMerging: false,
|
||||
},
|
||||
},
|
||||
metrics: {
|
||||
enabled: false,
|
||||
},
|
||||
}),
|
||||
BusinessAppModule,
|
||||
],
|
||||
|
||||
@@ -59,13 +59,13 @@ export class CreateCommand extends CommandRunner {
|
||||
}
|
||||
|
||||
private createScript(name: string) {
|
||||
const contents = ["import { PrismaService } from '../../prisma';", ''];
|
||||
const contents = ["import { PrismaClient } from '@prisma/client';", ''];
|
||||
contents.push(`export class ${name} {`);
|
||||
contents.push(' // do the migration');
|
||||
contents.push(' static async up(db: PrismaService) {}');
|
||||
contents.push(' static async up(db: PrismaClient) {}');
|
||||
contents.push('');
|
||||
contents.push(' // revert the migration');
|
||||
contents.push(' static async down(db: PrismaService) {}');
|
||||
contents.push(' static async down(db: PrismaClient) {}');
|
||||
|
||||
contents.push('}');
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import { applyUpdate, Doc, encodeStateAsUpdate } from 'yjs';
|
||||
|
||||
import { PrismaService } from '../../prisma';
|
||||
import { DocID } from '../../utils/doc';
|
||||
|
||||
export class Guid1698398506533 {
|
||||
// do the migration
|
||||
static async up(db: PrismaService) {
|
||||
static async up(db: PrismaClient) {
|
||||
let turn = 0;
|
||||
let lastTurnCount = 100;
|
||||
while (lastTurnCount === 100) {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
import { Features } from '../../modules/features';
|
||||
import { Quotas } from '../../modules/quota/schema';
|
||||
import { PrismaService } from '../../prisma';
|
||||
import { migrateNewFeatureTable, upsertFeature } from './utils/user-features';
|
||||
|
||||
export class UserFeaturesInit1698652531198 {
|
||||
// do the migration
|
||||
static async up(db: PrismaService) {
|
||||
static async up(db: PrismaClient) {
|
||||
// upgrade features from lower version to higher version
|
||||
for (const feature of Features) {
|
||||
await upsertFeature(db, feature);
|
||||
@@ -18,7 +19,7 @@ export class UserFeaturesInit1698652531198 {
|
||||
}
|
||||
|
||||
// revert the migration
|
||||
static async down(_db: PrismaService) {
|
||||
static async down(_db: PrismaClient) {
|
||||
// TODO: revert the migration
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { PrismaService } from '../../prisma';
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
export class PagePermission1699005339766 {
|
||||
// do the migration
|
||||
static async up(db: PrismaService) {
|
||||
static async up(db: PrismaClient) {
|
||||
let turn = 0;
|
||||
let lastTurnCount = 50;
|
||||
const done = new Set<string>();
|
||||
@@ -88,7 +87,7 @@ export class PagePermission1699005339766 {
|
||||
}
|
||||
|
||||
// revert the migration
|
||||
static async down(db: PrismaService) {
|
||||
static async down(db: PrismaClient) {
|
||||
await db.workspaceUserPermission.deleteMany({});
|
||||
await db.workspacePageUserPermission.deleteMany({});
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { QuotaType } from '../../modules/quota/types';
|
||||
import { PrismaService } from '../../prisma';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
import { QuotaType } from '../../modules/quota/types';
|
||||
export class OldUserFeature1702620653283 {
|
||||
// do the migration
|
||||
static async up(db: PrismaService) {
|
||||
static async up(db: PrismaClient) {
|
||||
await db.$transaction(async tx => {
|
||||
const latestFreePlan = await tx.features.findFirstOrThrow({
|
||||
where: { feature: QuotaType.FreePlanV1 },
|
||||
@@ -31,7 +31,7 @@ export class OldUserFeature1702620653283 {
|
||||
|
||||
// revert the migration
|
||||
// WARN: this will drop all user features
|
||||
static async down(db: PrismaService) {
|
||||
static async down(db: PrismaClient) {
|
||||
await db.userFeatures.deleteMany({});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
import type { UserType } from '../../modules/users';
|
||||
import { PrismaService } from '../../prisma';
|
||||
|
||||
export class UnamedAccount1703756315970 {
|
||||
// do the migration
|
||||
static async up(db: PrismaService) {
|
||||
static async up(db: PrismaClient) {
|
||||
await db.$transaction(async tx => {
|
||||
// only find users with empty names
|
||||
const users = await db.$queryRaw<
|
||||
@@ -27,5 +28,5 @@ export class UnamedAccount1703756315970 {
|
||||
}
|
||||
|
||||
// revert the migration
|
||||
static async down(_db: PrismaService) {}
|
||||
static async down(_db: PrismaClient) {}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { ModuleRef } from '@nestjs/core';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
import { WorkspaceBlobStorage } from '../../modules/storage';
|
||||
import { PrismaService } from '../../prisma';
|
||||
|
||||
export class WorkspaceBlobs1703828796699 {
|
||||
// do the migration
|
||||
static async up(db: PrismaService, injector: ModuleRef) {
|
||||
static async up(db: PrismaClient, injector: ModuleRef) {
|
||||
const blobStorage = injector.get(WorkspaceBlobStorage, { strict: false });
|
||||
let hasMore = true;
|
||||
let turn = 0;
|
||||
@@ -32,7 +32,7 @@ export class WorkspaceBlobs1703828796699 {
|
||||
}
|
||||
|
||||
// revert the migration
|
||||
static async down(_db: PrismaService) {
|
||||
static async down(_db: PrismaClient) {
|
||||
// old data kept, no need to downgrade the migration
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
import { Features } from '../../modules/features';
|
||||
import { PrismaService } from '../../prisma';
|
||||
import { upsertFeature } from './utils/user-features';
|
||||
|
||||
export class RefreshUserFeatures1704352562369 {
|
||||
// do the migration
|
||||
static async up(db: PrismaService) {
|
||||
static async up(db: PrismaClient) {
|
||||
// add early access v2 & copilot feature
|
||||
for (const feature of Features) {
|
||||
await upsertFeature(db, feature);
|
||||
@@ -12,5 +13,5 @@ export class RefreshUserFeatures1704352562369 {
|
||||
}
|
||||
|
||||
// revert the migration
|
||||
static async down(_db: PrismaService) {}
|
||||
static async down(_db: PrismaClient) {}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { Prisma, PrismaClient } from '@prisma/client';
|
||||
|
||||
import {
|
||||
CommonFeature,
|
||||
FeatureKind,
|
||||
FeatureType,
|
||||
} from '../../../modules/features';
|
||||
import { PrismaService } from '../../../prisma';
|
||||
|
||||
// upgrade features from lower version to higher version
|
||||
export async function upsertFeature(
|
||||
db: PrismaService,
|
||||
db: PrismaClient,
|
||||
feature: CommonFeature
|
||||
): Promise<void> {
|
||||
const hasEqualOrGreaterVersion =
|
||||
@@ -34,7 +33,7 @@ export async function upsertFeature(
|
||||
}
|
||||
}
|
||||
|
||||
export async function migrateNewFeatureTable(prisma: PrismaService) {
|
||||
export async function migrateNewFeatureTable(prisma: PrismaClient) {
|
||||
const waitingList = await prisma.newFeaturesWaitingList.findMany();
|
||||
for (const oldUser of waitingList) {
|
||||
const user = await prisma.user.findFirst({
|
||||
|
||||
Reference in New Issue
Block a user