Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

fix: migration for session replay

Carl-Gerhard Lindesvärd791668526caf
diff --git a/packages/db/code-migrations/10-add-session-replay.ts b/packages/db/code-migrations/10-add-session-replay.ts
index 21a1ceb72..964360333 100644
--- a/packages/db/code-migrations/10-add-session-replay.ts
+++ b/packages/db/code-migrations/10-add-session-replay.ts
@@ -2,7 +2,6 @@ import fs from 'node:fs';
import path from 'node:path';
import { TABLE_NAMES } from '../src/clickhouse/client';
import {
- addColumns,
createTable,
modifyTTL,
runClickhouseMigrationCommands,
@@ -25,8 +24,8 @@ export async function up() {
'`is_full_snapshot` Bool',
'`payload` String CODEC(ZSTD(6))',
],
- orderBy: ['project_id', 'session_id', 'chunk_index'],
- partitionBy: 'toYYYYMM(started_at)',
+ orderBy: ['project_id', 'session_id', 'started_at', 'chunk_index'],
+ partitionBy: 'toYYYYMMDD(started_at)',
settings: {
index_granularity: 8192,
},
@@ -42,16 +41,16 @@ export async function up() {
];
fs.writeFileSync(
- path.join(__filename.replace('.ts', '.sql')),
+ path.join(import.meta.filename.replace('.ts', '.sql')),
sqls
.map((sql) =>
sql
.trim()
.replace(/;$/, '')
.replace(/\n{2,}/g, '\n')
- .concat(';'),
+ .concat(';')
)
- .join('\n\n---\n\n'),
+ .join('\n\n---\n\n')
);
if (!process.argv.includes('--dry')) {