Skip to content

bun run dev fails with ENOENT when using D1 + Drizzle + Alchemy — missing migrations directory #999

@shkumbinhasani

Description

@shkumbinhasani

Bug

When scaffolding a new project with D1 database, Drizzle ORM, and Alchemy infra, running bun run dev immediately after project creation fails with:

ENOENT: no such file or directory, open '../../packages/db/src/migrations'

Root Cause

The packages/db/src/migrations directory is never created during scaffolding. The drizzle config (packages/db/drizzle.config.ts) specifies out: "./src/migrations" as the output directory, but drizzle-kit generate is never run during project generation. The infra package (packages/infra/alchemy.run.ts) references this directory via migrationsDir: "../../packages/db/src/migrations", and when Alchemy's D1Database tries to glob for SQL files in a non-existent directory, Bun's fs.glob throws ENOENT (unlike Node.js which silently returns empty).

The post-install instructions do mention running db:generate, but the README says "D1 local development and migrations are handled automatically by Alchemy" and directs users to run bun run dev without any prerequisite steps.

Steps to Reproduce

  1. bunx create-better-t-stack my-app (select D1, Drizzle, Alchemy)
  2. cd my-app && bun install
  3. bun run dev
  4. Observe ENOENT crash from the infra package

Suggested Fix

Add a .gitkeep file to packages/db/src/migrations/ in the template generator so the directory always exists after scaffolding. This is the simplest fix — the directory will be populated with real migration files once the user runs db:generate, but its existence won't break bun run dev in the meantime.

Alternative: run drizzle-kit generate as a post-scaffold step when D1 + Drizzle is selected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions