react-starter-kit icon indicating copy to clipboard operation
react-starter-kit copied to clipboard

Facing issues with bun --filter @repo/db migrate

Open codeweft opened this issue 7 months ago • 1 comments

@repo/db migrate $ bun --bun drizzle-kit migrate │ [57 lines elided] │ severity: "ERROR", │ hint: "No function matches the given name and argument types. You might need to add explicit type casts.", │ position: "60", │ file: "parse_func.c", │ routine: "ParseFuncOrColumn", │ code: "42883" │ │ at ErrorResponse (/Users/kadeo/Desktop/kadeo/playground/react-starter-kit/node_modules/postgres/src/errors.js:794:5) │ │ error: "drizzle-kit" exited with code 1 └─ Exited with code 1

codeweft avatar Sep 16 '25 11:09 codeweft

This error happens because the database schema uses uuid_generate_v7() for generating primary keys, which requires the pg_uuidv7 PostgreSQL extension.

The migration tries to create it:

CREATE EXTENSION IF NOT EXISTS "pg_uuidv7";

But your PostgreSQL provider might not have this extension available.

Options

1. Use Neon PostgreSQL (recommended)

Neon has pg_uuidv7 pre-installed. Create a free database at neon.tech and update your DATABASE_URL in .env.

2. Enable the extension manually

If you're using a provider that supports it (like Supabase), you may need to enable it through their dashboard first, then run the migration again.

3. Switch to built-in UUIDs

If your provider doesn't support pg_uuidv7, you can modify db/schema.ts to use PostgreSQL's built-in gen_random_uuid() instead:

// Before
import { uuidv7 } from "./utils";
// ...
id: text().primaryKey().$default(uuidv7),

// After
id: text().primaryKey().$default(sql`gen_random_uuid()`),

Then regenerate migrations with bun --filter @repo/db generate.

The trade-off: UUID v7 produces time-ordered IDs (better for index performance), while v4 is random. For most applications, v4 works fine.


Which PostgreSQL provider are you using? That would help narrow down the best solution for your setup.

koistya avatar Dec 05 '25 22:12 koistya