|
|
@ -2059,6 +2059,7 @@ export class ColumnsService { |
|
|
|
req?: any; |
|
|
|
req?: any; |
|
|
|
columnId: string; |
|
|
|
columnId: string; |
|
|
|
user: UserType; |
|
|
|
user: UserType; |
|
|
|
|
|
|
|
forceDeleteSystem?: boolean; |
|
|
|
reuse?: ReusableParams; |
|
|
|
reuse?: ReusableParams; |
|
|
|
}, |
|
|
|
}, |
|
|
|
ncMeta = this.metaService, |
|
|
|
ncMeta = this.metaService, |
|
|
@ -2067,7 +2068,7 @@ export class ColumnsService { |
|
|
|
|
|
|
|
|
|
|
|
const column = await Column.get({ colId: param.columnId }, ncMeta); |
|
|
|
const column = await Column.get({ colId: param.columnId }, ncMeta); |
|
|
|
|
|
|
|
|
|
|
|
if (column.system) { |
|
|
|
if (column.system && !param.forceDeleteSystem) { |
|
|
|
NcError.badRequest( |
|
|
|
NcError.badRequest( |
|
|
|
`The column '${ |
|
|
|
`The column '${ |
|
|
|
column.title || column.column_name |
|
|
|
column.title || column.column_name |
|
|
@ -2178,9 +2179,11 @@ export class ColumnsService { |
|
|
|
colOpt.type === 'mm' && |
|
|
|
colOpt.type === 'mm' && |
|
|
|
colOpt.fk_parent_column_id === childColumn.id && |
|
|
|
colOpt.fk_parent_column_id === childColumn.id && |
|
|
|
colOpt.fk_child_column_id === parentColumn.id && |
|
|
|
colOpt.fk_child_column_id === parentColumn.id && |
|
|
|
colOpt.fk_mm_model_id === mmTable.id && |
|
|
|
colOpt.fk_mm_model_id === relationColOpt.fk_mm_model_id && |
|
|
|
colOpt.fk_mm_parent_column_id === mmChildCol.id && |
|
|
|
colOpt.fk_mm_parent_column_id === |
|
|
|
colOpt.fk_mm_child_column_id === mmParentCol.id |
|
|
|
relationColOpt.fk_mm_child_column_id && |
|
|
|
|
|
|
|
colOpt.fk_mm_child_column_id === |
|
|
|
|
|
|
|
relationColOpt.fk_mm_parent_column_id |
|
|
|
) { |
|
|
|
) { |
|
|
|
await Column.delete(c.id, ncMeta); |
|
|
|
await Column.delete(c.id, ncMeta); |
|
|
|
break; |
|
|
|
break; |
|
|
@ -2189,6 +2192,7 @@ export class ColumnsService { |
|
|
|
|
|
|
|
|
|
|
|
await Column.delete(relationColOpt.fk_column_id, ncMeta); |
|
|
|
await Column.delete(relationColOpt.fk_column_id, ncMeta); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mmTable) { |
|
|
|
// delete bt columns in m2m table
|
|
|
|
// delete bt columns in m2m table
|
|
|
|
await mmTable.getColumns(ncMeta); |
|
|
|
await mmTable.getColumns(ncMeta); |
|
|
|
for (const c of mmTable.columns) { |
|
|
|
for (const c of mmTable.columns) { |
|
|
@ -2199,6 +2203,7 @@ export class ColumnsService { |
|
|
|
await Column.delete(c.id, ncMeta); |
|
|
|
await Column.delete(c.id, ncMeta); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// delete hm columns in parent table
|
|
|
|
// delete hm columns in parent table
|
|
|
|
await parentTable.getColumns(ncMeta); |
|
|
|
await parentTable.getColumns(ncMeta); |
|
|
@ -2206,7 +2211,9 @@ export class ColumnsService { |
|
|
|
if (!isLinksOrLTAR(c.uidt)) continue; |
|
|
|
if (!isLinksOrLTAR(c.uidt)) continue; |
|
|
|
const colOpt = |
|
|
|
const colOpt = |
|
|
|
await c.getColOptions<LinkToAnotherRecordColumn>(ncMeta); |
|
|
|
await c.getColOptions<LinkToAnotherRecordColumn>(ncMeta); |
|
|
|
if (colOpt.fk_related_model_id === mmTable.id) { |
|
|
|
if ( |
|
|
|
|
|
|
|
colOpt.fk_related_model_id === relationColOpt.fk_mm_model_id |
|
|
|
|
|
|
|
) { |
|
|
|
await Column.delete(c.id, ncMeta); |
|
|
|
await Column.delete(c.id, ncMeta); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2217,11 +2224,14 @@ export class ColumnsService { |
|
|
|
if (!isLinksOrLTAR(c.uidt)) continue; |
|
|
|
if (!isLinksOrLTAR(c.uidt)) continue; |
|
|
|
const colOpt = |
|
|
|
const colOpt = |
|
|
|
await c.getColOptions<LinkToAnotherRecordColumn>(ncMeta); |
|
|
|
await c.getColOptions<LinkToAnotherRecordColumn>(ncMeta); |
|
|
|
if (colOpt.fk_related_model_id === mmTable.id) { |
|
|
|
if ( |
|
|
|
|
|
|
|
colOpt.fk_related_model_id === relationColOpt.fk_mm_model_id |
|
|
|
|
|
|
|
) { |
|
|
|
await Column.delete(c.id, ncMeta); |
|
|
|
await Column.delete(c.id, ncMeta); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mmTable) { |
|
|
|
// retrieve columns in m2m table again
|
|
|
|
// retrieve columns in m2m table again
|
|
|
|
await mmTable.getColumns(ncMeta); |
|
|
|
await mmTable.getColumns(ncMeta); |
|
|
|
|
|
|
|
|
|
|
@ -2233,6 +2243,7 @@ export class ColumnsService { |
|
|
|
await mmTable.delete(ncMeta); |
|
|
|
await mmTable.delete(ncMeta); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -2340,6 +2351,7 @@ export class ColumnsService { |
|
|
|
}, |
|
|
|
}, |
|
|
|
ignoreFkDelete = false, |
|
|
|
ignoreFkDelete = false, |
|
|
|
) => { |
|
|
|
) => { |
|
|
|
|
|
|
|
if (childTable) { |
|
|
|
let foreignKeyName; |
|
|
|
let foreignKeyName; |
|
|
|
|
|
|
|
|
|
|
|
// if relationColOpt is not provided, extract it from child table
|
|
|
|
// if relationColOpt is not provided, extract it from child table
|
|
|
@ -2378,6 +2390,7 @@ export class ColumnsService { |
|
|
|
console.log(e.message); |
|
|
|
console.log(e.message); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!relationColOpt) return; |
|
|
|
if (!relationColOpt) return; |
|
|
|
const columnsInRelatedTable: Column[] = await relationColOpt |
|
|
|
const columnsInRelatedTable: Column[] = await relationColOpt |
|
|
@ -2424,7 +2437,7 @@ export class ColumnsService { |
|
|
|
...index, |
|
|
|
...index, |
|
|
|
tn: cTable.table_name, |
|
|
|
tn: cTable.table_name, |
|
|
|
columns: [childColumn.column_name], |
|
|
|
columns: [childColumn.column_name], |
|
|
|
indexName: index.index_name, |
|
|
|
indexName: index.key_name, |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|