Skip to content

Commit

Permalink
Force PostgreSQL timestamps to UTC.
Browse files Browse the repository at this point in the history
  • Loading branch information
TallJimbo committed Nov 26, 2020
1 parent 1cc2db8 commit 5fab3bd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/lsst/daf/butler/registry/databases/postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ def transaction(self, *, interrupting: bool = False, savepoint: bool = False,
if not self.isWriteable():
with closing(self._connection.connection.cursor()) as cursor:
cursor.execute("SET TRANSACTION READ ONLY")
else:
with closing(self._connection.connection.cursor()) as cursor:
# Make timestamps UTC, because we didn't use TIMESTAMPZ for
# the column type. When we can tolerate a schema change,
# we should change that type and remove this line.
cursor.execute("SET TIME ZONE 0")
yield

def _lockTables(self, tables: Iterable[sqlalchemy.schema.Table] = ()) -> None:
Expand Down

0 comments on commit 5fab3bd

Please sign in to comment.