{"record":{"id":"91018fa34ffe5d68","repo":"remix-run/remix","slug":"unknown-migration-target-to","errorCode":null,"errorMessage":"Unknown migration target: {to}","messagePattern":"Unknown migration target: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/data-table/src/lib/migrations/runner.ts","lineNumber":77,"sourceCode":"  }\n}\n\nfunction resolveTargetOption(\n  migrations: MigrationDescriptor[],\n  to: string | undefined,\n): string | undefined {\n  if (to === undefined) {\n    return undefined\n  }\n\n  // Accept either a bare migration id or the full `id_name` directory form and\n  // normalize to the bare id so range filtering compares ids consistently.\n  let matches = migrations.filter(\n    (migration) => migration.id === to || migration.id + '_' + migration.name === to,\n  )\n\n  if (matches.length === 0) {\n    throw new Error('Unknown migration target: ' + to)\n  }\n\n  if (matches.length > 1) {\n    throw new Error(\n      'Ambiguous migration target \"' +\n        to +\n        '\". Matches: ' +\n        matches.map((migration) => migration.id + '_' + migration.name).join(', '),\n    )\n  }\n\n  return matches[0].id\n}\n\nasync function assertMigrationIntegrity(\n  migrations: MigrationDescriptor[],\n  journal: MigrationJournalRow[],\n  direction: MigrationDirection,","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/remix-run/remix/blob/9696913134be3a4423513d2775f7b31d6917c049/packages/data-table/src/lib/migrations/runner.ts#L59-L95","documentation":"The `to` target option did not match any registered migration. Targets are matched against either the bare id or the full `id_name` string, and zero matches abort the run before anything executes.","triggerScenarios":"Calling runMigrations with `{ to: 'create_users' }` (name only, unsupported), a typo'd id, or an id from a branch that isn't in the registry.","commonSituations":"Passing the migration name without its timestamp id; targeting a migration that exists on another branch or hasn't been generated yet; trailing whitespace from CLI input.","solutions":["Use the full `id_name` or the bare numeric id, e.g. `20240101123045_create_users` or `20240101123045`.","Print `registry.list()` to confirm available ids and copy the exact target.","Trim/normalize CLI-provided target strings before passing them in."],"exampleFix":"// before\nawait runMigrations(db, { direction: 'up', to: 'create_users' })\n\n// after\nawait runMigrations(db, { direction: 'up', to: '20240101123045_create_users' })","handlingStrategy":"validation","validationCode":"let valid = registry\n  .list()\n  .some((m) => m.id === to || m.id + '_' + m.name === to)\nif (!valid) throw new Error('unknown --to target: ' + to)","typeGuard":"function isKnownTarget(registry: MigrationRegistry, to: string): boolean {\n  return registry.list().some((m) => m.id === to || `${m.id}_${m.name}` === to)\n}","tryCatchPattern":"try {\n  await runMigrations(db, { direction: 'up', to })\n} catch (error) {\n  if (error instanceof Error && error.message.startsWith('Unknown migration target')) {\n    console.error('Available:', registry.list().map((m) => `${m.id}_${m.name}`).join('\\n'))\n  }\n  throw error\n}","preventionTips":["Offer targets from registry.list() via CLI completion or a list command.","Always copy the full id_name string rather than typing from memory."],"tags":["migrations","unknown-target","options-validation"],"backgroundTag":"target-not-found","analyzedSha":"9696913134be3a4423513d2775f7b31d6917c049","analyzedAt":"2026-08-27T19:55:01.024Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}