-
Notifications
You must be signed in to change notification settings - Fork 170
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
Drop all databases on DELETE /v1/admin/databases
#1968
Conversation
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.
Overall LGTM, left some minor comments.
plug :delete_tenant | ||
|
||
defp delete_tenant(conn, _) do | ||
case TenantManager.delete_all_tenants(conn.assigns.config) do |
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.
At first glance this looked like it would fail to respond to the HTTP request if the deletion failed.
Looking further i realised that delete_all_tenants
will/should always return :ok
.
So the case
statement seems unnecessary. This would be equivalent:
:ok = TenantManager.delete_all_tenants(conn.assigns.config)
conn
|> send_resp(200, Jason.encode_to_iodata!(%{}))
|> halt()
@@ -2,6 +2,7 @@ defmodule Electric.Plug.RemoveDatabasePlug do | |||
use Plug.Builder | |||
|
|||
alias Plug.Conn | |||
|
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.
unnecessary change
plug :put_resp_content_type, "application/json" | ||
plug :delete_tenant | ||
|
||
defp delete_tenant(conn, _) do |
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.
This should be named delete_tenants
|
||
assert conn.status == 200 | ||
|
||
assert Electric.Tenant.Persistence.load_tenants!( |
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.
Not sure if loading from persistence is the right thing to check here.
I'd check that Electric.TenantManager.get_only_tenant(config)
returns {:error, :not_found}
Closing as the purpose of this PR is to allow is to allow users of electric (not the cloud) to clear all replication slots so they can permanently stop electric. But since the multi-tenancy separation there is no concept of "all databases" now in electric, there is only one database, so all we need is an endpoint to delete the one database, which I'll do on a separate PR. |
Fixes #1923