Skip to content

Commit 995e1c2

Browse files
committed
fix: ERROR: relation "cache" does not exist at character 16
1 parent 1a72cbd commit 995e1c2

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

storage/database.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package storage
22

33
import (
44
"context"
5+
"fmt"
56
"time"
67

78
"github.com/jackc/pgx/v5"
@@ -19,6 +20,20 @@ func NewDatabaseStorage(dsn string) (*DatabaseStorage, error) {
1920
if err != nil {
2021
return nil, err
2122
}
23+
24+
// Ensure the cache table exists
25+
_, err = pool.Exec(ctx, `
26+
CREATE TABLE IF NOT EXISTS cache (
27+
key VARCHAR(255) PRIMARY KEY,
28+
value TEXT,
29+
expires_at TIMESTAMPTZ
30+
)
31+
`)
32+
if err != nil {
33+
pool.Close()
34+
return nil, fmt.Errorf("failed to create cache table: %w", err)
35+
}
36+
2237
return &DatabaseStorage{pool: pool}, nil
2338
}
2439

0 commit comments

Comments
 (0)