From 1a6f7786234718bf35917ac302c59f55f9e051b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lassi=20P=C3=B6l=C3=B6nen?= Date: Mon, 14 Sep 2015 13:41:29 +0300 Subject: [PATCH] Define time zone explicitly in postgresql connection string. --- builtin/logical/postgresql/backend.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/builtin/logical/postgresql/backend.go b/builtin/logical/postgresql/backend.go index caee8b31d2..e10b87824f 100644 --- a/builtin/logical/postgresql/backend.go +++ b/builtin/logical/postgresql/backend.go @@ -6,6 +6,7 @@ import ( "strings" "sync" + "github.com/lib/pq" "github.com/hashicorp/vault/logical" "github.com/hashicorp/vault/logical/framework" ) @@ -74,6 +75,16 @@ func (b *backend) DB(s logical.Storage) (*sql.DB, error) { return nil, err } + // Ensure timezone is set to UTC for all the conenctions + if strings.HasPrefix(conn, "postgres://") || strings.HasPrefix(conn, "postgresql://") { + var err error + conn, err = pq.ParseURL(conn) + if err != nil { + return nil, err + } + } + conn += " timezone=utc" + b.db, err = sql.Open("postgres", conn) if err != nil { return nil, err