drizzle-team/drizzle-orm · critical · Error
Can't find meta/_journal.json file
Error message
Can't find meta/_journal.json file
What it means
Thrown by readMigrationFiles in migrator.ts (line 29) when meta/_journal.json does not exist inside the configured migrationsFolder. Drizzle Kit writes this journal to track migration order; its absence means migrations were never generated or the folder path is wrong.
Source
Thrown at drizzle-orm/src/migrator.ts:29
migrationsTable?: string;
migrationsSchema?: string;
}
export interface MigrationMeta {
sql: string[];
folderMillis: number;
hash: string;
bps: boolean;
}
export function readMigrationFiles(config: MigrationConfig): MigrationMeta[] {
const migrationFolderTo = config.migrationsFolder;
const migrationQueries: MigrationMeta[] = [];
const journalPath = `${migrationFolderTo}/meta/_journal.json`;
if (!fs.existsSync(journalPath)) {
throw new Error(`Can't find meta/_journal.json file`);
}
const journalAsString = fs.readFileSync(`${migrationFolderTo}/meta/_journal.json`).toString();
const journal = JSON.parse(journalAsString) as {
entries: { idx: number; when: number; tag: string; breakpoints: boolean }[];
};
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;
});
View on GitHub (pinned to b7862528fd)
Solutions
- Run `drizzle-kit generate` to create the migrations folder, meta/_journal.json, and initial .sql files.
- Verify the migrationsFolder path in migrate() matches the `out` folder in drizzle.config.ts exactly (resolve relative to process.cwd()).
- Ensure the migrations folder is committed and deployed alongside your app so meta/_journal.json is present at runtime.
- Use an absolute path (path.resolve) for migrationsFolder to avoid cwd ambiguity.
Example fix
// before - wrong/missing folder
import { migrate } from 'drizzle-orm/libsql/migrator';
await migrate(db, { migrationsFolder: './drizzle' }); // no meta/_journal.json
// after - correct folder + ensure generated
// drizzle.config.ts: { out: './drizzle/migrations' }
import path from 'node:path';
await migrate(db, { migrationsFolder: path.resolve('./drizzle/migrations') });
// run: drizzle-kit generate Defensive patterns
Strategy: validation
Validate before calling
import fs from 'node:fs';
import path from 'node:path';
const journal = path.join(folder, 'meta', '_journal.json');
if (!fs.existsSync(journal)) {
throw new Error(`Run 'drizzle-kit generate'. Missing ${journal}`);
} Type guard
function migrationsReady(folder: string): boolean {
return fs.existsSync(path.join(folder, 'meta', '_journal.json'));
} Prevention
- Run drizzle-kit generate before migrate at deploy time.
- Use the same folder path in drizzle.config.ts `out` and migrate() `migrationsFolder`.
- Commit and ship the migrations folder including meta/_journal.json.
- Use absolute paths resolved from process.cwd().
When it happens
Trigger: Calling migrate() with a migrationsFolder that lacks a meta/_journal.json file. Happens when the folder doesn't exist, points to the wrong directory, or drizzle-kit generate was never run.
Common situations: Wrong/typo'd migrationsFolder path in migrate() config; migrations generated to a different folder than the one passed; fresh repo where drizzle-kit generate hasn't been run yet; CI running migrations before generating them.
Related errors
- No file ${migrationPath} found in ${migrationFolderTo} folde
- 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/ce3a56330fd13b06.json.
Report an issue: GitHub.