Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Migration: add traffic change type (#4325)
hq176da6b49a153
diff --git a/lib/plausible/site/spike_notification.ex b/lib/plausible/site/spike_notification.exindex c37692da23..0c0453c32d 100644--- a/lib/plausible/site/spike_notification.ex+++ b/lib/plausible/site/spike_notification.ex@@ -6,6 +6,7 @@ defmodule Plausible.Site.SpikeNotification dofield :recipients, {:array, :string}field :threshold, :integerfield :last_sent, :naive_datetime+ field :type, Ecto.Enum, values: [:spike, :drop], default: :spikebelongs_to :site, Plausible.Sitetimestamps()@@ -15,7 +16,7 @@ defmodule Plausible.Site.SpikeNotification doschema|> cast(attrs, [:site_id, :recipients, :threshold])|> validate_required([:site_id, :recipients, :threshold])- |> unique_constraint(:site_id)+ |> unique_constraint([:site_id, :type])enddef add_recipient(schema, recipient) dodiff --git a/priv/repo/migrations/20240702055817_traffic_drop_notifications.exs b/priv/repo/migrations/20240702055817_traffic_drop_notifications.exsnew file mode 100644index 0000000000..d0ed53effb--- /dev/null+++ b/priv/repo/migrations/20240702055817_traffic_drop_notifications.exs@@ -0,0 +1,13 @@+defmodule Plausible.Repo.Migrations.TrafficDropNotifications do+ use Ecto.Migration++ def change do+ drop index(:spike_notifications, [:site_id])++ alter table(:spike_notifications) do+ add :type, :string, default: "spike"+ end++ create unique_index(:spike_notifications, [:site_id, :type])+ end+end