Remove DataSourceService and clean up datasource migration logic (#19532)
## Summary - **Drop the `objectMetadata.dataSourceId` foreign key and index** via a 1-22 fast instance command — column kept nullable for data preservation - **Delete `DataSourceService`, `DataSourceModule`, and `DataSourceException`** — all code now uses `workspace.databaseSchema` directly - **Remove `IS_DATASOURCE_MIGRATED` feature flag** from default flags and all branching logic - **Simplify workspace/object creation pipelines** — `WorkspaceManagerService`, `DevSeederService`, and the object creation action handler no longer route through `DataSourceService` - **Keep `DataSourceEntity` and the `dataSource` table** for historical data — entity stripped of all ORM relations
This commit is contained in:
+1
-8
@@ -2,19 +2,12 @@ import { Module } from '@nestjs/common';
|
||||
import { TypeOrmModule } from '@nestjs/typeorm';
|
||||
|
||||
import { TypeORMModule } from 'src/database/typeorm/typeorm.module';
|
||||
import { FeatureFlagModule } from 'src/engine/core-modules/feature-flag/feature-flag.module';
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { DataSourceModule } from 'src/engine/metadata-modules/data-source/data-source.module';
|
||||
|
||||
import { WorkspaceDataSourceService } from './workspace-datasource.service';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
TypeOrmModule.forFeature([WorkspaceEntity]),
|
||||
TypeORMModule,
|
||||
FeatureFlagModule,
|
||||
DataSourceModule,
|
||||
],
|
||||
imports: [TypeOrmModule.forFeature([WorkspaceEntity]), TypeORMModule],
|
||||
exports: [WorkspaceDataSourceService],
|
||||
providers: [WorkspaceDataSourceService],
|
||||
})
|
||||
|
||||
+5
-24
@@ -3,13 +3,10 @@ import { InjectDataSource, InjectRepository } from '@nestjs/typeorm';
|
||||
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
import { FeatureFlagKey } from 'twenty-shared/types';
|
||||
import { type DataSource, type EntityManager, Repository } from 'typeorm';
|
||||
|
||||
import { FeatureFlagService } from 'src/engine/core-modules/feature-flag/services/feature-flag.service';
|
||||
import { TwentyConfigService } from 'src/engine/core-modules/twenty-config/twenty-config.service';
|
||||
import { WorkspaceEntity } from 'src/engine/core-modules/workspace/workspace.entity';
|
||||
import { DataSourceService } from 'src/engine/metadata-modules/data-source/data-source.service';
|
||||
import {
|
||||
PermissionsException,
|
||||
PermissionsExceptionCode,
|
||||
@@ -27,8 +24,6 @@ export class WorkspaceDataSourceService {
|
||||
private readonly workspaceRepository: Repository<WorkspaceEntity>,
|
||||
@InjectDataSource()
|
||||
private readonly coreDataSource: DataSource,
|
||||
private readonly featureFlagService: FeatureFlagService,
|
||||
private readonly dataSourceService: DataSourceService,
|
||||
private readonly twentyConfigService: TwentyConfigService,
|
||||
) {}
|
||||
|
||||
@@ -43,26 +38,12 @@ export class WorkspaceDataSourceService {
|
||||
}
|
||||
|
||||
public async checkSchemaExists(workspaceId: string) {
|
||||
const isDataSourceMigrated = await this.featureFlagService.isFeatureEnabled(
|
||||
FeatureFlagKey.IS_DATASOURCE_MIGRATED,
|
||||
workspaceId,
|
||||
);
|
||||
const workspace = await this.workspaceRepository.findOne({
|
||||
select: ['databaseSchema'],
|
||||
where: { id: workspaceId },
|
||||
});
|
||||
|
||||
if (isDataSourceMigrated) {
|
||||
const workspace = await this.workspaceRepository.findOne({
|
||||
select: ['databaseSchema'],
|
||||
where: { id: workspaceId },
|
||||
});
|
||||
|
||||
return isNonEmptyString(workspace?.databaseSchema);
|
||||
}
|
||||
|
||||
const dataSources =
|
||||
await this.dataSourceService.getDataSourcesMetadataFromWorkspaceId(
|
||||
workspaceId,
|
||||
);
|
||||
|
||||
return dataSources.length > 0;
|
||||
return isNonEmptyString(workspace?.databaseSchema);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user