© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Drizzle TeamDT
Drizzle Team•2y ago
jsingleton37

Properly setting timestamp column

I just want to make sure that I am properly setting the
timestamp
timestamp
to match some data that I am getting. This is what my schema looks like:

export const weeksTable = pgTable(
  'weeks',
  {
    id: serial('id').primaryKey(),
    seasonId: integer('seasonId')
      .notNull()
      .references(() => seasonsTable.id),
    week: integer('week').notNull(),
    start: timestamp('start', { mode: 'string' }).notNull(),
    end: timestamp('end', { mode: 'string' }).notNull(),
  },
  (table) => ({
    isUniqueWeek: unique().on(table.seasonId, table.week),
  }),
)
export const weeksTable = pgTable(
  'weeks',
  {
    id: serial('id').primaryKey(),
    seasonId: integer('seasonId')
      .notNull()
      .references(() => seasonsTable.id),
    week: integer('week').notNull(),
    start: timestamp('start', { mode: 'string' }).notNull(),
    end: timestamp('end', { mode: 'string' }).notNull(),
  },
  (table) => ({
    isUniqueWeek: unique().on(table.seasonId, table.week),
  }),
)


and the data I want to store looks like the code snippet attached. I believe they are all using UTC, so would my
timestamp
timestamp
need to be updated to be :

timestamp('start', { mode: 'string' }).notNull().default(sql`extract(epoch from now())`)
timestamp('start', { mode: 'string' }).notNull().default(sql`extract(epoch from now())`)


Right now I am just manually inserting the data into Supabase's UI, but I should probably write a script or something 😅 since pasting the timestamp does not work in Supabase's UI
image.png
Drizzle TeamJoin
The official Discord for all Drizzle related projects, such as Drizzle ORM, Drizzle Kit, Drizzle Studio and more!
11,879Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Issue with filtering on timestamp column
Drizzle TeamDTDrizzle Team / help
2y ago
Setting default timestamp in user table
Drizzle TeamDTDrizzle Team / help
2y ago
Correct setting for PostgreSQL timestamp storing UTC value
Drizzle TeamDTDrizzle Team / help
9mo ago
Altering existing table with Timestamp column to Timestamp with Timezone in Postgres using Drizzle
Drizzle TeamDTDrizzle Team / help
2y ago