Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

Delete the data source and database info when deleting the instance

天舟a509048ce985
diff --git a/frontend/src/miragejs/routes/index.js b/frontend/src/miragejs/routes/index.js
index 904efc4d39..e6c410600d 100644
--- a/frontend/src/miragejs/routes/index.js
+++ b/frontend/src/miragejs/routes/index.js
@@ -363,6 +363,18 @@ export default function routes() {
});
this.delete("/instance/:instanceId", function (schema, request) {
+ // Delete data source and database before instance itself.
+ // Otherwise, the instanceId will be set to null.
+ const dataSourceList = schema.dataSources.where({
+ instanceId: request.params.instanceId,
+ });
+ dataSourceList.models.forEach((item) => item.destroy());
+
+ const databaseList = schema.databases.where({
+ instanceId: request.params.instanceId,
+ });
+ databaseList.models.forEach((item) => item.destroy());
+
return schema.instances.find(request.params.instanceId).destroy();
});
diff --git a/frontend/src/views/InstanceDetail.vue b/frontend/src/views/InstanceDetail.vue
index 1a53268de2..93f19e3045 100644
--- a/frontend/src/views/InstanceDetail.vue
+++ b/frontend/src/views/InstanceDetail.vue
@@ -265,6 +265,7 @@ input[type="number"] {
:style="'CRITICAL'"
:okText="'Delete'"
:title="'Delete instance \'' + state.instance.name + '\' ?'"
+ :description="'All associated data sources will also be deleted. You cannot undo this action.'"
@ok="
() => {
state.showDeleteModal = false;