{"record":{"id":"d38c45efd27e61fc","repo":"ory/hydra","slug":"migrations-have-not-yet-been-fully-applied-v","errorCode":null,"errorMessage":"migrations have not yet been fully applied: %+v","messagePattern":"migrations have not yet been fully applied: %\\+v","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"driver/registry_sql.go","lineNumber":398,"sourceCode":"\tif m.hh == nil {\n\t\tm.hh = healthx.NewHandler(m.Writer(), config.Version, healthx.ReadyCheckers{\n\t\t\t\"database\": func(r *http.Request) error {\n\t\t\t\treturn m.PingContext(r.Context())\n\t\t\t},\n\t\t\t\"migrations\": func(r *http.Request) error {\n\t\t\t\tstatus, err := m.migrator.MigrationStatus(r.Context())\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\n\t\t\t\tif status.HasPending() {\n\t\t\t\t\tvar notApplied []string\n\t\t\t\t\tfor _, s := range status {\n\t\t\t\t\t\tif s.State != \"Applied\" {\n\t\t\t\t\t\t\tnotApplied = append(notApplied, s.Version)\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\terr := errors.Errorf(\"migrations have not yet been fully applied: %+v\", notApplied)\n\t\t\t\t\tm.Logger().WithField(\"not_applied\", fmt.Sprintf(\"%+v\", notApplied)).WithError(err).Warn(\"Instance is not yet ready because migrations have not yet been fully applied.\")\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t},\n\t\t})\n\t}\n\n\treturn m.hh\n}\n\nfunc (m *RegistrySQL) ConsentStrategy() consent.Strategy {\n\tif m.cos == nil {\n\t\tm.cos = consent.NewStrategy(m)\n\t}\n\treturn m.cos\n}\n","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/ory/hydra/blob/4174065ffb052799890f7480f5360a877a67ffc1/driver/registry_sql.go#L380-L416","documentation":"During registry initialization Hydra checks migration status (PopMiscMigrations/ValidateMigrations path in registry_sql.go). If any migration for the connection has a state other than \"Applied\", it errors with the list of unapplied versions and logs a warning that the instance is not yet ready. This prevents running a code version against a database schema it doesn't match.","triggerScenarios":"Starting `hydra serve` (or any registry boot that runs the migration readiness check) when `hydra migrate sql` has not been run for the current code version — the schemamigration status returns pending/missing versions.","commonSituations":"Deploying a new Hydra version without running migrations first; running multiple Hydra replicas where one applied migrations late; manually skipping `hydra migrate sql up` in CI/CD; partial migration failure leaving a version in a non-Applied state.","solutions":["Run `hydra migrate sql up -e \"$DSN\"` to apply pending migrations, then restart the instance.","Check status with `hydra migrate sql status -e \"$DSN\"` to see which versions are not Applied.","If a migration failed midway, fix the underlying DB issue (permissions, locks) and re-run; check for partially applied transactions.","Ensure your deployment pipeline runs migrations as a pre-deploy step before rolling out new Hydra binaries."],"exampleFix":"// before (CI)\n- docker run oryd/hydra:v2.2.0 serve all\n\n// after (CI)\n- docker run oryd/hydra:v2.2.0 migrate sql up -e \"$DSN\"\n- docker run oryd/hydra:v2.2.0 serve all","handlingStrategy":"validation","validationCode":"// gate deployment on migration status\nout, err := exec.Command(\"hydra\", \"migrate\", \"sql\", \"status\", \"-e\", dsn).Output()\nif err != nil || strings.Contains(string(out), \"Pending\") {\n    return fmt.Errorf(\"run `hydra migrate sql up` before starting hydra\")\n}","typeGuard":null,"tryCatchPattern":"if err := hydra.Start(ctx); err != nil {\n    if strings.Contains(err.Error(), \"migrations have not yet been fully applied\") {\n        log.Println(\"running pending migrations...\")\n        if err := hydra.MigrateUp(ctx, dsn); err != nil {\n            log.Fatalf(\"migration failed: %+v\", err)\n        }\n        return hydra.Start(ctx)\n    }\n    log.Fatalf(\"hydra failed: %+v\", err)\n}","preventionTips":["Always run `hydra migrate sql up` as a pre-deploy step before starting new versions.","Check `hydra migrate sql status` in CI after migrations to confirm all states are Applied.","Run migrations exactly once per deploy (single migration job, not per replica).","Monitor the instance log line 'migrations have not yet been fully applied' in orchestration health checks."],"tags":["database","migrations","startup","schema"],"backgroundTag":"pending-database-migrations","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"}