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
await smartClickHouseDbRefArg.clickhouseClient
.queryPromise(`CREATE TABLE IF NOT EXISTS ${newTable.tableName} (
timestamp DateTime64(3, 'Europe/Berlin'),
message String
) ENGINE=MergeTree() ORDER BY timestamp`);
.queryPromise(`
CREATE TABLE IF NOT EXISTS ${newTable.tableName} (
timestamp DateTime64(3, 'Europe/Berlin'),
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();
console.log(`=======================`)