$defaultFn() for an ISO timestamp in a text() field set as NULL

Schema:
export const users = sqliteTable("user", {
id: text("id")
.primaryKey()
.$defaultFn(() => crypto.randomUUID()),
name: text("name"),
email: text("email").unique(),
createdAt: text('created_at').$defaultFn(() => new Date().toISOString()),
updatedAt: text('updated_at').$defaultFn(() => new Date().toISOString())
})
export const users = sqliteTable("user", {
id: text("id")
.primaryKey()
.$defaultFn(() => crypto.randomUUID()),
name: text("name"),
email: text("email").unique(),
createdAt: text('created_at').$defaultFn(() => new Date().toISOString()),
updatedAt: text('updated_at').$defaultFn(() => new Date().toISOString())
})
Im not sure why but when a new user is created, Turso will leave the both createdAt and updatedAt columns as "NULL" although I've set my default function as above.
No description
1 Reply
amianthus
amianthusOP2mo ago
Actually I've just noticed that none of my default() functions work properly profile pictures: if google oauth doesnt return a response then it will leave the cell NULL even though the default is set image: text('image').default('https://i.imgur.com/[...].png'),

Did you find this page helpful?