d021f7e369
- Fixes self host application - add new telemetry information - add serverId to identify a server instance - remove .twenty from git tracking - tree-shake "twenty-sdk" usage in built logic functions and front components - fix "twenty-sdk" version usage - fix twenty-zapier cli --------- Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
47 lines
1.7 KiB
TypeScript
47 lines
1.7 KiB
TypeScript
import { InjectDataSource, InjectRepository } from '@nestjs/typeorm';
|
|
|
|
import { Command } from 'nest-commander';
|
|
import { DataSource, Repository } from 'typeorm';
|
|
|
|
import { ActiveOrSuspendedWorkspacesMigrationCommandRunner } from 'src/database/commands/command-runners/active-or-suspended-workspaces-migration.command-runner';
|
|
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
|
import { DataSourceService } from 'src/engine/metadata-modules/data-source/data-source.service';
|
|
import { GlobalWorkspaceOrmManager } from 'src/engine/twenty-orm/global-workspace-datasource/global-workspace-orm.manager';
|
|
import { seedServerId } from 'src/engine/workspace-manager/dev-seeder/core/utils/seed-server-id.util';
|
|
|
|
@Command({
|
|
name: 'upgrade:1-19:seed-server-id',
|
|
description:
|
|
'Seed a unique SERVER_ID (UUID v4) into the keyValuePair table as a CONFIG_VARIABLE',
|
|
})
|
|
export class SeedServerIdCommand extends ActiveOrSuspendedWorkspacesMigrationCommandRunner {
|
|
private hasRun = false;
|
|
|
|
constructor(
|
|
@InjectRepository(WorkspaceEntity)
|
|
protected readonly workspaceRepository: Repository<WorkspaceEntity>,
|
|
@InjectDataSource()
|
|
private readonly coreDataSource: DataSource,
|
|
protected readonly twentyORMGlobalManager: GlobalWorkspaceOrmManager,
|
|
protected readonly dataSourceService: DataSourceService,
|
|
) {
|
|
super(workspaceRepository, twentyORMGlobalManager, dataSourceService);
|
|
}
|
|
|
|
override async runOnWorkspace(): Promise<void> {
|
|
if (this.hasRun) {
|
|
return;
|
|
}
|
|
|
|
const queryRunner = this.coreDataSource.createQueryRunner();
|
|
|
|
await seedServerId({ queryRunner, schemaName: 'core' });
|
|
|
|
this.hasRun = true;
|
|
|
|
await queryRunner.release();
|
|
|
|
this.logger.log(`SERVER_ID seeded successfully`);
|
|
}
|
|
}
|