Skip to content

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

Clickhouse migration: add ingest_counters table (#2692)

Adam Rutkowski043e3ed572f1
diff --git a/priv/ingest_repo/migrations/20230214114402_create_ingest_counters_table.exs b/priv/ingest_repo/migrations/20230214114402_create_ingest_counters_table.exs
new file mode 100644
index 0000000000..231db40dc3
--- /dev/null
+++ b/priv/ingest_repo/migrations/20230214114402_create_ingest_counters_table.exs
@@ -0,0 +1,15 @@
+defmodule Plausible.IngestRepo.Migrations.CreateIngestCountersTable do
+ use Ecto.Migration
+
+ def change do
+ create_if_not_exists table(:ingest_counters,
+ engine: "SummingMergeTree(value) ORDER BY (domain, toDate(event_timebucket), metric, toStartOfMinute(event_timebucket))") do
+
+ add(:event_timebucket, :utc_datetime)
+ add(:domain, :"LowCardinality(String)")
+ add(:site_id, :"Nullable(UInt64)")
+ add(:metric, :"LowCardinality(String)")
+ add(:value, :UInt64)
+ end
+ end
+end