-
-
Notifications
You must be signed in to change notification settings - Fork 332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement roles.delete
, databases.drop
& databases.configured.disconnect
endpoints
#3858
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b436fcd
implement roles.delete endpoint
Anish9901 ee3d351
add drop database sql functions
Anish9901 0870db9
add drop_database sql function with name input
Anish9901 739ea57
implement databases.delete and databases.configured.disconnect endpoints
Anish9901 19e3530
add endpoint tests
Anish9901 4be937d
fix drop databases from python
Anish9901 9cc36f9
fix docstring for drop_database sql
Anish9901 8d0d01b
Merge branch 'develop' into rd_db_dis_d
pavish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from db.connection import exec_msar_func | ||
from psycopg import sql | ||
|
||
|
||
def drop_database(database_oid, conn): | ||
cursor = conn.cursor() | ||
conn.autocommit = True | ||
drop_database_query = exec_msar_func( | ||
conn, | ||
'drop_database_query', | ||
database_oid | ||
).fetchone()[0] | ||
cursor.execute(sql.SQL(drop_database_query)) | ||
cursor.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from db.connection import exec_msar_func | ||
|
||
|
||
def drop_role(role_oid, conn): | ||
exec_msar_func(conn, 'drop_role', role_oid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,3 +50,17 @@ def list_(*, server_id: int = None, **kwargs) -> list[ConfiguredDatabaseInfo]: | |
database_qs = Database.objects.all() | ||
|
||
return [ConfiguredDatabaseInfo.from_model(db_model) for db_model in database_qs] | ||
|
||
|
||
@rpc_method(name="databases.configured.disconnect") | ||
@http_basic_auth_login_required | ||
@handle_rpc_exceptions | ||
def disconnect(*, database_id: int, **kwargs) -> None: | ||
""" | ||
Disconnect a configured database. | ||
|
||
Args: | ||
database_id: The Django id of the database. | ||
""" | ||
database_qs = Database.objects.get(id=database_id) | ||
database_qs.delete() | ||
Comment on lines
+65
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to discuss on how to remove the Mathesar schemas. This requires a broader discussion on how we'll retain/request the user for the role & password for the role that owns the schemas. We can get back to this before beta. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been thinking more about this and we should only be providing
delete
for databases created in the internal server. Only Mathesar admins should be able to perform this.When the user requests a delete, these conditions should match:
And then, in a single transaction:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing needed in this PR, we can do this for beta.