feat: migration can be applied on a specific schema & some enhancements (#2998)
* fix: remove old metadata seed files * feat: wip standard to core relation * fix: lint * fix: merge * fix: remove debug files * feat: add feature flag for core object metadata * fix: remove debug * feat: always disable the standard core relation * fix: missing feature flag * fix: remove debug * fix: feature flag doesn't seems to disable relation * fix: delete .vscode folder, change this in another PR * Update packages/twenty-server/src/workspace/workspace-sync-metadata/reflective-metadata.factory.ts Co-authored-by: Weiko <corentin@twenty.com> * Update packages/twenty-server/src/workspace/workspace-sync-metadata/reflective-metadata.factory.ts Co-authored-by: Weiko <corentin@twenty.com> * Update packages/twenty-server/src/workspace/workspace-sync-metadata/workspace-sync.metadata.service.ts Co-authored-by: Weiko <corentin@twenty.com> * fix: remove optional fields from metadata entities * fix: renamed variable * fix: put back CursorScalarType * fix: delete test command * fix: remove unused workspace standard migration command * fix: drop core object metadata declaration * fix: rename variable * fix: drop creation of core datasource * fix: remove feature flag * fix: drop support of standard to core relations * feat: add user email field on workspace-member standard object * fix: update seed accordingly * fix: missing remove command file * fix: datasource label should remain nullable * fix: better asserts * Remove unused code * Remove unused code --------- Co-authored-by: Weiko <corentin@twenty.com> Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
@ -10,13 +10,16 @@ import {
|
||||
|
||||
import { ObjectMetadataEntity } from 'src/metadata/object-metadata/object-metadata.entity';
|
||||
|
||||
type DataSourceType = DataSourceOptions['type'];
|
||||
export type DataSourceType = DataSourceOptions['type'];
|
||||
|
||||
@Entity('dataSource')
|
||||
export class DataSourceEntity {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
label: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
url: string;
|
||||
|
||||
@ -26,9 +29,6 @@ export class DataSourceEntity {
|
||||
@Column({ type: 'enum', enum: ['postgres'], default: 'postgres' })
|
||||
type: DataSourceType;
|
||||
|
||||
@Column({ nullable: true, name: 'label' })
|
||||
label: string;
|
||||
|
||||
@Column({ default: false })
|
||||
isRemote: boolean;
|
||||
|
||||
|
||||
@ -94,6 +94,7 @@ export class FieldMetadataService extends TypeOrmQueryService<FieldMetadataEntit
|
||||
{
|
||||
name: objectMetadata.targetTableName,
|
||||
action: 'alter',
|
||||
schemaName: objectMetadata.dataSource.schema,
|
||||
columns: this.workspaceMigrationFactory.createColumnActions(
|
||||
WorkspaceMigrationColumnActionType.CREATE,
|
||||
createdFieldMetadata,
|
||||
@ -204,6 +205,7 @@ export class FieldMetadataService extends TypeOrmQueryService<FieldMetadataEntit
|
||||
{
|
||||
name: objectMetadata.targetTableName,
|
||||
action: 'alter',
|
||||
schemaName: objectMetadata.dataSource.schema,
|
||||
columns: this.workspaceMigrationFactory.createColumnActions(
|
||||
WorkspaceMigrationColumnActionType.ALTER,
|
||||
existingFieldMetadata,
|
||||
|
||||
@ -230,11 +230,13 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
|
||||
{
|
||||
name: createdObjectMetadata.targetTableName,
|
||||
action: 'create',
|
||||
schemaName: createdObjectMetadata.dataSource.schema,
|
||||
} satisfies WorkspaceMigrationTableAction,
|
||||
// Add activity target relation
|
||||
{
|
||||
name: activityTargetObjectMetadata.targetTableName,
|
||||
action: 'alter',
|
||||
schemaName: activityTargetObjectMetadata.dataSource.schema,
|
||||
columns: [
|
||||
{
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
@ -247,6 +249,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
|
||||
{
|
||||
name: activityTargetObjectMetadata.targetTableName,
|
||||
action: 'alter',
|
||||
schemaName: activityTargetObjectMetadata.dataSource.schema,
|
||||
columns: [
|
||||
{
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
@ -260,6 +263,7 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
|
||||
{
|
||||
name: createdObjectMetadata.targetTableName,
|
||||
action: 'alter',
|
||||
schemaName: createdObjectMetadata.dataSource.schema,
|
||||
columns: [
|
||||
{
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
@ -313,16 +317,16 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
|
||||
options: FindOneOptions<ObjectMetadataEntity>,
|
||||
): Promise<ObjectMetadataEntity | null> {
|
||||
return this.objectMetadataRepository.findOne({
|
||||
...options,
|
||||
where: {
|
||||
...options.where,
|
||||
workspaceId,
|
||||
},
|
||||
relations: [
|
||||
'fields',
|
||||
'fields.fromRelationMetadata',
|
||||
'fields.toRelationMetadata',
|
||||
],
|
||||
...options,
|
||||
where: {
|
||||
...options.where,
|
||||
workspaceId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@ -331,17 +335,17 @@ export class ObjectMetadataService extends TypeOrmQueryService<ObjectMetadataEnt
|
||||
options?: FindManyOptions<ObjectMetadataEntity>,
|
||||
) {
|
||||
return this.objectMetadataRepository.find({
|
||||
...options,
|
||||
where: {
|
||||
...options?.where,
|
||||
workspaceId,
|
||||
},
|
||||
relations: [
|
||||
'fields',
|
||||
'fields.fromRelationMetadata',
|
||||
'fields.toRelationMetadata',
|
||||
'fields.fromRelationMetadata.toObjectMetadata',
|
||||
],
|
||||
...options,
|
||||
where: {
|
||||
...options?.where,
|
||||
workspaceId,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -200,6 +200,9 @@ export class RelationMetadataService extends TypeOrmQueryService<RelationMetadat
|
||||
name: objectMetadataMap[relationMetadataInput.toObjectMetadataId]
|
||||
.targetTableName,
|
||||
action: 'alter',
|
||||
schemaName:
|
||||
objectMetadataMap[relationMetadataInput.toObjectMetadataId]
|
||||
.dataSource.schema,
|
||||
columns: [
|
||||
{
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
@ -214,6 +217,9 @@ export class RelationMetadataService extends TypeOrmQueryService<RelationMetadat
|
||||
name: objectMetadataMap[relationMetadataInput.toObjectMetadataId]
|
||||
.targetTableName,
|
||||
action: 'alter',
|
||||
schemaName:
|
||||
objectMetadataMap[relationMetadataInput.toObjectMetadataId]
|
||||
.dataSource.schema,
|
||||
columns: [
|
||||
{
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
|
||||
@ -1,84 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addCompanyTable: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'company',
|
||||
action: 'create',
|
||||
},
|
||||
{
|
||||
name: 'company',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'name',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'domainName',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'address',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'employees',
|
||||
columnType: 'integer',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'linkedinLinkUrl',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'linkedinLinkLabel',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'xLinkUrl',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'xLinkLabel',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'annualRecurringRevenueAmountMicros',
|
||||
columnType: 'numeric',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'annualRecurringRevenueCurrencyCode',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'idealCustomerProfile',
|
||||
columnType: 'boolean',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'accountOwnerId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,34 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addViewTable: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'view',
|
||||
action: 'create',
|
||||
},
|
||||
{
|
||||
name: 'view',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'name',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'objectMetadataId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'type',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "'table'",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,51 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addViewFieldTable: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'viewField',
|
||||
action: 'create',
|
||||
},
|
||||
{
|
||||
name: 'viewField',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'fieldMetadataId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'position',
|
||||
columnType: 'float',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
columnName: 'isVisible',
|
||||
columnType: 'boolean',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: true,
|
||||
},
|
||||
{
|
||||
columnName: 'size',
|
||||
columnType: 'integer',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
columnName: 'viewId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'viewId',
|
||||
referencedTableName: 'view',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,51 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addViewFilterTable: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'viewFilter',
|
||||
action: 'create',
|
||||
},
|
||||
{
|
||||
name: 'viewFilter',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'fieldMetadataId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'operand',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "'Contains'",
|
||||
},
|
||||
{
|
||||
columnName: 'value',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'displayValue',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'viewId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'viewId',
|
||||
referencedTableName: 'view',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,39 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addViewSortTable: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'viewSort',
|
||||
action: 'create',
|
||||
},
|
||||
{
|
||||
name: 'viewSort',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'fieldMetadataId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'direction',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "'asc'",
|
||||
},
|
||||
{
|
||||
columnName: 'viewId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'viewId',
|
||||
referencedTableName: 'view',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,32 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addActivityTargetTable: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'activityTarget',
|
||||
action: 'create',
|
||||
},
|
||||
{
|
||||
name: 'activityTarget',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'companyId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'activityId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'personId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,60 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addActivityTable: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'activity',
|
||||
action: 'create',
|
||||
},
|
||||
{
|
||||
name: 'activity',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'title',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'body',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "'{}'",
|
||||
},
|
||||
{
|
||||
columnName: 'type',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "'Note'",
|
||||
},
|
||||
{
|
||||
columnName: 'reminderAt',
|
||||
columnType: 'timestamp',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'dueAt',
|
||||
columnType: 'timestamp',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'completedAt',
|
||||
columnType: 'timestamp',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'authorId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'assigneeId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,33 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addApiKeyTable: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'apiKey',
|
||||
action: 'create',
|
||||
},
|
||||
{
|
||||
name: 'apiKey',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'name',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'revokedAt',
|
||||
columnType: 'timestamp',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'expiresAt',
|
||||
columnType: 'timestamp',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,55 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addAttachmentTable: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'attachment',
|
||||
action: 'create',
|
||||
},
|
||||
{
|
||||
name: 'attachment',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'name',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'fullPath',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'type',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'companyId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'authorId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'activityId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'personId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,33 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addCommentTable: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'comment',
|
||||
action: 'create',
|
||||
},
|
||||
{
|
||||
name: 'comment',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'body',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'authorId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'activityId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,38 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addFavoriteTable: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'favorite',
|
||||
action: 'create',
|
||||
},
|
||||
{
|
||||
name: 'favorite',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'position',
|
||||
columnType: 'float',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: 0,
|
||||
},
|
||||
{
|
||||
columnName: 'companyId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'personId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'workspaceMemberId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,58 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addOpportunityTable: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'opportunity',
|
||||
action: 'create',
|
||||
},
|
||||
{
|
||||
name: 'opportunity',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'amountAmountMicros',
|
||||
columnType: 'numeric',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'amountCurrencyCode',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'probability',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "'0'",
|
||||
},
|
||||
{
|
||||
columnName: 'closeDate',
|
||||
columnType: 'timestamp',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'companyId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'personId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'pipelineStepId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'pointOfContactId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,88 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addPersonTable: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'person',
|
||||
action: 'create',
|
||||
},
|
||||
{
|
||||
name: 'person',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'nameFirstName',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'nameLastName',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'email',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'linkedinLinkUrl',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'linkedinLinkLabel',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'xLinkUrl',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'xLinkLabel',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'jobTitle',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'phone',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'city',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'avatarUrl',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'companyId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,35 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addPipelineStepTable: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'pipelineStep',
|
||||
action: 'create',
|
||||
},
|
||||
{
|
||||
name: 'pipelineStep',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'name',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'color',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'position',
|
||||
columnType: 'float',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,29 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addWebhookTable: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'webhook',
|
||||
action: 'create',
|
||||
},
|
||||
{
|
||||
name: 'webhook',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'targetUrl',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'operation',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,51 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addWorkspaceMemberTable: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'workspaceMember',
|
||||
action: 'create',
|
||||
},
|
||||
{
|
||||
name: 'workspaceMember',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'nameFirstName',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'nameLastName',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'avatarUrl',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
columnName: 'colorScheme',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "'Light'",
|
||||
},
|
||||
{
|
||||
columnName: 'locale',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "'en'",
|
||||
},
|
||||
{
|
||||
columnName: 'userId',
|
||||
columnType: 'uuid',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,19 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addCompanyRelations: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'company',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'accountOwnerId',
|
||||
referencedTableName: 'workspaceMember',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,37 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addAttachmentRelations: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'attachment',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'companyId',
|
||||
referencedTableName: 'company',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
{
|
||||
columnName: 'personId',
|
||||
referencedTableName: 'person',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
{
|
||||
columnName: 'activityId',
|
||||
referencedTableName: 'activity',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
{
|
||||
columnName: 'authorId',
|
||||
referencedTableName: 'workspaceMember',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,19 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addPersonRelations: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'person',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'companyId',
|
||||
referencedTableName: 'company',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,31 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addFavoriteRelations: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'favorite',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'companyId',
|
||||
referencedTableName: 'company',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
{
|
||||
columnName: 'personId',
|
||||
referencedTableName: 'person',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
{
|
||||
columnName: 'workspaceMemberId',
|
||||
referencedTableName: 'workspaceMember',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,37 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addOpportunityRelations: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'opportunity',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'companyId',
|
||||
referencedTableName: 'company',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
{
|
||||
columnName: 'personId',
|
||||
referencedTableName: 'person',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
{
|
||||
columnName: 'pointOfContactId',
|
||||
referencedTableName: 'person',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
{
|
||||
columnName: 'pipelineStepId',
|
||||
referencedTableName: 'pipelineStep',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,31 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addActivityTargetRelations: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'activityTarget',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'companyId',
|
||||
referencedTableName: 'company',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
{
|
||||
columnName: 'personId',
|
||||
referencedTableName: 'person',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
{
|
||||
columnName: 'activityId',
|
||||
referencedTableName: 'activity',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,25 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addActivityRelations: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'activity',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'authorId',
|
||||
referencedTableName: 'workspaceMember',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
{
|
||||
columnName: 'assigneeId',
|
||||
referencedTableName: 'workspaceMember',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,25 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addCommentRelations: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'comment',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'authorId',
|
||||
referencedTableName: 'workspaceMember',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
{
|
||||
columnName: 'activityId',
|
||||
referencedTableName: 'activity',
|
||||
referencedTableColumnName: 'id',
|
||||
action: WorkspaceMigrationColumnActionType.RELATION,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,47 +0,0 @@
|
||||
import {
|
||||
WorkspaceMigrationColumnActionType,
|
||||
WorkspaceMigrationTableAction,
|
||||
} from 'src/metadata/workspace-migration/workspace-migration.entity';
|
||||
|
||||
export const addConnectedAccount: WorkspaceMigrationTableAction[] = [
|
||||
{
|
||||
name: 'connectedAccount',
|
||||
action: 'create',
|
||||
},
|
||||
{
|
||||
name: 'connectedAccount',
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
columnName: 'type',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'accessToken',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'refreshToken',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'externalScopes',
|
||||
columnType: 'varchar',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: "''",
|
||||
},
|
||||
{
|
||||
columnName: 'hasEmailScope',
|
||||
columnType: 'boolean',
|
||||
action: WorkspaceMigrationColumnActionType.CREATE,
|
||||
defaultValue: 'false',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@ -1,56 +0,0 @@
|
||||
import { addActivityTargetTable } from 'src/metadata/workspace-migration/migrations/1697618015-addActivityTargetTable';
|
||||
import { addActivityTable } from 'src/metadata/workspace-migration/migrations/1697618016-addActivityTable';
|
||||
import { addApiKeyTable } from 'src/metadata/workspace-migration/migrations/1697618017-addApiKeyTable';
|
||||
import { addAttachmentTable } from 'src/metadata/workspace-migration/migrations/1697618018-addAttachmentTable';
|
||||
import { addCommentTable } from 'src/metadata/workspace-migration/migrations/1697618019-addCommentTable';
|
||||
import { addFavoriteTable } from 'src/metadata/workspace-migration/migrations/1697618020-addFavoriteTable';
|
||||
import { addOpportunityTable } from 'src/metadata/workspace-migration/migrations/1697618021-addOpportunityTable';
|
||||
import { addPersonTable } from 'src/metadata/workspace-migration/migrations/1697618022-addPersonTable';
|
||||
import { addPipelineStepTable } from 'src/metadata/workspace-migration/migrations/1697618023-addPipelineStepTable';
|
||||
import { addWebhookTable } from 'src/metadata/workspace-migration/migrations/1697618024-addWebhookTable';
|
||||
import { addWorkspaceMemberTable } from 'src/metadata/workspace-migration/migrations/1697618026-addWorspaceMemberTable';
|
||||
import { addCompanyRelations } from 'src/metadata/workspace-migration/migrations/1697618027-addCompanyRelations';
|
||||
import { addAttachmentRelations } from 'src/metadata/workspace-migration/migrations/1697618028-addAttachmentRelations';
|
||||
import { addPersonRelations } from 'src/metadata/workspace-migration/migrations/1697618029-addPersonRelations';
|
||||
import { addFavoriteRelations } from 'src/metadata/workspace-migration/migrations/1697618030-addFavoriteRelations';
|
||||
import { addActivityTargetRelations } from 'src/metadata/workspace-migration/migrations/1697618032-addActivityTargetRelations';
|
||||
import { addActivityRelations } from 'src/metadata/workspace-migration/migrations/1697618033-addActivityRelations';
|
||||
import { addCommentRelations } from 'src/metadata/workspace-migration/migrations/1697618034-addCommentRelations';
|
||||
import { addOpportunityRelations } from 'src/metadata/workspace-migration/migrations/1697618031-addOpportunityRelations';
|
||||
import { addConnectedAccount } from 'src/metadata/workspace-migration/migrations/1697618035-addConnectedAccount';
|
||||
|
||||
import { addCompanyTable } from './migrations/1697618009-addCompanyTable';
|
||||
import { addViewTable } from './migrations/1697618011-addViewTable';
|
||||
import { addViewFieldTable } from './migrations/1697618012-addViewFieldTable';
|
||||
import { addViewFilterTable } from './migrations/1697618013-addViewFilterTable';
|
||||
import { addViewSortTable } from './migrations/1697618014-addViewSortTable';
|
||||
|
||||
// TODO: read the folder and return all migrations
|
||||
export const standardMigrations = {
|
||||
'1697618009-addCompanyTable': addCompanyTable,
|
||||
'1697618011-addViewTable': addViewTable,
|
||||
'1697618012-addViewFieldTable': addViewFieldTable,
|
||||
'1697618013-addViewFilterTable': addViewFilterTable,
|
||||
'1697618014-addViewSortTable': addViewSortTable,
|
||||
|
||||
'1697618015-addActivityTargetTable': addActivityTargetTable,
|
||||
'1697618016-addActivityTable': addActivityTable,
|
||||
'1697618017-addApiKeyTable': addApiKeyTable,
|
||||
'1697618018-addAttachmentTable': addAttachmentTable,
|
||||
'1697618019-addCommentTable': addCommentTable,
|
||||
'1697618020-addFavoriteTable': addFavoriteTable,
|
||||
'1697618021-addOpportunityTable': addOpportunityTable,
|
||||
'1697618022-addPersonTable': addPersonTable,
|
||||
'1697618023-addPipelineStepTable': addPipelineStepTable,
|
||||
'1697618024-addWebhookTable': addWebhookTable,
|
||||
'1697618026-addWorkspaceMemberTable': addWorkspaceMemberTable,
|
||||
'1697618027-addCompanyRelations': addCompanyRelations,
|
||||
'1697618028-addAttachmentRelations': addAttachmentRelations,
|
||||
'1697618029-addPersonRelations': addPersonRelations,
|
||||
'1697618030-addFavoriteRelations': addFavoriteRelations,
|
||||
'1697618031-addOpportunitiesRelations': addOpportunityRelations,
|
||||
'1697618032-addActivityTargetRelations': addActivityTargetRelations,
|
||||
'1697618033-addActivityRelations': addActivityRelations,
|
||||
'1697618034-addCommentRelations': addCommentRelations,
|
||||
'1697618035-addConnectedAccount': addConnectedAccount,
|
||||
};
|
||||
@ -39,6 +39,7 @@ export type WorkspaceMigrationColumnRelation = {
|
||||
columnName: string;
|
||||
referencedTableName: string;
|
||||
referencedTableColumnName: string;
|
||||
referencedSchema?: string;
|
||||
isUnique?: boolean;
|
||||
};
|
||||
|
||||
@ -59,6 +60,7 @@ export type WorkspaceMigrationColumnAction = {
|
||||
export type WorkspaceMigrationTableAction = {
|
||||
name: string;
|
||||
action: 'create' | 'alter';
|
||||
schemaName: string;
|
||||
columns?: WorkspaceMigrationColumnAction[];
|
||||
};
|
||||
|
||||
|
||||
@ -3,7 +3,6 @@ import { InjectRepository } from '@nestjs/typeorm';
|
||||
|
||||
import { IsNull, Repository } from 'typeorm';
|
||||
|
||||
import { standardMigrations } from './standard-migrations';
|
||||
import {
|
||||
WorkspaceMigrationEntity,
|
||||
WorkspaceMigrationTableAction,
|
||||
@ -16,43 +15,6 @@ export class WorkspaceMigrationService {
|
||||
private readonly workspaceMigrationRepository: Repository<WorkspaceMigrationEntity>,
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Insert all standard migrations that have not been inserted yet
|
||||
*
|
||||
* @param workspaceId
|
||||
*/
|
||||
public async insertStandardMigrations(workspaceId: string): Promise<void> {
|
||||
// TODO: we actually don't need to fetch all of them, to improve later so it scales well.
|
||||
const insertedStandardMigrations =
|
||||
await this.workspaceMigrationRepository.find({
|
||||
where: { workspaceId, isCustom: false },
|
||||
});
|
||||
|
||||
const insertedStandardMigrationsMapByName =
|
||||
insertedStandardMigrations.reduce((acc, migration) => {
|
||||
acc[migration.name] = migration;
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
const standardMigrationsListThatNeedToBeInserted = Object.entries(
|
||||
standardMigrations,
|
||||
)
|
||||
.filter(([name]) => !insertedStandardMigrationsMapByName[name])
|
||||
.map(([name, migrations]) => ({ name, migrations }));
|
||||
|
||||
const standardMigrationsThatNeedToBeInserted =
|
||||
standardMigrationsListThatNeedToBeInserted.map((migration) => ({
|
||||
...migration,
|
||||
workspaceId,
|
||||
isCustom: false,
|
||||
}));
|
||||
|
||||
await this.workspaceMigrationRepository.save(
|
||||
standardMigrationsThatNeedToBeInserted,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all pending migrations for a given workspaceId
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user