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 Mouse0928d41a0a63
diff --git a/backend/migrations/clickhouse/selfhosted_v3_to_v4.js b/backend/migrations/clickhouse/selfhosted_v3_to_v4.js
index 72595e329..cd06a3758 100644
--- a/backend/migrations/clickhouse/selfhosted_v3_to_v4.js
+++ b/backend/migrations/clickhouse/selfhosted_v3_to_v4.js
@@ -1,5 +1,32 @@
+const childProcess = require('child_process')
+const path = require('path')
const { queriesRunner, dbName } = require('./setup')
+function runScript(scriptPath) {
+ return new Promise((resolve, reject) => {
+ const fullPath = path.join(__dirname, scriptPath)
+ console.log('[INFO] Running script: ' + fullPath)
+
+ const process = childProcess.fork(fullPath)
+ let invoked = false
+
+ // listen for errors as they may prevent the exit event from firing
+ process.on('error', function (err) {
+ if (invoked) return
+ invoked = true
+ reject(err)
+ })
+
+ // execute the callback once the process has finished running
+ process.on('exit', function (code) {
+ if (invoked) return
+ invoked = true
+ const err = code === 0 ? null : new Error('exit code ' + code)
+ err ? reject(err) : resolve()
+ })
+ })
+}
+
const queries = [
`CREATE TABLE IF NOT EXISTS ${dbName}.user
(
@@ -37,6 +64,12 @@ const queries = [
async function runMigrations() {
try {
await queriesRunner(queries)
+ await runScript('./2025_01_09.js')
+ await runScript('./2025_02_08.js')
+ await runScript('./2025_04_16.js')
+ await runScript('./2025_05_17.js')
+ await runScript('./2025_05_23.js')
+
console.log('[INFO] SWETRIX CE V4 - MIGRATIONS FINISHED')
} catch (reason) {
console.error('Error running migration:', reason)