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

4 Likes

Agree. Can you open a PR changing this please?

3 Likes

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

MyPrepaidCenter

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 https://github.com/rails/rails/pull/41084

1 Like

That PR is building green now. Keen for feedback.