Skip to content

Commit

Permalink
fix: incorrect timestamps in drizzle (t3-oss#1864)
Browse files Browse the repository at this point in the history
  • Loading branch information
szamanr committed May 7, 2024
1 parent cd6a6f5 commit 7f7f83d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ export const posts = createTable(
{
id: serial("id").primaryKey(),
name: varchar("name", { length: 256 }),
createdAt: timestamp("created_at")
createdAt: timestamp("created_at", { withTimezone: true })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp("updatedAt"),
updatedAt: timestamp("updatedAt", { withTimezone: true }),
},
(example) => ({
nameIndex: index("name_idx").on(example.name),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ export const posts = createTable(
createdById: varchar("createdById", { length: 255 })
.notNull()
.references(() => users.id),
createdAt: timestamp("created_at")
createdAt: timestamp("created_at", { withTimezone: true })
.default(sql`CURRENT_TIMESTAMP`)
.notNull(),
updatedAt: timestamp("updatedAt"),
updatedAt: timestamp("updatedAt", { withTimezone: true }),
},
(example) => ({
createdByIdIdx: index("createdById_idx").on(example.createdById),
Expand All @@ -44,6 +44,7 @@ export const users = createTable("user", {
email: varchar("email", { length: 255 }).notNull(),
emailVerified: timestamp("emailVerified", {
mode: "date",
withTimezone: true,
}).default(sql`CURRENT_TIMESTAMP`),
image: varchar("image", { length: 255 }),
});
Expand Down Expand Up @@ -92,7 +93,10 @@ export const sessions = createTable(
userId: varchar("userId", { length: 255 })
.notNull()
.references(() => users.id),
expires: timestamp("expires", { mode: "date" }).notNull(),
expires: timestamp("expires", {
mode: "date",
withTimezone: true,
}).notNull(),
},
(session) => ({
userIdIdx: index("session_userId_idx").on(session.userId),
Expand All @@ -108,7 +112,10 @@ export const verificationTokens = createTable(
{
identifier: varchar("identifier", { length: 255 }).notNull(),
token: varchar("token", { length: 255 }).notNull(),
expires: timestamp("expires", { mode: "date" }).notNull(),
expires: timestamp("expires", {
mode: "date",
withTimezone: true,
}).notNull(),
},
(vt) => ({
compoundKey: primaryKey({ columns: [vt.identifier, vt.token] }),
Expand Down

0 comments on commit 7f7f83d

Please sign in to comment.