Skip to content

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

Migration to add `tracker_script_version` to ingest_counters table (#5202)

Karl-Aksel Puulmann71e5c46e8387
diff --git a/priv/ingest_repo/migrations/20250316182725_ingest_counters_tracker_script_version.exs b/priv/ingest_repo/migrations/20250316182725_ingest_counters_tracker_script_version.exs
new file mode 100644
index 0000000000..7217f2b01c
--- /dev/null
+++ b/priv/ingest_repo/migrations/20250316182725_ingest_counters_tracker_script_version.exs
@@ -0,0 +1,14 @@
+defmodule Plausible.IngestRepo.Migrations.IngestCountersTrackerScriptVersion do
+ use Ecto.Migration
+
+ def change do
+ on_cluster = Plausible.MigrationUtils.on_cluster_statement("ingest_counters")
+
+ execute """
+ ALTER TABLE ingest_counters
+ #{on_cluster}
+ ADD COLUMN IF NOT EXISTS tracker_script_version UInt16,
+ MODIFY ORDER BY (domain, toDate(event_timebucket), metric, toStartOfMinute(event_timebucket), tracker_script_version)
+ """
+ end
+end