Cascade delete sent_renewal_notifications table when user is deleted (#2549)

* Cascade delete sent_renewal_notifications table when user is deleted

This commit fixes a bug when deleting a user would trigger a constraint
error.

* Update CHANGELOG.md
pull/2558/head
Vini Brasil 4 years ago committed by GitHub
parent 10a9767912
commit b6d30019ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -7,6 +7,9 @@ All notable changes to this project will be documented in this file.
- Reject events with long URIs and data URIs plausible/analytics#2536
- Always show direct traffic in sources reports plausible/analytics#2531
## Fixed
- Cascade delete sent_renewal_notifications table when user is deleted plausible/analytics#2549
## v1.5.1 - 2022-12-06
### Fixed

@ -0,0 +1,11 @@
defmodule Plausible.Repo.Migrations.CascadeDeleteSentRenewalNotifications do
use Ecto.Migration
def change do
drop constraint("sent_renewal_notifications", "sent_renewal_notifications_user_id_fkey")
alter table(:sent_renewal_notifications) do
modify :user_id, references(:users, on_delete: :delete_all), null: false
end
end
end

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

Loading…
Cancel
Save