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

  1. Restore the missing .sql file from version control, or regenerate it with drizzle-kit generate using the same schema snapshot.
  2. If the migration was intentionally removed, edit meta/_journal.json to drop the corresponding entry (advanced - ensure DB state matches).
  3. Ensure all .sql files are committed and shipped to the deployment environment (check .gitignore, Dockerfile COPY).
  4. 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

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


AI-assisted analysis of drizzle-team/drizzle-orm@b7862528fd (2026-08-03). Data as JSON: /data/errors/45401a4488fed9ef.json. Report an issue: GitHub.