sorting key support, clickhouse recreate table support

This commit is contained in:
Jan Prochazka
2024-09-12 11:59:03 +02:00
parent 670cfb9dc0
commit 2f1cbbd75e
8 changed files with 116 additions and 32 deletions

View File

@@ -27,6 +27,7 @@ export interface TableInfoYaml {
// schema?: string;
columns: ColumnInfoYaml[];
primaryKey?: string[];
sortingKey?: string[];
insertKey?: string[];
insertOnly?: string[];
@@ -91,6 +92,9 @@ export function tableInfoToYaml(table: TableInfo): TableInfoYaml {
if (tableCopy.primaryKey && !tableCopy.primaryKey['_dumped']) {
res.primaryKey = tableCopy.primaryKey.columns.map(x => x.columnName);
}
if (tableCopy.sortingKey && !tableCopy.sortingKey['_dumped']) {
res.sortingKey = tableCopy.sortingKey.columns.map(x => x.columnName);
}
// const foreignKeys = (tableCopy.foreignKeys || []).filter(x => !x['_dumped']).map(foreignKeyInfoToYaml);
return res;
}
@@ -132,6 +136,13 @@ export function tableInfoFromYaml(table: TableInfoYaml, allTables: TableInfoYaml
columns: table.primaryKey.map(columnName => ({ columnName })),
};
}
if (table.sortingKey) {
res.sortingKey = {
pureName: table.name,
constraintType: 'sortingKey',
columns: table.sortingKey.map(columnName => ({ columnName })),
};
}
res.preloadedRows = table.data;
res.preloadedRowsKey = table.insertKey;
res.preloadedRowsInsertOnly = table.insertOnly;