Cannot insert rows with drizzle

I have the following schema
export const user = pgTable(
  'User',
  {
    username: varchar('username', { length: 50 }).notNull(),
    password: varchar('password', { length: 255 }).notNull(),
    id: uuid('id').primaryKey().notNull().defaultRandom(),
  },
  (table) => {
    return {
      usernameKey: uniqueIndex('User_username_key').on(table.username),
    }
  },
)


and I am trying to seed my database with test rows like this
import { db } from './db'
import { user } from './schema'
import { hash } from 'bcrypt'

async function main() {
  try {
    console.log('Seeding database')
    const password = await hash('password', 10)
    const insertedUser = await db
      .insert(user)
      .values({
        username: 'jorge',
        password,
      })
      .returning()
      .execute()
    console.log('Database seeded')
  } catch (e) {
    console.error('Error seeding database', e)
  }
}

;(async () => {
  await main()
})()

However, it seems like it does not get past the insert as the "Database seeded" message is never logged in the console. Is there something I am doing wrong?
Was this page helpful?