diff --git a/main.go b/main.go index 750c375..6932561 100644 --- a/main.go +++ b/main.go @@ -341,6 +341,7 @@ func connectToPostgreSQL(pgConnStr string) error { returning_l2 INT, returning_l3 INT ); + CREATE UNIQUE INDEX IF NOT EXISTS timestamp_idx ON log (timestamp); `) if err != nil { log.Fatal("Error creating table:", err) @@ -352,7 +353,7 @@ func connectToPostgreSQL(pgConnStr string) error { // Enable TimescaleDB _, err = db.Exec(` CREATE EXTENSION IF NOT EXISTS timescaledb; - SELECT create_hypertable('p1', 'timestamp', if_not_exists => TRUE); + SELECT create_hypertable('p1', 'timestamp', if_not_exists => TRUE), migrate_data => TRUE; `) if err != nil { log.Fatal("Error creating TimescaleDB extension:", err)