Fix user deletion

This commit is contained in:
Uku Taht 2020-12-30 11:00:37 +02:00
parent bbb6bae4a2
commit 9bbaa756b8
2 changed files with 31 additions and 0 deletions

View File

@ -0,0 +1,17 @@
defmodule Plausible.Repo.Migrations.DeleteEmailRecordsWhenUserIsDeleted do
use Ecto.Migration
def change do
alter table(:create_site_emails) do
modify :user_id, references(:users, on_delete: :delete_all),
null: false,
from: references(:users)
end
alter table(:check_stats_emails) do
modify :user_id, references(:users, on_delete: :delete_all),
null: false,
from: references(:users)
end
end
end

View File

@ -302,6 +302,20 @@ defmodule PlausibleWeb.AuthControllerTest do
}
])
Repo.insert_all("create_site_emails", [
%{
user_id: user.id,
timestamp: NaiveDateTime.utc_now()
}
])
Repo.insert_all("check_stats_emails", [
%{
user_id: user.id,
timestamp: NaiveDateTime.utc_now()
}
])
insert(:google_auth, site: site, user: user)
insert(:subscription, user: user, status: "deleted")