Skip to content

Commit

Permalink
allow disconnecting server via databases.configured.disconnect
Browse files Browse the repository at this point in the history
  • Loading branch information
Anish9901 committed Jan 17, 2025
1 parent 021b196 commit 144bc96
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mathesar/rpc/databases/configured.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def disconnect(
strict: bool = True,
role_name: str = None,
password: str = None,
disconnect_db_server: bool = False
) -> None:
"""
Disconnect a configured database, after removing Mathesar SQL from it.
Expand All @@ -92,6 +93,11 @@ def disconnect(
we fail to remove any objects which we expected to remove.
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.
This is intended for optional use while disconnecting the
last database on the server.
"""
database = Database.objects.get(id=database_id)
database.uninstall_sql(
Expand All @@ -101,3 +107,5 @@ def disconnect(
password=password,
)
database.delete()
if disconnect_db_server:
database.server.delete()

0 comments on commit 144bc96

Please sign in to comment.