{"record":{"id":"cbe35363f865b5ee","repo":"ory/hydra","slug":"problem-checking-for-legacy-migration-version-s","errorCode":null,"errorMessage":"problem checking for legacy migration version %s","messagePattern":"problem checking for legacy migration version (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"oryx/popx/migrator.go","lineNumber":379,"sourceCode":"\t\t\t\tmb.l.WithError(err).Error(\"Problem reverting migrations.\")\n\t\t\t}\n\t\t}()\n\t\tfor i, mi := range mfs {\n\t\t\tif i >= attemptSteps {\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tl := mb.l.WithField(\"version\", mi.Version).WithField(\"migration_name\", mi.Name).WithField(\"migration_file\", mi.Path)\n\t\t\tl.Debugf(\"handling migration %s\", mi.Name)\n\t\t\texists, err := c.Where(\"version = ?\", mi.Version).Exists(mtn)\n\t\t\tif err != nil {\n\t\t\t\treturn errors.Wrapf(err, \"problem checking for migration version %s\", mi.Version)\n\t\t\t}\n\n\t\t\tif !exists && len(mi.Version) > 14 {\n\t\t\t\tlegacyVersion := mi.Version[:14]\n\t\t\t\tlegacyVersionExists, err := c.Where(\"version = ?\", legacyVersion).Exists(mtn)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.Wrapf(err, \"problem checking for legacy migration version %s\", legacyVersion)\n\t\t\t\t}\n\n\t\t\t\tif !legacyVersionExists {\n\t\t\t\t\treturn errors.Errorf(\"neither normal (%s) nor legacy migration (%s) exist\", mi.Version, legacyVersion)\n\t\t\t\t}\n\t\t\t} else if !exists {\n\t\t\t\treturn errors.Errorf(\"migration version %s does not exist\", mi.Version)\n\t\t\t}\n\n\t\t\tif err := mi.Valid(); err != nil {\n\t\t\t\treturn errors.WithStack(err)\n\t\t\t}\n\n\t\t\tif mb.shouldNotUseTransaction(mi) {\n\t\t\t\terr := mi.Runner(mi, c)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn errors.WithStack(err)\n\t\t\t\t}","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/ory/hydra/blob/4174065ffb052799890f7480f5360a877a67ffc1/oryx/popx/migrator.go#L361-L397","documentation":"If a migration's full-length version is not found in schema_migration, the migrator also probes the legacy 14-char truncated version. This error wraps a failure of that legacy EXISTS lookup. It is a query failure against the tracking table, not evidence about whether the legacy row exists.","triggerScenarios":"Calling Down for a migration with a version longer than 14 characters whose full version is absent, and the legacy-version EXISTS query fails (table missing, connection error, permissions).","commonSituations":"schema_migration dropped or corrupted between queries; transient connection failure; wrong database (table absent).","solutions":["Inspect the wrapped cause for the underlying SQL error","Verify schema_migration exists and is readable","Reconnect/retry once the database is reachable"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"var n int\nif err := db.QueryRow(\"SELECT COUNT(*) FROM schema_migration\").Scan(&n); err != nil {\n    return fmt.Errorf(\"tracking table unreadable before Down: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := box.Down(ctx, 1); err != nil {\n    if isTransient(err) {\n        time.Sleep(time.Second)\n        return box.Down(ctx, 1)\n    }\n    return err\n}","preventionTips":["Check DB connectivity before starting rollback runs","Do not drop schema_migration mid-operation","Ensure consistent read access for the migration user"],"tags":["database","migration","go"],"backgroundTag":"migration-table-missing","analyzedSha":"4174065ffb052799890f7480f5360a877a67ffc1","analyzedAt":"2026-09-03T14:52:41.581Z","contentChangedAt":"2026-09-03T14:52:41.581Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}