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!

CH structure update

Blue Mouseac2d2b7880b5
diff --git a/migrations/clickhouse/initialise_selfhosted.js b/migrations/clickhouse/initialise_selfhosted.js
index 56bddc451..282bd7f44 100644
--- a/migrations/clickhouse/initialise_selfhosted.js
+++ b/migrations/clickhouse/initialise_selfhosted.js
@@ -7,7 +7,8 @@ const CLICKHOUSE_INIT_QUERIES = [
(
id FixedString(12),
name String,
- origins String,
+ origins Nullable(String),
+ ipBlacklist Nullable(String),
active Int8,
public Int8,
created DateTime
diff --git a/migrations/clickhouse/selfhosted_2023_04_29.js b/migrations/clickhouse/selfhosted_2023_04_29.js
new file mode 100644
index 000000000..d29cf032e
--- /dev/null
+++ b/migrations/clickhouse/selfhosted_2023_04_29.js
@@ -0,0 +1,27 @@
+const { queriesRunner, dbName } = require('./setup')
+
+const queries = [
+ // Added 'prev' column
+ `DROP TABLE IF EXISTS ${dbName}.project_temp`,
+ `CREATE TABLE IF NOT EXISTS ${dbName}.project_temp
+ (
+ id FixedString(12),
+ name String,
+ origins Nullable(String),
+ ipBlacklist Nullable(String),
+ active Int8,
+ public Int8,
+ created DateTime
+ )
+ ENGINE = MergeTree()
+ PARTITION BY toYYYYMM(created)
+ ORDER BY (created);`,
+
+ `INSERT INTO ${dbName}.project_temp (id, name, origins, ipBlacklist, active, public, created)
+ SELECT id, name, origins, NULL, active, public, created FROM ${dbName}.project`,
+
+ `DROP TABLE ${dbName}.project`,
+ `RENAME TABLE ${dbName}.project_temp TO ${dbName}.project`,
+]
+
+queriesRunner(queries)