Skip to content

Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.

Cascade site google auth deletion

Uku Tahtfd8917d4f39f
diff --git a/priv/repo/migrations/20200106085607_cascade_google_auth_deletion.exs b/priv/repo/migrations/20200106085607_cascade_google_auth_deletion.exs
new file mode 100644
index 0000000000..20251373e8
--- /dev/null
+++ b/priv/repo/migrations/20200106085607_cascade_google_auth_deletion.exs
@@ -0,0 +1,11 @@
+defmodule Plausible.Repo.Migrations.CascadeGoogleAuthDeletion do
+ use Ecto.Migration
+
+ def change do
+ drop constraint("google_auth", "google_auth_site_id_fkey")
+
+ alter table(:google_auth) do
+ modify :site_id, references(:sites, on_delete: :delete_all), null: false
+ end
+ end
+end
diff --git a/test/plausible_web/controllers/auth_controller_test.exs b/test/plausible_web/controllers/auth_controller_test.exs
index 67098aab89..c4d2a07c4c 100644
--- a/test/plausible_web/controllers/auth_controller_test.exs
+++ b/test/plausible_web/controllers/auth_controller_test.exs
@@ -163,6 +163,9 @@ defmodule PlausibleWeb.AuthControllerTest do
timestamp: NaiveDateTime.utc_now()
}])
+ site = insert(:site, members: [user])
+ insert(:google_auth, site: site, user: user)
+
conn = delete(conn, "/me")
assert redirected_to(conn) == "/"
end