mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-02 14:49:44 +08:00
e516e0db23
- [x] separates modules into `fundamental`, `core`, `plugins`
- [x] optional modules with `@OptionalModule` decorator to install modules with requirements met(`requires`, `if`)
- [x] `module.contributesTo` defines optional features that will be enabled if module registered
- [x] `AFFiNE.plugins.use('payment', {})` to enable a optional/plugin module
- [x] `PaymentModule` is the first plugin module
- [x] GraphQLSchema will not be generated for non-included modules
- [x] Frontend can use `ServerConfigType` query to detect which features are enabled
- [x] override existing provider globally
39 lines
986 B
TypeScript
39 lines
986 B
TypeScript
import { ModuleRef } from '@nestjs/core';
|
|
import { PrismaClient } from '@prisma/client';
|
|
|
|
import { WorkspaceBlobStorage } from '../../core/storage';
|
|
|
|
export class WorkspaceBlobs1703828796699 {
|
|
// do the migration
|
|
static async up(db: PrismaClient, injector: ModuleRef) {
|
|
const blobStorage = injector.get(WorkspaceBlobStorage, { strict: false });
|
|
let hasMore = true;
|
|
let turn = 0;
|
|
const eachTurnCount = 50;
|
|
|
|
while (hasMore) {
|
|
const blobs = await db.blob.findMany({
|
|
skip: turn * eachTurnCount,
|
|
take: eachTurnCount,
|
|
orderBy: {
|
|
createdAt: 'asc',
|
|
},
|
|
});
|
|
|
|
hasMore = blobs.length === eachTurnCount;
|
|
turn += 1;
|
|
|
|
await Promise.all(
|
|
blobs.map(async ({ workspaceId, hash, blob }) =>
|
|
blobStorage.put(workspaceId, hash, blob)
|
|
)
|
|
);
|
|
}
|
|
}
|
|
|
|
// revert the migration
|
|
static async down(_db: PrismaClient) {
|
|
// old data kept, no need to downgrade the migration
|
|
}
|
|
}
|