fix(TTL): tables now have a default TTL for data of 1 MONTH

This commit is contained in:
Philipp Kunz 2022-03-08 18:54:10 +01:00
parent 4417c880b6
commit 3034ef2edd

View File

@ -32,10 +32,18 @@ export class TimeDataTable {
// create table in clickhouse // create table in clickhouse
await smartClickHouseDbRefArg.clickhouseClient await smartClickHouseDbRefArg.clickhouseClient
.queryPromise(`CREATE TABLE IF NOT EXISTS ${newTable.tableName} ( .queryPromise(`
timestamp DateTime64(3, 'Europe/Berlin'), CREATE TABLE IF NOT EXISTS ${newTable.tableName} (
message String timestamp DateTime64(3, 'Europe/Berlin'),
) ENGINE=MergeTree() ORDER BY timestamp`); message String
) ENGINE=MergeTree() ORDER BY timestamp
`);
// lets adjust the TTL
await smartClickHouseDbRefArg.clickhouseClient
.queryPromise(`
ALTER TABLE ${newTable.tableName} MODIFY TTL toDateTime(timestamp) + INTERVAL 1 MONTH;
`);
await newTable.updateColumns(); await newTable.updateColumns();
console.log(`=======================`) console.log(`=======================`)