Properly setting timestamp column

I just want to make sure that I am properly setting the 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 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
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server