Postgres timestampz by default in Rails 6.2

Reviving discussion from timestamp schema migration on postgres doesn't include timezone · Issue #21126 · rails/rails · GitHub

Rails 6.2 should use timestampz as the default Postgres field type for datetime and timestamp.

see Don't Do This - PostgreSQL wiki

timestamp without zone (current default)

2016-06-03 15:06:35

can be converted to whatever timezone as appropriate. e.g. (('2016-06-03 15:06:35'::timestamp AT TIME ZONE 'UTC') AT TIME ZONE 'America/Chicago') type of casting.

but timestamp with zone (timestampz) is like

2016-06-03 15:06:35+00

which includes the zone +00, and is stored as an offset from the epoch as opposed to without any context. I can’t see why this would be at all problematic unless perhaps you’re working with systems which can’t handle that

cc @rafaelfranca


Agree. Can you open a PR changing this please?


I faced similar kind of issue last time, I am still searching for some proper solution Same issue still no fix to this.


I mean, Rails-core said please open a PR. There are also plenty of solutions out there. So… yes, there are two possible fixes available: your app and PR to Rails. Let’s not derail this thread please by responding asking for help how to do it.

Ooh, someone made a PR Change default PostgreSQL datetime format to `timestamp with time zone` by ghiculescu · Pull Request #41084 · rails/rails · GitHub

1 Like

That PR is building green now. Keen for feedback.