mirror of
https://github.com/lingble/twenty.git
synced 2025-11-11 18:56:17 +00:00
Add standard company table migrations (#2484)
This commit is contained in:
@@ -55,7 +55,7 @@ export const seedViews = async (
|
|||||||
{
|
{
|
||||||
id: SeedViewIds.Person,
|
id: SeedViewIds.Person,
|
||||||
name: 'All People',
|
name: 'All People',
|
||||||
objectMetadataId: SeedObjectMetadataIds.Company,
|
objectMetadataId: SeedObjectMetadataIds.Person,
|
||||||
type: 'table',
|
type: 'table',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -62,12 +62,6 @@ export const addCompanyTable: TenantMigrationTableAction[] = [
|
|||||||
columnType: 'uuid',
|
columnType: 'uuid',
|
||||||
action: TenantMigrationColumnActionType.CREATE,
|
action: TenantMigrationColumnActionType.CREATE,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
columnName: 'accountOwnerId',
|
|
||||||
referencedTableName: 'workspaceMember',
|
|
||||||
referencedTableColumnName: 'id',
|
|
||||||
action: TenantMigrationColumnActionType.RELATION,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import { TenantMigrationTableAction } from 'src/metadata/tenant-migration/tenant-migration.entity';
|
import {
|
||||||
|
TenantMigrationColumnActionType,
|
||||||
|
TenantMigrationTableAction,
|
||||||
|
} from 'src/metadata/tenant-migration/tenant-migration.entity';
|
||||||
|
|
||||||
export const addActivityTargetTable: TenantMigrationTableAction[] = [
|
export const addActivityTargetTable: TenantMigrationTableAction[] = [
|
||||||
{
|
{
|
||||||
@@ -8,6 +11,12 @@ export const addActivityTargetTable: TenantMigrationTableAction[] = [
|
|||||||
{
|
{
|
||||||
name: 'activityTarget',
|
name: 'activityTarget',
|
||||||
action: 'alter',
|
action: 'alter',
|
||||||
columns: [],
|
columns: [
|
||||||
|
{
|
||||||
|
columnName: 'companyId',
|
||||||
|
columnType: 'uuid',
|
||||||
|
action: TenantMigrationColumnActionType.CREATE,
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import { TenantMigrationTableAction } from 'src/metadata/tenant-migration/tenant-migration.entity';
|
import {
|
||||||
|
TenantMigrationColumnActionType,
|
||||||
|
TenantMigrationTableAction,
|
||||||
|
} from 'src/metadata/tenant-migration/tenant-migration.entity';
|
||||||
|
|
||||||
export const addAttachmentTable: TenantMigrationTableAction[] = [
|
export const addAttachmentTable: TenantMigrationTableAction[] = [
|
||||||
{
|
{
|
||||||
@@ -8,6 +11,12 @@ export const addAttachmentTable: TenantMigrationTableAction[] = [
|
|||||||
{
|
{
|
||||||
name: 'attachment',
|
name: 'attachment',
|
||||||
action: 'alter',
|
action: 'alter',
|
||||||
columns: [],
|
columns: [
|
||||||
|
{
|
||||||
|
columnName: 'companyId',
|
||||||
|
columnType: 'uuid',
|
||||||
|
action: TenantMigrationColumnActionType.CREATE,
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import { TenantMigrationTableAction } from 'src/metadata/tenant-migration/tenant-migration.entity';
|
import {
|
||||||
|
TenantMigrationColumnActionType,
|
||||||
|
TenantMigrationTableAction,
|
||||||
|
} from 'src/metadata/tenant-migration/tenant-migration.entity';
|
||||||
|
|
||||||
export const addFavoriteTable: TenantMigrationTableAction[] = [
|
export const addFavoriteTable: TenantMigrationTableAction[] = [
|
||||||
{
|
{
|
||||||
@@ -8,6 +11,12 @@ export const addFavoriteTable: TenantMigrationTableAction[] = [
|
|||||||
{
|
{
|
||||||
name: 'favorite',
|
name: 'favorite',
|
||||||
action: 'alter',
|
action: 'alter',
|
||||||
columns: [],
|
columns: [
|
||||||
|
{
|
||||||
|
columnName: 'companyId',
|
||||||
|
columnType: 'uuid',
|
||||||
|
action: TenantMigrationColumnActionType.CREATE,
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import { TenantMigrationTableAction } from 'src/metadata/tenant-migration/tenant-migration.entity';
|
import {
|
||||||
|
TenantMigrationColumnActionType,
|
||||||
|
TenantMigrationTableAction,
|
||||||
|
} from 'src/metadata/tenant-migration/tenant-migration.entity';
|
||||||
|
|
||||||
export const addOpportunityTable: TenantMigrationTableAction[] = [
|
export const addOpportunityTable: TenantMigrationTableAction[] = [
|
||||||
{
|
{
|
||||||
@@ -8,6 +11,12 @@ export const addOpportunityTable: TenantMigrationTableAction[] = [
|
|||||||
{
|
{
|
||||||
name: 'opportunity',
|
name: 'opportunity',
|
||||||
action: 'alter',
|
action: 'alter',
|
||||||
columns: [],
|
columns: [
|
||||||
|
{
|
||||||
|
columnName: 'companyId',
|
||||||
|
columnType: 'uuid',
|
||||||
|
action: TenantMigrationColumnActionType.CREATE,
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import { TenantMigrationTableAction } from 'src/metadata/tenant-migration/tenant-migration.entity';
|
import {
|
||||||
|
TenantMigrationColumnActionType,
|
||||||
|
TenantMigrationTableAction,
|
||||||
|
} from 'src/metadata/tenant-migration/tenant-migration.entity';
|
||||||
|
|
||||||
export const addPersonTable: TenantMigrationTableAction[] = [
|
export const addPersonTable: TenantMigrationTableAction[] = [
|
||||||
{
|
{
|
||||||
@@ -8,6 +11,12 @@ export const addPersonTable: TenantMigrationTableAction[] = [
|
|||||||
{
|
{
|
||||||
name: 'person',
|
name: 'person',
|
||||||
action: 'alter',
|
action: 'alter',
|
||||||
columns: [],
|
columns: [
|
||||||
|
{
|
||||||
|
columnName: 'companyId',
|
||||||
|
columnType: 'uuid',
|
||||||
|
action: TenantMigrationColumnActionType.CREATE,
|
||||||
|
},
|
||||||
|
],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import {
|
||||||
|
TenantMigrationColumnActionType,
|
||||||
|
TenantMigrationTableAction,
|
||||||
|
} from 'src/metadata/tenant-migration/tenant-migration.entity';
|
||||||
|
|
||||||
|
export const addCompanyRelations: TenantMigrationTableAction[] = [
|
||||||
|
{
|
||||||
|
name: 'company',
|
||||||
|
action: 'alter',
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
columnName: 'accountOwnerId',
|
||||||
|
referencedTableName: 'workspaceMember',
|
||||||
|
referencedTableColumnName: 'id',
|
||||||
|
action: TenantMigrationColumnActionType.RELATION,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import {
|
||||||
|
TenantMigrationColumnActionType,
|
||||||
|
TenantMigrationTableAction,
|
||||||
|
} from 'src/metadata/tenant-migration/tenant-migration.entity';
|
||||||
|
|
||||||
|
export const addAttachmentRelations: TenantMigrationTableAction[] = [
|
||||||
|
{
|
||||||
|
name: 'attachment',
|
||||||
|
action: 'alter',
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
columnName: 'companyId',
|
||||||
|
referencedTableName: 'company',
|
||||||
|
referencedTableColumnName: 'id',
|
||||||
|
action: TenantMigrationColumnActionType.RELATION,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import {
|
||||||
|
TenantMigrationColumnActionType,
|
||||||
|
TenantMigrationTableAction,
|
||||||
|
} from 'src/metadata/tenant-migration/tenant-migration.entity';
|
||||||
|
|
||||||
|
export const addPersonRelations: TenantMigrationTableAction[] = [
|
||||||
|
{
|
||||||
|
name: 'person',
|
||||||
|
action: 'alter',
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
columnName: 'companyId',
|
||||||
|
referencedTableName: 'company',
|
||||||
|
referencedTableColumnName: 'id',
|
||||||
|
action: TenantMigrationColumnActionType.RELATION,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import {
|
||||||
|
TenantMigrationColumnActionType,
|
||||||
|
TenantMigrationTableAction,
|
||||||
|
} from 'src/metadata/tenant-migration/tenant-migration.entity';
|
||||||
|
|
||||||
|
export const addFavoriteRelations: TenantMigrationTableAction[] = [
|
||||||
|
{
|
||||||
|
name: 'favorite',
|
||||||
|
action: 'alter',
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
columnName: 'companyId',
|
||||||
|
referencedTableName: 'company',
|
||||||
|
referencedTableColumnName: 'id',
|
||||||
|
action: TenantMigrationColumnActionType.RELATION,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import {
|
||||||
|
TenantMigrationColumnActionType,
|
||||||
|
TenantMigrationTableAction,
|
||||||
|
} from 'src/metadata/tenant-migration/tenant-migration.entity';
|
||||||
|
|
||||||
|
export const addOpportunitiesRelations: TenantMigrationTableAction[] = [
|
||||||
|
{
|
||||||
|
name: 'opportunity',
|
||||||
|
action: 'alter',
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
columnName: 'companyId',
|
||||||
|
referencedTableName: 'company',
|
||||||
|
referencedTableColumnName: 'id',
|
||||||
|
action: TenantMigrationColumnActionType.RELATION,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
import {
|
||||||
|
TenantMigrationColumnActionType,
|
||||||
|
TenantMigrationTableAction,
|
||||||
|
} from 'src/metadata/tenant-migration/tenant-migration.entity';
|
||||||
|
|
||||||
|
export const addActivityTargetRelations: TenantMigrationTableAction[] = [
|
||||||
|
{
|
||||||
|
name: 'activityTarget',
|
||||||
|
action: 'alter',
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
columnName: 'companyId',
|
||||||
|
referencedTableName: 'company',
|
||||||
|
referencedTableColumnName: 'id',
|
||||||
|
action: TenantMigrationColumnActionType.RELATION,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -10,6 +10,12 @@ import { addPipelineStepTable } from 'src/metadata/tenant-migration/migrations/1
|
|||||||
import { addWebhookTable } from 'src/metadata/tenant-migration/migrations/1697618024-addWebhookTable';
|
import { addWebhookTable } from 'src/metadata/tenant-migration/migrations/1697618024-addWebhookTable';
|
||||||
import { addWorkspaceMemberSettingTable } from 'src/metadata/tenant-migration/migrations/1697618025-addWorkspaceMemberSettingTable';
|
import { addWorkspaceMemberSettingTable } from 'src/metadata/tenant-migration/migrations/1697618025-addWorkspaceMemberSettingTable';
|
||||||
import { addWorkspaceMemberTable } from 'src/metadata/tenant-migration/migrations/1697618026-addWorspaceMemberTable';
|
import { addWorkspaceMemberTable } from 'src/metadata/tenant-migration/migrations/1697618026-addWorspaceMemberTable';
|
||||||
|
import { addCompanyRelations } from 'src/metadata/tenant-migration/migrations/1697618027-addCompanyRelations';
|
||||||
|
import { addAttachmentRelations } from 'src/metadata/tenant-migration/migrations/1697618028-addAttachmentRelations';
|
||||||
|
import { addPersonRelations } from 'src/metadata/tenant-migration/migrations/1697618029-addPersonRelations';
|
||||||
|
import { addFavoriteRelations } from 'src/metadata/tenant-migration/migrations/1697618030-addFavoriteRelations';
|
||||||
|
import { addOpportunitiesRelations } from 'src/metadata/tenant-migration/migrations/1697618031-addOpportunitiesRelations';
|
||||||
|
import { addActivityTargetRelations } from 'src/metadata/tenant-migration/migrations/1697618032-addActivityTargetRelations';
|
||||||
|
|
||||||
import { addCompanyTable } from './migrations/1697618009-addCompanyTable';
|
import { addCompanyTable } from './migrations/1697618009-addCompanyTable';
|
||||||
import { addViewTable } from './migrations/1697618011-addViewTable';
|
import { addViewTable } from './migrations/1697618011-addViewTable';
|
||||||
@@ -19,6 +25,7 @@ import { addViewSortTable } from './migrations/1697618014-addViewSortTable';
|
|||||||
|
|
||||||
// TODO: read the folder and return all migrations
|
// TODO: read the folder and return all migrations
|
||||||
export const standardMigrations = {
|
export const standardMigrations = {
|
||||||
|
'1697618009-addCompanyTable': addCompanyTable,
|
||||||
'1697618011-addViewTable': addViewTable,
|
'1697618011-addViewTable': addViewTable,
|
||||||
'1697618012-addViewFieldTable': addViewFieldTable,
|
'1697618012-addViewFieldTable': addViewFieldTable,
|
||||||
'1697618013-addViewFilterTable': addViewFilterTable,
|
'1697618013-addViewFilterTable': addViewFilterTable,
|
||||||
@@ -36,5 +43,10 @@ export const standardMigrations = {
|
|||||||
'1697618024-addWebhookTable': addWebhookTable,
|
'1697618024-addWebhookTable': addWebhookTable,
|
||||||
'1697618025-addWorkspaceMemberSettingTable': addWorkspaceMemberSettingTable,
|
'1697618025-addWorkspaceMemberSettingTable': addWorkspaceMemberSettingTable,
|
||||||
'1697618026-addWorkspaceMemberTable': addWorkspaceMemberTable,
|
'1697618026-addWorkspaceMemberTable': addWorkspaceMemberTable,
|
||||||
'1697618009-addCompanyTable': addCompanyTable,
|
'1697618027-addCompanyRelations': addCompanyRelations,
|
||||||
|
'1697618028-addAttachmentRelations': addAttachmentRelations,
|
||||||
|
'1697618029-addPersonRelations': addPersonRelations,
|
||||||
|
'1697618030-addFavoriteRelations': addFavoriteRelations,
|
||||||
|
'1697618031-addOpportunitiesRelations': addOpportunitiesRelations,
|
||||||
|
'1697618032-addActivityTargetRelations': addActivityTargetRelations,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ export class CompositeFieldAliasFactory {
|
|||||||
|
|
||||||
// Otherwise it means it's a relation destination is of kind ONE
|
// Otherwise it means it's a relation destination is of kind ONE
|
||||||
return `
|
return `
|
||||||
${fieldKey}: ${referencedObjectMetadata.targetTableName} {
|
${fieldKey} {
|
||||||
${this.fieldsStringFactory.createFieldsStringRecursive(
|
${this.fieldsStringFactory.createFieldsStringRecursive(
|
||||||
info,
|
info,
|
||||||
fieldValue,
|
fieldValue,
|
||||||
|
|||||||
Reference in New Issue
Block a user