Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

add missing migrations

Blue Mouse015a0cececb3
diff --git a/backend/migrations/clickhouse/2025_12_08_feature_flags.js b/backend/migrations/clickhouse/2025_12_08_feature_flags.js
index cd1ae6a16..5533f6e3b 100644
--- a/backend/migrations/clickhouse/2025_12_08_feature_flags.js
+++ b/backend/migrations/clickhouse/2025_12_08_feature_flags.js
@@ -1,7 +1,6 @@
const { queriesRunner, dbName } = require('./setup')
const queries = [
- // Create feature_flag_evaluations table for tracking flag evaluations
`CREATE TABLE IF NOT EXISTS ${dbName}.feature_flag_evaluations
(
pid FixedString(12),
diff --git a/backend/migrations/clickhouse/2025_12_11_experiments.js b/backend/migrations/clickhouse/2025_12_11_experiments.js
index 7be7e676b..7e1e0498d 100644
--- a/backend/migrations/clickhouse/2025_12_11_experiments.js
+++ b/backend/migrations/clickhouse/2025_12_11_experiments.js
@@ -1,7 +1,7 @@
const { queriesRunner, dbName } = require('./setup')
const queries = [
- // Create experiment_exposures table for tracking which variant each user sees
+ // Experiment exposures table for tracking which variant each user sees
`CREATE TABLE IF NOT EXISTS ${dbName}.experiment_exposures
(
pid FixedString(12),
diff --git a/backend/migrations/clickhouse/initialise_database.js b/backend/migrations/clickhouse/initialise_database.js
index 7eba14816..795311b9e 100644
--- a/backend/migrations/clickhouse/initialise_database.js
+++ b/backend/migrations/clickhouse/initialise_database.js
@@ -163,6 +163,48 @@ const CLICKHOUSE_INIT_QUERIES = [
ORDER BY (pid, psid)
PARTITION BY toYYYYMM(firstSeen);`,
+ // Session duration table
+ `CREATE TABLE IF NOT EXISTS ${dbName}.sessions
+ (
+ psid UInt64,
+ pid FixedString(12),
+ profileId Nullable(String),
+ firstSeen DateTime('UTC'),
+ lastSeen DateTime('UTC')
+ )
+ ENGINE = ReplacingMergeTree(lastSeen)
+ ORDER BY (pid, psid)
+ PARTITION BY toYYYYMM(firstSeen);`,
+
+ // Feature flag evaluations table
+ `CREATE TABLE IF NOT EXISTS ${dbName}.feature_flag_evaluations
+ (
+ pid FixedString(12),
+ flagId String,
+ flagKey String,
+ result UInt8,
+ profileId String,
+ created DateTime('UTC')
+ )
+ ENGINE = MergeTree()
+ PARTITION BY toYYYYMM(created)
+ ORDER BY (pid, flagId, created)
+ TTL created + INTERVAL 1 YEAR;`,
+
+ // Experiment exposures table for tracking which variant each user sees
+ `CREATE TABLE IF NOT EXISTS ${dbName}.experiment_exposures
+ (
+ pid FixedString(12),
+ experimentId String,
+ variantKey String,
+ profileId String,
+ created DateTime('UTC')
+ )
+ ENGINE = MergeTree()
+ PARTITION BY toYYYYMM(created)
+ ORDER BY (pid, experimentId, created)
+ TTL created + INTERVAL 1 YEAR;`,
+
// The CAPTCHA data table
`CREATE TABLE IF NOT EXISTS ${dbName}.captcha
(