Browse Source

Merge pull request #4761 from nocodb/fix/4759-remove-source

fix: remove datasource
pull/4764/head
mertmit 2 years ago committed by GitHub
parent
commit
ba800793a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      packages/nocodb/src/lib/models/Base.ts
  2. 22
      packages/nocodb/src/lib/models/Model.ts

2
packages/nocodb/src/lib/models/Base.ts

@ -278,7 +278,7 @@ export default class Base implements BaseType {
ncMeta
);
for (const model of models) {
await model.delete(ncMeta);
await model.delete(ncMeta, true);
}
await NocoCache.deepDel(
CacheScope.BASE,

22
packages/nocodb/src/lib/models/Model.ts

@ -345,7 +345,7 @@ export default class Model implements TableType {
});
}
async delete(ncMeta = Noco.ncMeta): Promise<boolean> {
async delete(ncMeta = Noco.ncMeta, force = false): Promise<boolean> {
await Audit.deleteRowComments(this.id);
for (const view of await this.getViews(true)) {
@ -391,6 +391,26 @@ export default class Model implements TableType {
}
}
if (force) {
const leftOverColumns = await ncMeta.metaList2(null, null, MetaTable.COL_RELATIONS, {
condition: {
fk_related_model_id: this.id,
},
});
for (const col of leftOverColumns) {
await NocoCache.deepDel(
CacheScope.COL_RELATION,
`${CacheScope.COL_RELATION}:${col.fk_column_id}`,
CacheDelDirection.CHILD_TO_PARENT
);
}
await ncMeta.metaDelete(null, null, MetaTable.COL_RELATIONS, {
fk_related_model_id: this.id,
});
}
await NocoCache.deepDel(
CacheScope.COLUMN,
`${CacheScope.COLUMN}:${this.id}`,

Loading…
Cancel
Save