Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: timestamps are not stored as UTC when using drizzle and postgres #1863

Closed
szamanr opened this issue May 1, 2024 · 1 comment · Fixed by #1864
Closed

bug: timestamps are not stored as UTC when using drizzle and postgres #1863

szamanr opened this issue May 1, 2024 · 1 comment · Fixed by #1864

Comments

@szamanr
Copy link
Contributor

szamanr commented May 1, 2024

Provide environment information

  System:
    OS: Linux 6.5 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
    CPU: (12) x64 13th Gen Intel(R) Core(TM) i7-1355U
    Memory: 18.35 GB / 31.01 GB
    Container: Yes
    Shell: 3.7.1 - /usr/bin/fish
  Binaries:
    Node: 18.18.2 - ~/.local/share/nvm/v18.18.2/bin/node
    Yarn: 1.22.19 - ~/.local/share/nvm/v18.18.2/bin/yarn
    npm: 9.8.1 - ~/.local/share/nvm/v18.18.2/bin/npm
    pnpm: 8.10.5 - ~/.local/share/nvm/v18.18.2/bin/pnpm
    bun: 1.1.3 - ~/.bun/bin/bun

Describe the bug

using the auto-generated app with drizzle and postgres, when i create a post at 9:00 CEST (7:00 UTC), and inspect the database, the created_at timestamp actually shows 05:00:xx.xxxZ, so 2 hours before UTC. same thing for the updatedAt field (after adding api to update posts).

changing the drizzle data type to include timezone fixes the issue: timestamp("created_at", { withTimezone: true })

Reproduction repo

To reproduce

  1. set up the app and run it
  2. add a post
  3. inspect the created_at timestamp, e.g. in drizzle studio

Additional information

No response

@szamanr szamanr changed the title bug: timestamps are not stored as UTC bug: timestamps are not stored as UTC when using drizzle May 1, 2024
@szamanr szamanr changed the title bug: timestamps are not stored as UTC when using drizzle bug: timestamps are not stored as UTC when using drizzle and postgres May 1, 2024
@szamanr
Copy link
Contributor Author

szamanr commented May 1, 2024

possibly a bug in drizzle? i see a similar-sounding bug fix in v0.30, whereas t3 app uses v0.29:

https://github.com/drizzle-team/drizzle-orm/releases/tag/0.30.0

[BUG]: invalid timestamp conversion when using PostgreSQL with TimeZone set to UTC

EDIT: after upgrading drizzle, the issue still occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant