Clean metadata and schema (#2382)

This commit is contained in:
martmull
2023-11-07 12:33:54 +01:00
committed by GitHub
parent 7aa6b20418
commit 0ae56b055c
6 changed files with 39 additions and 0 deletions
@@ -121,6 +121,20 @@ export class DataSourceService implements OnModuleInit, OnModuleDestroy {
return `workspace_${uuidToBase36(workspaceId)}`;
}
public async deleteWorkspaceSchema(workspaceId: string) {
const schemaName = this.getSchemaName(workspaceId);
const queryRunner = this.mainDataSource.createQueryRunner();
const schemaAlreadyExists = await queryRunner.hasSchema(schemaName);
if (!schemaAlreadyExists) {
throw new Error(`Schema ${schemaName} does not exist`);
}
await queryRunner.dropSchema(schemaName, true, true);
await queryRunner.release();
}
async onModuleInit() {
// Init main data source "default" schema
await this.mainDataSource.initialize();