* wip * wip * wip * wip * show revenue better on overview * align realtime and overview counters * update revenue docs * always return device id * add project settings, improve projects charts, * fix: comments * fixes * fix migration * ignore sql files * fix comments
37 lines
761 B
TypeScript
37 lines
761 B
TypeScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import {
|
|
addColumns,
|
|
runClickhouseMigrationCommands,
|
|
} from '../src/clickhouse/migration';
|
|
import { getIsCluster } from './helpers';
|
|
|
|
export async function up() {
|
|
const isClustered = getIsCluster();
|
|
|
|
const sqls: string[] = [
|
|
...addColumns(
|
|
'events',
|
|
['`revenue` UInt64 AFTER `referrer_type`'],
|
|
isClustered,
|
|
),
|
|
];
|
|
|
|
fs.writeFileSync(
|
|
path.join(__filename.replace('.ts', '.sql')),
|
|
sqls
|
|
.map((sql) =>
|
|
sql
|
|
.trim()
|
|
.replace(/;$/, '')
|
|
.replace(/\n{2,}/g, '\n')
|
|
.concat(';'),
|
|
)
|
|
.join('\n\n---\n\n'),
|
|
);
|
|
|
|
if (!process.argv.includes('--dry')) {
|
|
await runClickhouseMigrationCommands(sqls);
|
|
}
|
|
}
|