Skip to content

Commit

Permalink
add a check to ensure that no connected dbs exist in mathesar before …
Browse files Browse the repository at this point in the history
…deleting db server
  • Loading branch information
Anish9901 committed Jan 17, 2025
1 parent 144bc96 commit b3e1f57
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mathesar/rpc/databases/configured.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ def disconnect(
role_name: the username of the role used for upgrading.
password: the password of the role used for upgrading.
disconnect_db_server: If True, will delete the stored server
metadata(host, port, role credentials) and also disconnect
all the databases associated with that server from Mathesar.
metadata(host, port, role credentials) from Mathesar.
This is intended for optional use while disconnecting the
last database on the server.
"""
Expand All @@ -107,5 +106,6 @@ def disconnect(
password=password,
)
database.delete()
if disconnect_db_server:
server_db_count = len(Database.objects.filter(server=database.server))
if disconnect_db_server and server_db_count == 0:
database.server.delete()

0 comments on commit b3e1f57

Please sign in to comment.