{"record":{"id":"d55fc7e315c6016c","repo":"toeverything/AFFiNE","slug":"unknown-migration-name-name","errorCode":null,"errorMessage":"Unknown migration name: ${name}.","messagePattern":"Unknown migration name: (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/backend/server/src/data/commands/run.ts","lineNumber":75,"sourceCode":"      }\n\n      await this.runMigration(migration);\n\n      done.push(migration);\n    }\n\n    this.logger.log(`Done ${done.length} migrations`);\n    done.forEach(migration => {\n      this.logger.log(`  ✔ ${migration.name}`);\n    });\n  }\n\n  async runOne(name: string) {\n    const migrations = collectMigrations();\n    const migration = migrations.find(m => m.name === name);\n\n    if (!migration) {\n      throw new Error(`Unknown migration name: ${name}.`);\n    }\n    const exists = await this.db.dataMigration.count({\n      where: {\n        name: migration.name,\n      },\n    });\n\n    if (exists) return;\n\n    await this.runMigration(migration);\n  }\n\n  private async runMigration(migration: Migration) {\n    this.logger.log(`Running ${migration.name}...`);\n    const record = await this.db.dataMigration.upsert({\n      where: {\n        name: migration.name,\n      },","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/toeverything/AFFiNE/blob/26c515e050211269e911f7d9cfe162a26c83ed98/packages/backend/server/src/data/commands/run.ts#L57-L93","documentation":"Thrown by `RunCommand.runOne` when no collected migration matches the supplied `name`. The migration registry is built from the file modules in `data/migrations`, so a name not present there cannot be run. A plain `Error` (no error code); unlike `RevertCommand`, this variant does not log the available names.","triggerScenarios":"Calling `runOne(name)` with a typo, a migration that has not been added to the registry, an old name after a rename, or a name from a different version of the codebase.","commonSituations":"Operator mistypes the migration name; migration was renamed in an upgrade but ops still uses the old name; running against a deployment that doesn't include the new migration file; copy-paste of a name with trailing whitespace.","solutions":["List the migrations directory (`packages/backend/server/src/data/migrations/`) to see available names.","Use the exact filename without extension (and with its trailing numeric suffix).","Trim whitespace from the name before invoking; verify against the registry exports.","If the migration is missing, ensure the file exists and is exported from `data/migrations/index.ts`."],"exampleFix":"// before\nawait runCommand.runOne('add-indexes');\n\n// after\nawait runCommand.runOne('1766000000000-add-indexes'); // exact name from registry","handlingStrategy":"validation","validationCode":"// Verify the name is in the registry before running\nconst migrations = collectMigrations();\nif (!migrations.find(m => m.name === name)) {\n  console.error('Available:', migrations.map(m => m.name).join(', '));\n  process.exit(1);\n}\nawait runCommand.runOne(name);","typeGuard":"function isRegisteredMigration(name, migrations) {\n  return migrations.some(m => m.name === name);\n}","tryCatchPattern":"try {\n  await runCommand.runOne(name);\n} catch (e) {\n  if (e.message.startsWith('Unknown migration name')) {\n    const migrations = collectMigrations();\n    console.error('Available:', migrations.map(m => m.name).join(', '));\n  }\n  throw e;\n}","preventionTips":["Use the exact migration name (filename without extension, including numeric suffix).","List the migrations directory before running a single migration.","Trim whitespace from operator-supplied names."],"tags":["cli","migration","not-found","nestjs"],"backgroundTag":null,"analyzedSha":"26c515e050211269e911f7d9cfe162a26c83ed98","analyzedAt":"2026-08-12T13:15:16.447Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}