drizzle-team/drizzle-orm · critical · Error
No file ${migrationPath} found in ${migrationFolderTo} folde
Error message
No file ${migrationPath} found in ${migrationFolderTo} folder What it means
Thrown by readMigrationFiles in migrator.ts (line 55) when the journal references a migration .sql file (by tag) that cannot be read from disk. The journal entry exists but its corresponding <tag>.sql file is missing, deleted, or never written.
Source
Thrown at drizzle-orm/src/migrator.ts:55
for (const journalEntry of journal.entries) {
const migrationPath = `${migrationFolderTo}/${journalEntry.tag}.sql`;
try {
const query = fs.readFileSync(`${migrationFolderTo}/${journalEntry.tag}.sql`).toString();
const result = query.split('--> statement-breakpoint').map((it) => {
return it;
});
migrationQueries.push({
sql: result,
bps: journalEntry.breakpoints,
folderMillis: journalEntry.when,
hash: crypto.createHash('sha256').update(query).digest('hex'),
});
} catch {
throw new Error(`No file ${migrationPath} found in ${migrationFolderTo} folder`);
}
}
return migrationQueries;
}
View on GitHub (pinned to b7862528fd)
Solutions
- Restore the missing .sql file from version control, or regenerate it with drizzle-kit generate using the same schema snapshot.
- If the migration was intentionally removed, edit meta/_journal.json to drop the corresponding entry (advanced - ensure DB state matches).
- Ensure all .sql files are committed and shipped to the deployment environment (check .gitignore, Dockerfile COPY).
- Verify filesystem casing of the .sql filename matches the journal tag exactly.
Example fix
// before - journal references 0002_add_email.sql which is missing
await migrate(db, { migrationsFolder: './drizzle' });
// Error: No file ./drizzle/0002_add_email.sql found
// after - restore the file (git checkout) or regenerate
// git: git checkout HEAD -- drizzle/0002_add_email.sql
// then re-run migrate
await migrate(db, { migrationsFolder: './drizzle' }); Defensive patterns
Strategy: validation
Validate before calling
import fs from 'node:fs';
import path from 'node:path';
const journal = JSON.parse(fs.readFileSync(path.join(folder, 'meta', '_journal.json'), 'utf8'));
for (const e of journal.entries) {
if (!fs.existsSync(path.join(folder, `${e.tag}.sql`))) {
throw new Error(`Missing migration ${e.tag}.sql`);
}
} Type guard
function allMigrationsPresent(folder: string): boolean {
const journal = JSON.parse(fs.readFileSync(path.join(folder, 'meta/_journal.json'), 'utf8'));
return journal.entries.every((e: any) => fs.existsSync(path.join(folder, `${e.tag}.sql`)));
} Prevention
- Commit all .sql files and meta/_journal.json together.
- Don't gitignore migration .sql files.
- Keep filename casing consistent with journal tags.
- Regenerate migrations from version control rather than editing by hand.
When it happens
Trigger: meta/_journal.json lists an entry whose tag (e.g. 0001_initial) has no matching .sql file in the migrations folder. The readFileSync inside the loop throws and is caught, then re-thrown with this descriptive message.
Common situations: A migration .sql file was manually deleted or git-ignored while the journal still references it; partial/failed `drizzle-kit generate`; mismatched casing across filesystems (case-insensitive dev, case-sensitive deploy); files not included in the deployment artifact.
Related errors
- Can't find meta/_journal.json file
- Transaction not supported
- ${it.code}: ${it.message}
- unsupported dialect
- unsupported relation type
AI-assisted analysis of drizzle-team/drizzle-orm@b7862528fd (2026-08-03).
Data as JSON: /data/errors/45401a4488fed9ef.json.
Report an issue: GitHub.