|
|
|
@ -17,6 +17,7 @@ export enum MetaDiffType {
|
|
|
|
|
TABLE_REMOVE = 'TABLE_REMOVE', |
|
|
|
|
TABLE_COLUMN_ADD = 'TABLE_COLUMN_ADD', |
|
|
|
|
TABLE_COLUMN_TYPE_CHANGE = 'TABLE_COLUMN_TYPE_CHANGE', |
|
|
|
|
TABLE_COLUMN_PROPS_CHANGED = 'TABLE_COLUMN_PROPS_CHANGED', |
|
|
|
|
TABLE_COLUMN_REMOVE = 'TABLE_COLUMN_REMOVE', |
|
|
|
|
VIEW_NEW = 'VIEW_NEW', |
|
|
|
|
VIEW_REMOVE = 'VIEW_REMOVE', |
|
|
|
@ -103,6 +104,15 @@ type MetaDiffChange = {
|
|
|
|
|
relationType: RelationTypes; |
|
|
|
|
cstn?: string; |
|
|
|
|
} |
|
|
|
|
| { |
|
|
|
|
type: MetaDiffType.TABLE_COLUMN_PROPS_CHANGED; |
|
|
|
|
tn?: string; |
|
|
|
|
model?: Model; |
|
|
|
|
id?: string; |
|
|
|
|
cn: string; |
|
|
|
|
column: Column; |
|
|
|
|
colId?: string; |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
@Injectable() |
|
|
|
@ -217,6 +227,21 @@ export class MetaDiffsService {
|
|
|
|
|
column: oldCol, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
if ( |
|
|
|
|
!!oldCol.pk !== !!column.pk || |
|
|
|
|
!!oldCol.rqd !== !!column.rqd || |
|
|
|
|
!!oldCol.un !== !!column.un || |
|
|
|
|
!!oldCol.ai !== !!column.ai || |
|
|
|
|
!!oldCol.unique !== !!column.unique |
|
|
|
|
) { |
|
|
|
|
tableProp.detectedChanges.push({ |
|
|
|
|
type: MetaDiffType.TABLE_COLUMN_PROPS_CHANGED, |
|
|
|
|
msg: `Column properties changed (${column.cn})`, |
|
|
|
|
cn: oldCol.column_name, |
|
|
|
|
id: oldMeta.id, |
|
|
|
|
column: oldCol, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
for (const column of oldMeta.columns) { |
|
|
|
|
if ( |
|
|
|
@ -688,6 +713,23 @@ export class MetaDiffsService {
|
|
|
|
|
await Column.update(change.column.id, column); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case MetaDiffType.TABLE_COLUMN_PROPS_CHANGED: |
|
|
|
|
{ |
|
|
|
|
const columns = ( |
|
|
|
|
await sqlClient.columnList({ tn: table_name }) |
|
|
|
|
)?.data?.list?.map((c) => ({ ...c, column_name: c.cn })); |
|
|
|
|
const colMeta = columns.find((c) => c.cn === change.cn); |
|
|
|
|
if (!colMeta) break; |
|
|
|
|
const { pk, ai, rqd, un, unique } = colMeta; |
|
|
|
|
await Column.update(change.column.id, { |
|
|
|
|
pk, |
|
|
|
|
ai, |
|
|
|
|
rqd, |
|
|
|
|
un, |
|
|
|
|
unique, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case MetaDiffType.TABLE_COLUMN_REMOVE: |
|
|
|
|
case MetaDiffType.VIEW_COLUMN_REMOVE: |
|
|
|
|
await change.column.delete(); |
|
|
|
@ -884,6 +926,23 @@ export class MetaDiffsService {
|
|
|
|
|
await Column.update(change.column.id, column); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case MetaDiffType.TABLE_COLUMN_PROPS_CHANGED: |
|
|
|
|
{ |
|
|
|
|
const columns = ( |
|
|
|
|
await sqlClient.columnList({ tn: table_name }) |
|
|
|
|
)?.data?.list?.map((c) => ({ ...c, column_name: c.cn })); |
|
|
|
|
const colMeta = columns.find((c) => c.cn === change.cn); |
|
|
|
|
if (!colMeta) break; |
|
|
|
|
const { pk, ai, rqd, un, unique } = colMeta; |
|
|
|
|
await Column.update(change.column.id, { |
|
|
|
|
pk, |
|
|
|
|
ai, |
|
|
|
|
rqd, |
|
|
|
|
un, |
|
|
|
|
unique, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
case MetaDiffType.TABLE_COLUMN_REMOVE: |
|
|
|
|
case MetaDiffType.VIEW_COLUMN_REMOVE: |
|
|
|
|
await change.column.delete(); |
|
|
|
|