Add relation metadata seed (#2431)
* Add relation metadata seed * Fix * Add filtering by relation id on server * Fix
This commit is contained in:
@ -9,9 +9,14 @@ import { TenantMigrationRunnerService } from 'src/tenant-migration-runner/tenant
|
||||
import { seedCompanies } from 'src/database/typeorm-seeds/tenant/companies';
|
||||
import { seedViewFields } from 'src/database/typeorm-seeds/tenant/view-fields';
|
||||
import { seedViews } from 'src/database/typeorm-seeds/tenant/views';
|
||||
import { seedFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata';
|
||||
import { seedObjectMetadata } from 'src/database/typeorm-seeds/metadata/object-metadata';
|
||||
import { TypeORMService } from 'src/database/typeorm/typeorm.service';
|
||||
import { seedCompanyFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/company';
|
||||
import { seedViewFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/view';
|
||||
import { seedViewFieldFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/viewField';
|
||||
import { seedViewFilterFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/viewFilter';
|
||||
import { seedViewSortFieldMetadata } from 'src/database/typeorm-seeds/metadata/field-metadata/viewSort';
|
||||
import { seedViewRelationMetadata } from 'src/database/typeorm-seeds/metadata/relation-metadata/view';
|
||||
|
||||
// TODO: implement dry-run
|
||||
@Command({
|
||||
@ -47,19 +52,30 @@ export class DataSeedTenantCommand extends CommandRunner {
|
||||
throw new Error('Could not connect to workspace data source');
|
||||
}
|
||||
|
||||
await seedObjectMetadata(this.metadataDataSource, 'metadata');
|
||||
await seedFieldMetadata(this.metadataDataSource, 'metadata');
|
||||
try {
|
||||
await seedObjectMetadata(this.metadataDataSource, 'metadata');
|
||||
|
||||
await this.tenantMigrationService.insertStandardMigrations(
|
||||
this.workspaceId,
|
||||
);
|
||||
await this.migrationRunnerService.executeMigrationFromPendingMigrations(
|
||||
this.workspaceId,
|
||||
);
|
||||
await seedCompanyFieldMetadata(this.metadataDataSource, 'metadata');
|
||||
await seedViewFieldMetadata(this.metadataDataSource, 'metadata');
|
||||
await seedViewFieldFieldMetadata(this.metadataDataSource, 'metadata');
|
||||
await seedViewSortFieldMetadata(this.metadataDataSource, 'metadata');
|
||||
await seedViewFilterFieldMetadata(this.metadataDataSource, 'metadata');
|
||||
|
||||
await seedCompanies(workspaceDataSource, dataSourceMetadata.schema);
|
||||
await seedViewFields(workspaceDataSource, dataSourceMetadata.schema);
|
||||
await seedViews(workspaceDataSource, dataSourceMetadata.schema);
|
||||
await seedViewRelationMetadata(this.metadataDataSource, 'metadata');
|
||||
|
||||
await this.tenantMigrationService.insertStandardMigrations(
|
||||
this.workspaceId,
|
||||
);
|
||||
await this.migrationRunnerService.executeMigrationFromPendingMigrations(
|
||||
this.workspaceId,
|
||||
);
|
||||
|
||||
await seedCompanies(workspaceDataSource, dataSourceMetadata.schema);
|
||||
await seedViews(workspaceDataSource, dataSourceMetadata.schema);
|
||||
await seedViewFields(workspaceDataSource, dataSourceMetadata.schema);
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
|
||||
await this.typeORMService.disconnectFromDataSource(dataSourceMetadata.id);
|
||||
}
|
||||
|
||||
@ -1,334 +0,0 @@
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
const tableName = 'fieldMetadata';
|
||||
|
||||
export const seedFieldMetadata = async (
|
||||
workspaceDataSource: DataSource,
|
||||
schemaName: string,
|
||||
) => {
|
||||
await workspaceDataSource
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(`${schemaName}.${tableName}`, [
|
||||
'objectMetadataId',
|
||||
'isCustom',
|
||||
'workspaceId',
|
||||
'isActive',
|
||||
'type',
|
||||
'name',
|
||||
'label',
|
||||
'targetColumnMap',
|
||||
'description',
|
||||
'icon',
|
||||
'isNullable',
|
||||
])
|
||||
.orIgnore()
|
||||
.values([
|
||||
// Companies
|
||||
{
|
||||
objectMetadataId: '1a8487a0-480c-434e-b4c7-e22408b97047',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'name',
|
||||
label: 'Name',
|
||||
targetColumnMap: {
|
||||
value: 'name',
|
||||
},
|
||||
description: 'Name of the company',
|
||||
icon: 'IconBuildingSkyscraper',
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '1a8487a0-480c-434e-b4c7-e22408b97047',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'domainName',
|
||||
label: 'Domain Name',
|
||||
targetColumnMap: {
|
||||
value: 'domainName',
|
||||
},
|
||||
description: 'Domain name of the company',
|
||||
icon: 'IconLink',
|
||||
isNullable: true,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '1a8487a0-480c-434e-b4c7-e22408b97047',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'address',
|
||||
label: 'Address',
|
||||
targetColumnMap: {
|
||||
value: 'address',
|
||||
},
|
||||
description: 'Address of the company',
|
||||
icon: 'IconMap',
|
||||
isNullable: true,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '1a8487a0-480c-434e-b4c7-e22408b97047',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'employees',
|
||||
label: 'Employees',
|
||||
targetColumnMap: {
|
||||
value: 'employees',
|
||||
},
|
||||
description: 'Number of employees',
|
||||
icon: 'IconUsers',
|
||||
isNullable: true,
|
||||
},
|
||||
// Views
|
||||
{
|
||||
objectMetadataId: '9ab6b3dc-767f-473f-8fd0-6cdbefbf8dbe',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'name',
|
||||
label: 'Name',
|
||||
targetColumnMap: {
|
||||
value: 'name',
|
||||
},
|
||||
description: 'View name',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '9ab6b3dc-767f-473f-8fd0-6cdbefbf8dbe',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'objectMetadataId',
|
||||
label: 'Object Metadata Id',
|
||||
targetColumnMap: {
|
||||
value: 'objectMetadataId',
|
||||
},
|
||||
description: 'View target object',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '9ab6b3dc-767f-473f-8fd0-6cdbefbf8dbe',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'type',
|
||||
label: 'Type',
|
||||
targetColumnMap: {
|
||||
value: 'type',
|
||||
},
|
||||
description: 'View type',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
// View Fields
|
||||
{
|
||||
objectMetadataId: '61d9000b-485c-4c48-a22e-0d9a164f9647',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'fieldMetadataId',
|
||||
label: 'Field Metadata Id',
|
||||
targetColumnMap: {
|
||||
value: 'fieldMetadataId',
|
||||
},
|
||||
description: 'View Field target field',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '61d9000b-485c-4c48-a22e-0d9a164f9647',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'viewId',
|
||||
label: 'View Id',
|
||||
targetColumnMap: {
|
||||
value: 'viewId',
|
||||
},
|
||||
description: 'View Field related view',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '61d9000b-485c-4c48-a22e-0d9a164f9647',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'BOOLEAN',
|
||||
name: 'isVisible',
|
||||
label: 'Visible',
|
||||
targetColumnMap: {
|
||||
value: 'isVisible',
|
||||
},
|
||||
description: 'View Field visibility',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '61d9000b-485c-4c48-a22e-0d9a164f9647',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'NUMBER',
|
||||
name: 'size',
|
||||
label: 'Size',
|
||||
targetColumnMap: {
|
||||
value: 'size',
|
||||
},
|
||||
description: 'View Field size',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '61d9000b-485c-4c48-a22e-0d9a164f9647',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'NUMBER',
|
||||
name: 'position',
|
||||
label: 'Position',
|
||||
targetColumnMap: {
|
||||
value: 'position',
|
||||
},
|
||||
description: 'View Field position',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
// View Filters
|
||||
{
|
||||
objectMetadataId: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'fieldMetadataId',
|
||||
label: 'Field Metadata Id',
|
||||
targetColumnMap: {
|
||||
value: 'fieldMetadataId',
|
||||
},
|
||||
description: 'View Filter target field',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'viewId',
|
||||
label: 'View Id',
|
||||
targetColumnMap: {
|
||||
value: 'viewId',
|
||||
},
|
||||
description: 'View Filter related view',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'operand',
|
||||
label: 'Operand',
|
||||
targetColumnMap: {
|
||||
value: 'operand',
|
||||
},
|
||||
description: 'View Filter operand',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'value',
|
||||
label: 'Value',
|
||||
targetColumnMap: {
|
||||
value: 'value',
|
||||
},
|
||||
description: 'View Filter value',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'displayValue',
|
||||
label: 'Display Value',
|
||||
targetColumnMap: {
|
||||
value: 'displayValue',
|
||||
},
|
||||
description: 'View Filter Display Value',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
// View Sorts
|
||||
{
|
||||
objectMetadataId: '6f8dcd4b-cf28-41dd-b98b-d6e1f5b3a251',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'fieldMetadataId',
|
||||
label: 'Field Metadata Id',
|
||||
targetColumnMap: {
|
||||
value: 'fieldMetadataId',
|
||||
},
|
||||
description: 'View Sort target field',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '6f8dcd4b-cf28-41dd-b98b-d6e1f5b3a251',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'viewId',
|
||||
label: 'View Id',
|
||||
targetColumnMap: {
|
||||
value: 'viewId',
|
||||
},
|
||||
description: 'View Sort related view',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '6f8dcd4b-cf28-41dd-b98b-d6e1f5b3a251',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'direction',
|
||||
label: 'Direction',
|
||||
targetColumnMap: {
|
||||
value: 'direction',
|
||||
},
|
||||
description: 'View Sort direction',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
])
|
||||
.execute();
|
||||
};
|
||||
@ -0,0 +1,89 @@
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
const tableName = 'fieldMetadata';
|
||||
|
||||
export const seedCompanyFieldMetadata = async (
|
||||
workspaceDataSource: DataSource,
|
||||
schemaName: string,
|
||||
) => {
|
||||
await workspaceDataSource
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(`${schemaName}.${tableName}`, [
|
||||
'objectMetadataId',
|
||||
'isCustom',
|
||||
'workspaceId',
|
||||
'isActive',
|
||||
'type',
|
||||
'name',
|
||||
'label',
|
||||
'targetColumnMap',
|
||||
'description',
|
||||
'icon',
|
||||
'isNullable',
|
||||
])
|
||||
.orIgnore()
|
||||
.values([
|
||||
{
|
||||
objectMetadataId: '1a8487a0-480c-434e-b4c7-e22408b97047',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'name',
|
||||
label: 'Name',
|
||||
targetColumnMap: {
|
||||
value: 'name',
|
||||
},
|
||||
description: 'Name of the company',
|
||||
icon: 'IconBuildingSkyscraper',
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '1a8487a0-480c-434e-b4c7-e22408b97047',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'domainName',
|
||||
label: 'Domain Name',
|
||||
targetColumnMap: {
|
||||
value: 'domainName',
|
||||
},
|
||||
description: 'Domain name of the company',
|
||||
icon: 'IconLink',
|
||||
isNullable: true,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '1a8487a0-480c-434e-b4c7-e22408b97047',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'address',
|
||||
label: 'Address',
|
||||
targetColumnMap: {
|
||||
value: 'address',
|
||||
},
|
||||
description: 'Address of the company',
|
||||
icon: 'IconMap',
|
||||
isNullable: true,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '1a8487a0-480c-434e-b4c7-e22408b97047',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'employees',
|
||||
label: 'Employees',
|
||||
targetColumnMap: {
|
||||
value: 'employees',
|
||||
},
|
||||
description: 'Number of employees',
|
||||
icon: 'IconUsers',
|
||||
isNullable: true,
|
||||
},
|
||||
])
|
||||
.execute();
|
||||
};
|
||||
@ -0,0 +1,89 @@
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
const tableName = 'fieldMetadata';
|
||||
|
||||
export const seedViewFieldMetadata = async (
|
||||
workspaceDataSource: DataSource,
|
||||
schemaName: string,
|
||||
) => {
|
||||
await workspaceDataSource
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(`${schemaName}.${tableName}`, [
|
||||
'id',
|
||||
'objectMetadataId',
|
||||
'isCustom',
|
||||
'workspaceId',
|
||||
'isActive',
|
||||
'type',
|
||||
'name',
|
||||
'label',
|
||||
'targetColumnMap',
|
||||
'description',
|
||||
'icon',
|
||||
'isNullable',
|
||||
])
|
||||
.orIgnore()
|
||||
.values([
|
||||
{
|
||||
objectMetadataId: '9ab6b3dc-767f-473f-8fd0-6cdbefbf8dbe',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'name',
|
||||
label: 'Name',
|
||||
targetColumnMap: {
|
||||
value: 'name',
|
||||
},
|
||||
description: 'View name',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '9ab6b3dc-767f-473f-8fd0-6cdbefbf8dbe',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'objectMetadataId',
|
||||
label: 'Object Metadata Id',
|
||||
targetColumnMap: {
|
||||
value: 'objectMetadataId',
|
||||
},
|
||||
description: 'View target object',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '9ab6b3dc-767f-473f-8fd0-6cdbefbf8dbe',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'type',
|
||||
label: 'Type',
|
||||
targetColumnMap: {
|
||||
value: 'type',
|
||||
},
|
||||
description: 'View type',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
id: '064eb439-fdfa-4246-a13a-989c5bcc4d97',
|
||||
objectMetadataId: '9ab6b3dc-767f-473f-8fd0-6cdbefbf8dbe',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'RELATION',
|
||||
name: 'viewFields',
|
||||
label: 'View Fields',
|
||||
targetColumnMap: {},
|
||||
description: 'View Fields',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
])
|
||||
.execute();
|
||||
};
|
||||
@ -0,0 +1,104 @@
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
const tableName = 'fieldMetadata';
|
||||
|
||||
export const seedViewFieldFieldMetadata = async (
|
||||
workspaceDataSource: DataSource,
|
||||
schemaName: string,
|
||||
) => {
|
||||
await workspaceDataSource
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(`${schemaName}.${tableName}`, [
|
||||
'id',
|
||||
'objectMetadataId',
|
||||
'isCustom',
|
||||
'workspaceId',
|
||||
'isActive',
|
||||
'type',
|
||||
'name',
|
||||
'label',
|
||||
'targetColumnMap',
|
||||
'description',
|
||||
'icon',
|
||||
'isNullable',
|
||||
])
|
||||
.orIgnore()
|
||||
.values([
|
||||
{
|
||||
objectMetadataId: '61d9000b-485c-4c48-a22e-0d9a164f9647',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'fieldMetadataId',
|
||||
label: 'Field Metadata Id',
|
||||
targetColumnMap: {
|
||||
value: 'fieldMetadataId',
|
||||
},
|
||||
description: 'View Field target field',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
id: 'a9a56210-a154-4965-9ace-c35f6dc43ee5',
|
||||
objectMetadataId: '61d9000b-485c-4c48-a22e-0d9a164f9647',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'RELATION',
|
||||
name: 'view',
|
||||
label: 'View Id',
|
||||
targetColumnMap: { value: 'viewId' },
|
||||
description: 'View Field related view',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '61d9000b-485c-4c48-a22e-0d9a164f9647',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'BOOLEAN',
|
||||
name: 'isVisible',
|
||||
label: 'Visible',
|
||||
targetColumnMap: {
|
||||
value: 'isVisible',
|
||||
},
|
||||
description: 'View Field visibility',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '61d9000b-485c-4c48-a22e-0d9a164f9647',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'NUMBER',
|
||||
name: 'size',
|
||||
label: 'Size',
|
||||
targetColumnMap: {
|
||||
value: 'size',
|
||||
},
|
||||
description: 'View Field size',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '61d9000b-485c-4c48-a22e-0d9a164f9647',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'NUMBER',
|
||||
name: 'position',
|
||||
label: 'Position',
|
||||
targetColumnMap: {
|
||||
value: 'position',
|
||||
},
|
||||
description: 'View Field position',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
])
|
||||
.execute();
|
||||
};
|
||||
@ -0,0 +1,105 @@
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
const tableName = 'fieldMetadata';
|
||||
|
||||
export const seedViewFilterFieldMetadata = async (
|
||||
workspaceDataSource: DataSource,
|
||||
schemaName: string,
|
||||
) => {
|
||||
await workspaceDataSource
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(`${schemaName}.${tableName}`, [
|
||||
'objectMetadataId',
|
||||
'isCustom',
|
||||
'workspaceId',
|
||||
'isActive',
|
||||
'type',
|
||||
'name',
|
||||
'label',
|
||||
'targetColumnMap',
|
||||
'description',
|
||||
'icon',
|
||||
'isNullable',
|
||||
])
|
||||
.orIgnore()
|
||||
.values([
|
||||
// View Filters
|
||||
{
|
||||
objectMetadataId: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'fieldMetadataId',
|
||||
label: 'Field Metadata Id',
|
||||
targetColumnMap: {
|
||||
value: 'fieldMetadataId',
|
||||
},
|
||||
description: 'View Filter target field',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'viewId',
|
||||
label: 'View Id',
|
||||
targetColumnMap: {
|
||||
value: 'viewId',
|
||||
},
|
||||
description: 'View Filter related view',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'operand',
|
||||
label: 'Operand',
|
||||
targetColumnMap: {
|
||||
value: 'operand',
|
||||
},
|
||||
description: 'View Filter operand',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'value',
|
||||
label: 'Value',
|
||||
targetColumnMap: {
|
||||
value: 'value',
|
||||
},
|
||||
description: 'View Filter value',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'displayValue',
|
||||
label: 'Display Value',
|
||||
targetColumnMap: {
|
||||
value: 'displayValue',
|
||||
},
|
||||
description: 'View Filter Display Value',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
])
|
||||
.execute();
|
||||
};
|
||||
@ -0,0 +1,74 @@
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
const tableName = 'fieldMetadata';
|
||||
|
||||
export const seedViewSortFieldMetadata = async (
|
||||
workspaceDataSource: DataSource,
|
||||
schemaName: string,
|
||||
) => {
|
||||
await workspaceDataSource
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(`${schemaName}.${tableName}`, [
|
||||
'objectMetadataId',
|
||||
'isCustom',
|
||||
'workspaceId',
|
||||
'isActive',
|
||||
'type',
|
||||
'name',
|
||||
'label',
|
||||
'targetColumnMap',
|
||||
'description',
|
||||
'icon',
|
||||
'isNullable',
|
||||
])
|
||||
.orIgnore()
|
||||
.values([
|
||||
{
|
||||
objectMetadataId: '6f8dcd4b-cf28-41dd-b98b-d6e1f5b3a251',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'fieldMetadataId',
|
||||
label: 'Field Metadata Id',
|
||||
targetColumnMap: {
|
||||
value: 'fieldMetadataId',
|
||||
},
|
||||
description: 'View Sort target field',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '6f8dcd4b-cf28-41dd-b98b-d6e1f5b3a251',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'viewId',
|
||||
label: 'View Id',
|
||||
targetColumnMap: {
|
||||
value: 'viewId',
|
||||
},
|
||||
description: 'View Sort related view',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
{
|
||||
objectMetadataId: '6f8dcd4b-cf28-41dd-b98b-d6e1f5b3a251',
|
||||
isCustom: false,
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
type: 'TEXT',
|
||||
name: 'direction',
|
||||
label: 'Direction',
|
||||
targetColumnMap: {
|
||||
value: 'direction',
|
||||
},
|
||||
description: 'View Sort direction',
|
||||
icon: null,
|
||||
isNullable: false,
|
||||
},
|
||||
])
|
||||
.execute();
|
||||
};
|
||||
@ -24,7 +24,6 @@ export const seedObjectMetadata = async (
|
||||
])
|
||||
.orIgnore()
|
||||
.values([
|
||||
// Companies
|
||||
{
|
||||
id: '1a8487a0-480c-434e-b4c7-e22408b97047',
|
||||
nameSingular: 'companyV2',
|
||||
@ -38,7 +37,6 @@ export const seedObjectMetadata = async (
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
},
|
||||
// Views
|
||||
{
|
||||
id: '9ab6b3dc-767f-473f-8fd0-6cdbefbf8dbe',
|
||||
nameSingular: 'viewV2',
|
||||
@ -52,7 +50,6 @@ export const seedObjectMetadata = async (
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
},
|
||||
// ViewFields
|
||||
{
|
||||
id: '61d9000b-485c-4c48-a22e-0d9a164f9647',
|
||||
nameSingular: 'viewFieldV2',
|
||||
@ -66,7 +63,6 @@ export const seedObjectMetadata = async (
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
},
|
||||
// ViewFilters
|
||||
{
|
||||
id: '5d9b1ab9-4461-4e2d-bf9e-9b47e68846d3',
|
||||
nameSingular: 'viewFilterV2',
|
||||
@ -80,7 +76,6 @@ export const seedObjectMetadata = async (
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
isActive: true,
|
||||
},
|
||||
// ViewSorts
|
||||
{
|
||||
id: '6f8dcd4b-cf28-41dd-b98b-d6e1f5b3a251',
|
||||
nameSingular: 'viewSortV2',
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
import { DataSource } from 'typeorm';
|
||||
|
||||
import { RelationMetadataType } from 'src/metadata/relation-metadata/relation-metadata.entity';
|
||||
|
||||
const tableName = 'relationMetadata';
|
||||
|
||||
export const seedViewRelationMetadata = async (
|
||||
workspaceDataSource: DataSource,
|
||||
schemaName: string,
|
||||
) => {
|
||||
await workspaceDataSource
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(`${schemaName}.${tableName}`, [
|
||||
'relationType',
|
||||
'fromObjectMetadataId',
|
||||
'toObjectMetadataId',
|
||||
'fromFieldMetadataId',
|
||||
'toFieldMetadataId',
|
||||
'workspaceId',
|
||||
])
|
||||
.orIgnore()
|
||||
.values([
|
||||
{
|
||||
relationType: RelationMetadataType.ONE_TO_MANY,
|
||||
fromObjectMetadataId: '9ab6b3dc-767f-473f-8fd0-6cdbefbf8dbe', // View
|
||||
toObjectMetadataId: '61d9000b-485c-4c48-a22e-0d9a164f9647', // ViewField
|
||||
fromFieldMetadataId: '064eb439-fdfa-4246-a13a-989c5bcc4d97', // View > ViewFields
|
||||
toFieldMetadataId: 'a9a56210-a154-4965-9ace-c35f6dc43ee5', // ViewField > View
|
||||
workspaceId: 'twenty-7ed9d212-1c25-4d02-bf25-6aeccf7ea419',
|
||||
},
|
||||
])
|
||||
.execute();
|
||||
};
|
||||
Reference in New Issue
Block a user