Overwriting Schema Defaults
await database.insert(users).values([
{
name: ADMIN_NAME!,
slug: ADMIN_SLUG!,
email: ADMIN_EMAIL!,
password: ADMIN_PASSWORD!,
role: 'ADMIN',
active: true
}
])await database.insert(users).values([
{
name: ADMIN_NAME!,
slug: ADMIN_SLUG!,
email: ADMIN_EMAIL!,
password: ADMIN_PASSWORD!,
role: 'ADMIN',
active: true
}
])the
values functionvalues function is marked with an error, because I set role and active, which already have a value due to their default value in the schema.What can I do about that?
export const users = pgTable('users', {
id: uuid('id').primaryKey().defaultRandom(),
name: varchar('name', { length: 256 }).notNull(),
slug: varchar('slug', { length: 256 }).notNull().unique(),
biography: text('biography'),
email: varchar('email', { length: 256 }).notNull(),
password: varchar('password', { length: 256 }).notNull(),
role: role('role').notNull().default('STANDARD'),
active: boolean('active').notNull().default(false),
createdAt: timestamp('created_at').notNull().defaultNow(),
updatedAt: timestamp('updated_at').notNull().defaultNow()
})export const users = pgTable('users', {
id: uuid('id').primaryKey().defaultRandom(),
name: varchar('name', { length: 256 }).notNull(),
slug: varchar('slug', { length: 256 }).notNull().unique(),
biography: text('biography'),
email: varchar('email', { length: 256 }).notNull(),
password: varchar('password', { length: 256 }).notNull(),
role: role('role').notNull().default('STANDARD'),
active: boolean('active').notNull().default(false),
createdAt: timestamp('created_at').notNull().defaultNow(),
updatedAt: timestamp('updated_at').notNull().defaultNow()
})Thank you.
Timo