Closed bingtsingw closed 1 year ago
If you believe that there are no issues with this design, I can assist with its implementation as writing it doesn't seem too difficult.
In fact, initially, it was without time zone, but then I read what postgres suggests and changed all timestamps to be with time zone by default.
Could you elaborate on why having timestamps without a timezone is important?
Postgres naming brings a lot of confusion, I guess it's by historical reasons, so you can have timestamp
which doesn't store timezone, and timestamps with timezone
which also doesn't store the timezone, but works slightly differently, and it's confusing.
I think that having only timestamps()
that are with timezone is enough and no need for other methods.
I did see the suggests in the doc, but I'm used to saving all time as UTC
in all of my systems, I already have a lot of projects running this way, I'm not going to change all tables to timestampTz
for now, that would be tons of work.
In fact, initially, it was without time zone, but then I read what postgres suggests and changed all timestamps to be with time zone by default.
Could you elaborate on why having timestamps without a timezone is important?
Postgres naming brings a lot of confusion, I guess it's by historical reasons, so you can have
timestamp
which doesn't store timezone, andtimestamps with timezone
which also doesn't store the timezone, but works slightly differently, and it's confusing.
That's interesting, I'm not very familiar with posgres
's internal design, I'll do some research.
Maybe let's rename existing timestampWithoutTimeZone
to timestmapNoTz
and then add timestampsNoTz
and timestampsNoTzSnakeCase
, how do you think?
Because if used extensively, I'm afraid that such timestampWithoutTimeZone
will add much visual noise to the code.
I tend to use method parameters because it allows for better combination and scalability. However, I think adding function implementations and explicitly using function names to distinguish functionality is also acceptable.
Anyway, NoTz
is very nice.
Ready: renamed it to timestampNoTZ
, added timestampsNoTZ
and timestampsNoTZSnakeCase
methods for updatedAt
and createdAt
.
I'd like to have the
t.timestamps()
to also supportwithoutTimeZone
, add an extratimestampsWithoutTimeZone
function is easy, but it seems we should addtimestampsWithoutTimeZoneSnakeCase
also, that's amazing api design.So, I suggest to have only one
timestamps()
method which can accept optional parameters to configure it's behavior:Then we can remove
t.timestampsSnakeCase()