diff --git a/cli/template/extras/src/server/db/schema-drizzle/base-postgres.ts b/cli/template/extras/src/server/db/schema-drizzle/base-postgres.ts index 7e7d62a3cd..83dfb6c37b 100644 --- a/cli/template/extras/src/server/db/schema-drizzle/base-postgres.ts +++ b/cli/template/extras/src/server/db/schema-drizzle/base-postgres.ts @@ -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), diff --git a/cli/template/extras/src/server/db/schema-drizzle/with-auth-postgres.ts b/cli/template/extras/src/server/db/schema-drizzle/with-auth-postgres.ts index 7733f4f17b..395e467696 100644 --- a/cli/template/extras/src/server/db/schema-drizzle/with-auth-postgres.ts +++ b/cli/template/extras/src/server/db/schema-drizzle/with-auth-postgres.ts @@ -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), @@ -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 }), }); @@ -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), @@ -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] }),