DT
Drizzle Team•12mo ago
xeon06

String default for integer timestamps?

Hey folks, I'm using Drizzle with SQLite on CloudFlare D1. Using the following column schema:
createdAt: integer("created_at", { mode: "timestamp" }).default(sql`CURRENT_TIMESTAMP`),
createdAt: integer("created_at", { mode: "timestamp" }).default(sql`CURRENT_TIMESTAMP`),
From the D1 database viewer I am seeing that Drizzle creates values that look like this 2024-01-03 03:55:45, whereas values inserted via direct SQL are integers properly e.g. 1703894400. In addition, the string values show up as NULL in Drizzle Studio. Could I be doing something wrong or have I encountered a bug?
7 Replies
Yuvaraj
Yuvaraj•12mo ago
I think you should use like this createdAt :timestamp('columnname').defaultNow()
xeon06
xeon06OP•12mo ago
SQLite doesn't have a timestamp type I'm starting to think this is a bug
Angelelz
Angelelz•12mo ago
SQLite? Isn't D1 Postgres?
xeon06
xeon06OP•12mo ago
No sir
xeon06
xeon06OP•12mo ago
Drizzle ORM - next gen TypeScript ORM
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
xeon06
xeon06OP•12mo ago
GitHub
[BUG]: Incorrect default value of integer timestamp fields with D1 ...
What version of drizzle-orm are you using? 0.29.2 What version of drizzle-kit are you using? 0.20.8 Describe the Bug Using CloudFlare D1, when inserting rows, columns with this type: createdAt: int...
Angelelz
Angelelz•12mo ago
My bad, I'll shut up 😂
Want results from more Discord servers?
Add your server