()
| 9 | import { getIsCluster } from './helpers'; |
| 10 | |
| 11 | export async function up() { |
| 12 | const isClustered = getIsCluster(); |
| 13 | |
| 14 | const sqls: string[] = [ |
| 15 | ...addColumns( |
| 16 | 'events', |
| 17 | ['`groups` Array(String) DEFAULT [] CODEC(ZSTD(3)) AFTER session_id'], |
| 18 | isClustered |
| 19 | ), |
| 20 | ...addColumns( |
| 21 | 'sessions', |
| 22 | ['`groups` Array(String) DEFAULT [] CODEC(ZSTD(3)) AFTER device_id'], |
| 23 | isClustered |
| 24 | ), |
| 25 | ...addColumns( |
| 26 | 'profiles', |
| 27 | ['`groups` Array(String) DEFAULT [] CODEC(ZSTD(3)) AFTER project_id'], |
| 28 | isClustered |
| 29 | ), |
| 30 | ...createTable({ |
| 31 | name: TABLE_NAMES.groups, |
| 32 | columns: [ |
| 33 | '`id` String', |
| 34 | '`project_id` String', |
| 35 | '`type` String', |
| 36 | '`name` String', |
| 37 | '`properties` Map(String, String)', |
| 38 | '`created_at` DateTime', |
| 39 | '`version` UInt64', |
| 40 | '`deleted` UInt8 DEFAULT 0', |
| 41 | ], |
| 42 | engine: 'ReplacingMergeTree(version, deleted)', |
| 43 | orderBy: ['project_id', 'id'], |
| 44 | distributionHash: 'cityHash64(project_id, id)', |
| 45 | replicatedVersion: '1', |
| 46 | isClustered, |
| 47 | }), |
| 48 | ]; |
| 49 | |
| 50 | fs.writeFileSync( |
| 51 | path.join(import.meta.filename.replace('.ts', '.sql')), |
| 52 | sqls |
| 53 | .map((sql) => |
| 54 | sql |
| 55 | .trim() |
| 56 | .replace(/;$/, '') |
| 57 | .replace(/\n{2,}/g, '\n') |
| 58 | .concat(';') |
| 59 | ) |
| 60 | .join('\n\n---\n\n') |
| 61 | ); |
| 62 | |
| 63 | if (!process.argv.includes('--dry')) { |
| 64 | await runClickhouseMigrationCommands(sqls); |
| 65 | } |
| 66 | } |
nothing calls this directly
no test coverage detected