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

  1. Rename the directory to `YYYYMMDDHHmmss_name`, e.g. `20240101123045_create_users`.
  2. Use the package's migration scaffolding command so names are generated correctly.
  3. 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

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


AI-assisted analysis of remix-run/remix@9696913134 (2026-08-27). Data as JSON: /api/errors/54dd63b704c22a8f. Report an issue: GitHub.