diff --git a/ts/smartclickhouse.classes.timedatatable.ts b/ts/smartclickhouse.classes.timedatatable.ts index efd4be3..196efa3 100644 --- a/ts/smartclickhouse.classes.timedatatable.ts +++ b/ts/smartclickhouse.classes.timedatatable.ts @@ -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(`=======================`)