Add Relation Metadata (#2388)
* Add Relation Metadata * remove logs * fix migrations * add one-to-many relation inside entities * fix relation * use enum for tenant migration column action type
This commit is contained in:
@ -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 addCompanyTable: TenantMigrationTableAction[] = [
|
||||
{
|
||||
@ -10,24 +13,24 @@ export const addCompanyTable: TenantMigrationTableAction[] = [
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'varchar',
|
||||
action: 'create',
|
||||
columnName: 'name',
|
||||
columnType: 'varchar',
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
name: 'domainName',
|
||||
type: 'varchar',
|
||||
action: 'create',
|
||||
columnName: 'domainName',
|
||||
columnType: 'varchar',
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
name: 'address',
|
||||
type: 'varchar',
|
||||
action: 'create',
|
||||
columnName: 'address',
|
||||
columnType: 'varchar',
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
name: 'employees',
|
||||
type: 'integer',
|
||||
action: 'create',
|
||||
columnName: 'employees',
|
||||
columnType: 'integer',
|
||||
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 addViewTable: TenantMigrationTableAction[] = [
|
||||
{
|
||||
@ -10,19 +13,19 @@ export const addViewTable: TenantMigrationTableAction[] = [
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'varchar',
|
||||
action: 'create',
|
||||
columnName: 'name',
|
||||
columnType: 'varchar',
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
name: 'objectId',
|
||||
type: 'varchar',
|
||||
action: 'create',
|
||||
columnName: 'objectId',
|
||||
columnType: 'varchar',
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
name: 'type',
|
||||
type: 'varchar',
|
||||
action: 'create',
|
||||
columnName: 'type',
|
||||
columnType: 'varchar',
|
||||
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 addViewFieldTable: TenantMigrationTableAction[] = [
|
||||
{
|
||||
@ -10,29 +13,29 @@ export const addViewFieldTable: TenantMigrationTableAction[] = [
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
name: 'fieldId',
|
||||
type: 'varchar',
|
||||
action: 'create',
|
||||
columnName: 'fieldId',
|
||||
columnType: 'varchar',
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
name: 'viewId',
|
||||
type: 'varchar',
|
||||
action: 'create',
|
||||
columnName: 'viewId',
|
||||
columnType: 'varchar',
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
name: 'position',
|
||||
type: 'integer',
|
||||
action: 'create',
|
||||
columnName: 'position',
|
||||
columnType: 'integer',
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
name: 'isVisible',
|
||||
type: 'boolean',
|
||||
action: 'create',
|
||||
columnName: 'isVisible',
|
||||
columnType: 'boolean',
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
name: 'size',
|
||||
type: 'integer',
|
||||
action: 'create',
|
||||
columnName: 'size',
|
||||
columnType: 'integer',
|
||||
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 addViewFilterTable: TenantMigrationTableAction[] = [
|
||||
{
|
||||
@ -10,29 +13,29 @@ export const addViewFilterTable: TenantMigrationTableAction[] = [
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
name: 'fieldId',
|
||||
type: 'varchar',
|
||||
action: 'create',
|
||||
columnName: 'fieldId',
|
||||
columnType: 'varchar',
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
name: 'viewId',
|
||||
type: 'varchar',
|
||||
action: 'create',
|
||||
columnName: 'viewId',
|
||||
columnType: 'varchar',
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
name: 'operand',
|
||||
type: 'varchar',
|
||||
action: 'create',
|
||||
columnName: 'operand',
|
||||
columnType: 'varchar',
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
name: 'value',
|
||||
type: 'varchar',
|
||||
action: 'create',
|
||||
columnName: 'value',
|
||||
columnType: 'varchar',
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
name: 'displayValue',
|
||||
type: 'varchar',
|
||||
action: 'create',
|
||||
columnName: 'displayValue',
|
||||
columnType: 'varchar',
|
||||
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 addViewSortTable: TenantMigrationTableAction[] = [
|
||||
{
|
||||
@ -10,19 +13,19 @@ export const addViewSortTable: TenantMigrationTableAction[] = [
|
||||
action: 'alter',
|
||||
columns: [
|
||||
{
|
||||
name: 'fieldId',
|
||||
type: 'varchar',
|
||||
action: 'create',
|
||||
columnName: 'fieldId',
|
||||
columnType: 'varchar',
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
name: 'viewId',
|
||||
type: 'varchar',
|
||||
action: 'create',
|
||||
columnName: 'viewId',
|
||||
columnType: 'varchar',
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
{
|
||||
name: 'direction',
|
||||
type: 'varchar',
|
||||
action: 'create',
|
||||
columnName: 'direction',
|
||||
columnType: 'varchar',
|
||||
action: TenantMigrationColumnActionType.CREATE,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@ -5,12 +5,28 @@ import {
|
||||
PrimaryGeneratedColumn,
|
||||
} from 'typeorm';
|
||||
|
||||
export type TenantMigrationColumnAction = {
|
||||
name: string;
|
||||
type: string;
|
||||
action: 'create';
|
||||
export enum TenantMigrationColumnActionType {
|
||||
CREATE = 'CREATE',
|
||||
RELATION = 'RELATION',
|
||||
}
|
||||
|
||||
export type TenantMigrationColumnCreate = {
|
||||
action: TenantMigrationColumnActionType.CREATE;
|
||||
columnName: string;
|
||||
columnType: string;
|
||||
};
|
||||
|
||||
export type TenantMigrationColumnRelation = {
|
||||
action: TenantMigrationColumnActionType.RELATION;
|
||||
columnName: string;
|
||||
referencedTableName: string;
|
||||
referencedTableColumnName: string;
|
||||
};
|
||||
|
||||
export type TenantMigrationColumnAction = {
|
||||
action: TenantMigrationColumnActionType;
|
||||
} & (TenantMigrationColumnCreate | TenantMigrationColumnRelation);
|
||||
|
||||
export type TenantMigrationTableAction = {
|
||||
name: string;
|
||||
action: 'create' | 'alter';
|
||||
|
||||
Reference in New Issue
Block a user