remix-run/remix · error · Error
Invalid migration directory name "{name}". Expected format Y
Error message
Invalid migration directory name "{name}". Expected format YYYYMMDDHHmmss_name What it means
A migration directory name failed to match the required `YYYYMMDDHHmmss_name` pattern. The id timestamp and the underscore-separated name are how migrations are ordered and identified, so malformed names are rejected.
Source
Thrown at packages/data-table/src/lib/migrations/directory-name.ts:14
const migrationDirectoryPattern = /^(\d{14})_(.+)$/
/**
* Parses a migration directory name into `{ id, name }`.
*
* Expected format: `YYYYMMDDHHmmss_name`.
* @param name Migration directory basename.
* @returns Parsed migration id and name.
*/
export function parseMigrationDirectoryName(name: string): { id: string; name: string } {
let match = name.match(migrationDirectoryPattern)
if (!match) {
throw new Error(
'Invalid migration directory name "' + name + '". Expected format YYYYMMDDHHmmss_name',
)
}
return {
id: match[1],
name: match[2],
}
}
View on GitHub (pinned to 9696913134)
Solutions
- Rename the directory to `YYYYMMDDHHmmss_name`, e.g. `20240101123045_create_users`.
- Use the package's migration scaffolding command so names are generated correctly.
- If renaming a recorded migration, also update the journal/registry entry or roll back first.
Example fix
# before migrations/01_create_users/ # after migrations/20240101123045_create_users/
Defensive patterns
Strategy: validation
Validate before calling
let ok = /^\d{14}_[a-zA-Z0-9_-]+$/.test(dirName)
if (!ok) throw new Error('bad migration dir name: ' + dirName) Type guard
function isValidMigrationDirectoryName(name: string): boolean {
return /^\d{14}_[a-zA-Z0-9_-]+$/.test(name)
} Try / catch
try {
let parsed = parseMigrationDirectoryName(entry.name)
} catch (error) {
if (error instanceof Error && error.message.includes('Invalid migration directory name')) {
continue // skip non-migration dirs like .DS_Store or __tests__
}
throw error
} Prevention
- Always create migrations via the scaffolding command, never by hand.
- Filter directory listings with the YYYYMMDDHHmmss_name regex before parsing.
When it happens
Trigger: Calling parseMigrationDirectoryName with names like `my_migration`, `20240101_create_users` (missing time part), or `20240101120000` (missing underscore/name).
Common situations: Hand-creating migration folders instead of using the generator; renaming directories; using a truncated 8-digit date instead of the full 14-digit timestamp.
Related errors
- expected promise to resolve, but it rejected with: ${stringi
- ${optionName} values must be package names. Received "${pack
- hmr must create a channel with a close function
- hmr must create a channel with an onFileEvents function
- hmr must create a channel with an updateWatchedFiles functio
AI-assisted analysis of remix-run/remix@9696913134 (2026-08-27).
Data as JSON: /api/errors/54dd63b704c22a8f.
Report an issue: GitHub.