📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
added migration script from Swetrix Selfhosted v1 to v2
Blue Mousea039e0c68bdc
diff --git a/migrations/clickhouse/selfhosted_v1_to_v2.js b/migrations/clickhouse/selfhosted_v1_to_v2.jsnew file mode 100644index 000000000..742d1e053--- /dev/null+++ b/migrations/clickhouse/selfhosted_v1_to_v2.js@@ -0,0 +1,47 @@+const childProcess = require('child_process')+const path = require('path')++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()+ })+ })+}++async function runMigrations() {+ try {+ await runScript('./initialise_database.js')+ await runScript('./initialise_selfhosted.js')+ await runScript('./2022_12_24.js')+ await runScript('./2022_12_29.js')+ await runScript('./2023_02_09.js')+ await runScript('./2023_03_20.js')+ await runScript('./2023_04_25.js')+ await runScript('./2023_04_26.js')+ await runScript('./selfhosted_2023_04_29.js')++ console.log('[INFO] SELFHOSTED MIGRATIONS FINISHED')+ } catch (err) {+ console.error('Error running migration:', err)+ }+}++runMigrations()