Skip to content

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

Ecto migration to move sessions_v2 to VersionedCollapsingMergeTree (#3809)

Karl-Aksel Puulmannea38b4568515
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d10d417942..d4cf7dc41c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -45,6 +45,7 @@ All notable changes to this project will be documented in this file.
- Replace `CLICKHOUSE_MAX_BUFFER_SIZE` with `CLICKHOUSE_MAX_BUFFER_SIZE_BYTES`
### Fixed
+- Using `VersionedCollapsingMergeTree` to store visit data to avoid rare race conditions that led to wrong visit data being shown
- Fix `conversion_rate` metric in a `browser_versions` breakdown
- Calculate `conversion_rate` percentage change in the same way like `bounce_rate` (subtraction instead of division)
- Calculate `bounce_rate` percentage change in the Stats API in the same way as it's done in the dashboard
diff --git a/priv/ingest_repo/migrations/20240222082911_sessions_v2_versioned_collapsing_merge_tree.exs b/priv/ingest_repo/migrations/20240222082911_sessions_v2_versioned_collapsing_merge_tree.exs
new file mode 100644
index 0000000000..6047eff091
--- /dev/null
+++ b/priv/ingest_repo/migrations/20240222082911_sessions_v2_versioned_collapsing_merge_tree.exs
@@ -0,0 +1,13 @@
+defmodule Plausible.IngestRepo.Migrations.SessionsV2VersionedCollapsingMergeTree do
+ use Ecto.Migration
+
+ def up do
+ Plausible.DataMigration.VersionedSessions.run(run_exchange?: true)
+
+ # After this migration a `sessions_v2_tmp_versioned` backup table is left behind, to be cleaned up manually
+ end
+
+ def down do
+ raise "Irreversible"
+ end
+end