Skip to content

Commit f652333

Browse files
committed
fix(kit): use path.basename/dirname in embeddedMigrations to fix Windows path separators
On Windows, snapshot paths use backslash separators. The previous entry.split('/')[...length - 2] approach returns undefined when the path contains only backslashes, causing migrations.js to import from './undefined/migration.sql'. Replace with path.basename(path.dirname(entry)) which correctly extracts the parent folder name on all platforms.
1 parent 7eb39f0 commit f652333

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drizzle-kit/src/cli/commands/generate-common.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const embeddedMigrations = (snapshots: string[], driver?: Driver) => {
9797
const migrations: Record<string, string> = {};
9898

9999
snapshots.forEach((entry, idx) => {
100-
const prefix = entry.split('/')[entry.split('/').length - 2];
100+
const prefix = path.basename(path.dirname(entry));
101101
const importName = idx.toString().padStart(4, '0');
102102
content += `import m${importName} from './${prefix}/migration.sql';\n`;
103103
migrations[prefix] = importName;

0 commit comments

Comments
 (0)