Skip to content

fix: support Drizzle folder migrations#3

Draft
HuakunShen wants to merge 1 commit into
mainfrom
fix/unique-migration
Draft

fix: support Drizzle folder migrations#3
HuakunShen wants to merge 1 commit into
mainfrom
fix/unique-migration

Conversation

@HuakunShen

Copy link
Copy Markdown
Owner

Summary

  • Fix migrate() so Drizzle v1/RC Folder V3 paths like .../20260605110000_add_users/migration.sql use a stable parent-folder migration id instead of the repeated migration.sql basename.
  • Keep existing flat migration filenames backward compatible and add legacy recovery for databases that already recorded the old migration.sql marker.
  • Add Bun TypeScript regression tests, test typechecking, README migration docs, and bump the npm package to 0.1.1-beta.0 for beta publishing.

Root Cause

Drizzle Folder V3 stores each migration SQL payload as migration.sql inside a uniquely named migration folder. The previous parser recorded only the SQL file basename in __drizzle_migrations.hash, so multiple migrations collided on migration.sql and could trigger UNIQUE constraint failed: __drizzle_migrations.hash.

Validation

  • ./node_modules/.bin/tsc --noEmit
  • ./node_modules/.bin/tsc --noEmit -p test/tsconfig.json
  • pnpm test
  • npm pack --dry-run --registry=https://registry.npmjs.org/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: SQLite migration fails with UNIQUE constraint on __drizzle_migrations.hash due to Drizzle v1 Beta nested folder structure

1 participant