Fix db error .
All checks were successful
Build Docker image / build (push) Successful in 47s

This commit is contained in:
Pieter Hollander 2023-12-05 18:04:49 +01:00
parent fe1d1b5635
commit 7d04a97109
Signed by: pieter
SSH key fingerprint: SHA256:HbX+9cBXsop9SuvL+mELd29sK+7DehFfdVweFVDtMSg

11
main.go
View file

@ -48,16 +48,17 @@ func main() {
// Connect to PostgreSQL // Connect to PostgreSQL
pgConnStr := os.Getenv("PG_DB") pgConnStr := os.Getenv("PG_DB")
db, err := sql.Open("postgres", pgConnStr) var err error
db, err = sql.Open("postgres", pgConnStr)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
defer db.Close() defer db.Close()
// Enable TimescaleDB // Enable TimescaleDB
_, err = db.Exec(` // _, err = db.Exec(`
CREATE EXTENSION IF NOT EXISTS timescaledb; // CREATE EXTENSION IF NOT EXISTS timescaledb;
`) // `)
if err != nil { if err != nil {
log.Fatal("Error creating TimescaleDB extension:", err) log.Fatal("Error creating TimescaleDB extension:", err)
} }
@ -88,7 +89,7 @@ func main() {
returning_l2 INT, returning_l2 INT,
returning_l3 INT returning_l3 INT
); );
SELECT create_hypertable('p1', 'timestamp', if_not_exists => TRUE); -- SELECT create_hypertable('p1', 'timestamp', if_not_exists => TRUE);
`) `)
if err != nil { if err != nil {
log.Fatal("Error creating table:", err) log.Fatal("Error creating table:", err)