Add timestamp index. Allow to add TimescaleDB after initial setup.
All checks were successful
Build Docker image / build (push) Successful in 1m13s

This commit is contained in:
Pieter Hollander 2024-02-21 11:17:09 +01:00
parent 31f8b86515
commit 11792f8c53
Signed by: pieter
SSH key fingerprint: SHA256:HbX+9cBXsop9SuvL+mELd29sK+7DehFfdVweFVDtMSg

View file

@ -341,6 +341,7 @@ func connectToPostgreSQL(pgConnStr string) error {
returning_l2 INT, returning_l2 INT,
returning_l3 INT returning_l3 INT
); );
CREATE UNIQUE INDEX IF NOT EXISTS timestamp_idx ON log (timestamp);
`) `)
if err != nil { if err != nil {
log.Fatal("Error creating table:", err) log.Fatal("Error creating table:", err)
@ -352,7 +353,7 @@ func connectToPostgreSQL(pgConnStr string) error {
// Enable TimescaleDB // Enable TimescaleDB
_, err = db.Exec(` _, err = db.Exec(`
CREATE EXTENSION IF NOT EXISTS timescaledb; 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 { if err != nil {
log.Fatal("Error creating TimescaleDB extension:", err) log.Fatal("Error creating TimescaleDB extension:", err)