Fetching contributors…
Cannot retrieve contributors at this time
35 lines (32 sloc) 1.37 KB
-- Enforce UTC
-- ===========
-- The production db is already in UTC (presumably per postgresql.conf). We
-- need local dev dbs to also use UTC, but we don't want to make users edit
-- postgresql.conf themselves, nor do we want to clutter schema.sql with this,
-- nor do we want to do it in the application layer per-session. So it's here
-- instead, and is applied in From the docs on ALTER DATABASE:
-- The remaining forms change the session default for a run-time
-- configuration variable for a PostgreSQL database. Whenever a new
-- session is subsequently started in that database, the specified value
-- becomes the session default value. The database-specific default
-- overrides whatever setting is present in postgresql.conf or has been
-- received from the postgres command line."
-- See also:
-- "Time Zones"
-- "Setting Parameters"
-- "How can I execute ALTER DATABASE $current_database in PostgreSQL"
DO $$
ALTER DATABASE "' || current_database() || '" SET timezone TO ''UTC'' ';
END; $$;