Add timestamp index. Allow to add TimescaleDB after initial setup.
All checks were successful
Build Docker image / build (push) Successful in 1m13s
All checks were successful
Build Docker image / build (push) Successful in 1m13s
This commit is contained in:
parent
31f8b86515
commit
11792f8c53
1 changed files with 2 additions and 1 deletions
3
main.go
3
main.go
|
@ -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)
|
||||||
|
|
Loading…
Reference in a new issue