Skip to content
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

Cascade delete sent_renewal_notifications table when user is deleted #2549

Merged
merged 2 commits into from
Jan 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
7 changes: 7 additions & 0 deletions test/plausible_web/controllers/auth_controller_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down