aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet.pm
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2018-03-26 13:37:15 +0100
committerMatthew Somerville <matthew-github@dracos.co.uk>2018-03-27 11:20:22 +0100
commitd959ce5f2e3e3eebab7a65beec183d1c541c3902 (patch)
tree71f14866abba8a67a75268ed677898b6a734014f /perllib/FixMyStreet.pm
parent2435ed88f9865e4f4f4e014d08f24e0654f47399 (diff)
Set database session timezone on connection.
fixmystreet.com went down early Sunday morning because the database server had been upgraded in the past year and was now set to UTC and not local time. This confused the codebase when it encountered timestamps that could not exist, all between 1-2am UTC. Ideally, timestamps in the database should be 'with time zone' or be stored in UTC, but for now let us set the time zone to the local one upon connection.
Diffstat (limited to 'perllib/FixMyStreet.pm')
-rw-r--r--perllib/FixMyStreet.pm7
1 files changed, 6 insertions, 1 deletions
diff --git a/perllib/FixMyStreet.pm b/perllib/FixMyStreet.pm
index b30f59472..c8d22fe50 100644
--- a/perllib/FixMyStreet.pm
+++ b/perllib/FixMyStreet.pm
@@ -154,7 +154,12 @@ sub dbic_connect_info {
AutoCommit => 1,
pg_enable_utf8 => 1,
};
- my $dbic_args = {};
+ my $local_time_zone = local_time_zone();
+ my $dbic_args = {
+ on_connect_do => [
+ "SET TIME ZONE '" . $local_time_zone->name . "'",
+ ],
+ };
return ( $dsn, $user, $password, $dbi_args, $dbic_args );
}