Skip to content

.tip

· one of the small things

Store time as timestamptz, never timestamp

timestamp without a zone stores whatever the client sent and forgets where it came from. Two servers in two regions write two different meanings into the same column, and nobody notices until a report is off by hours.

created_at timestamptz NOT NULL DEFAULT now()

timestamptz stores an instant. Convert it to a zone at the edge, in the query or the UI, and never in the schema.

postgresqlschema-design