{"record":{"id":"d3f523d9f9deb321","repo":"ory/hydra","slug":"unable-to-find-any-migrations-for-dialect-s","errorCode":null,"errorMessage":"unable to find any migrations for dialect: %s","messagePattern":"unable to find any migrations for dialect: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"oryx/popx/migrator.go","lineNumber":621,"sourceCode":"func errIsTableNotFound(err error) bool {\n\treturn strings.Contains(err.Error(), \"no such table:\") || // sqlite\n\t\tstrings.Contains(err.Error(), \"Error 1146\") || // MySQL\n\t\tstrings.Contains(err.Error(), \"SQLSTATE 42P01\") // PostgreSQL / CockroachDB\n}\n\n// Status prints out the status of applied/pending migrations.\nfunc (mb *MigrationBox) Status(ctx context.Context) (MigrationStatuses, error) {\n\tctx, span := startSpan(ctx, MigrationStatusOpName)\n\tdefer span.End()\n\n\tcon := mb.c.WithContext(ctx)\n\n\tdialect := mb.c.Dialect.Name()\n\tfallbacks := mb.migrationFallbacks()\n\tmigrationsUp := mb.migrationsUp.sortAndFilter(dialect, fallbacks...)\n\n\tif len(migrationsUp) == 0 {\n\t\treturn nil, errors.Errorf(\"unable to find any migrations for dialect: %s\", dialect)\n\t}\n\n\talreadyApplied := make([]string, 0, len(migrationsUp))\n\terr := con.RawQuery(fmt.Sprintf(\"SELECT version FROM %s\", sanitizedMigrationTableName(con))).All(&alreadyApplied)\n\tif err != nil {\n\t\tif errIsTableNotFound(err) {\n\t\t\t// This means that no migrations have been applied and we need to apply all of them first!\n\t\t\t//\n\t\t\t// It also means that we can ignore this state and act as if no migrations have been applied yet.\n\t\t} else {\n\t\t\t// On any other error, we fail.\n\t\t\treturn nil, errors.Wrap(err, \"problem with migration\")\n\t\t}\n\t}\n\n\tstatuses := make(MigrationStatuses, len(migrationsUp))\n\tfor k, mf := range migrationsUp {\n\t\tdownContent := \"-- error: no down migration defined for this migration\"","sourceCodeStart":603,"sourceCodeEnd":639,"githubUrl":"https://github.com/ory/hydra/blob/4174065ffb052799890f7480f5360a877a67ffc1/oryx/popx/migrator.go#L603-L639","documentation":"Status() computes migration status by sorting and filtering the embedded up-migrations for the connection's dialect (and its fallback dialects). If after that filtering no migration files remain, it refuses to guess and returns 'unable to find any migrations for dialect: %s'. This almost always means the migrations box was constructed without migration files matching your database dialect.","triggerScenarios":"Calling MigrationBox.Status(ctx) when mb.migrationsUp.sortAndFilter(dialect, fallbacks...) yields an empty list — i.e. no migration files whose name/dialect suffix matches the connection's dialect (e.g. postgres, mysql, sqlite, cockroach) or any configured fallback dialect.","commonSituations":"Pointing the migrations directory (or embedded FS) at the wrong path so no .sql files are loaded; migrations named without the required .up.sql / dialect naming convention; using a dialect name with no matching migration files (e.g. connecting with cockroach but only shipping postgres files without fallbacks configured); embedding migrations with a stale or empty go:embed pattern.","solutions":["Verify the migrations directory/embed pattern actually contains migration files and that the embed glob is not empty.","Check migration file naming: files must follow the '<version>_<name>.<dialect>.up.sql' convention matching your connection's dialect.","If dialects are aliases (e.g. cockroach vs postgres), configure migrationFallbacks so the box falls back to matching files.","Print mb.c.Dialect.Name() and confirm it matches the dialect suffix used in your migration filenames."],"exampleFix":"// before: files named 20210101000000_init.pg.up.sql while dialect is cockroach\n// after: add fallback or correctly named files\n-- migrations/20210101000000_init.cockroach.up.sql\n-- or configure fallbacks so cockroach resolves postgres migrations","handlingStrategy":"validation","validationCode":"// verify migration files match the dialect before calling Status\nentries, _ := fs.ReadDir(migrationsFS, \".\")\ndialect := c.Dialect.Name() // e.g. \"postgres\"\nfound := false\nfor _, e := range entries {\n    if strings.HasSuffix(e.Name(), \".\"+dialect+\".up.sql\") {\n        found = true\n        break\n    }\n}\nif !found {\n    return fmt.Errorf(\"no %s up-migrations present in migrations FS\", dialect)\n}","typeGuard":null,"tryCatchPattern":"statuses, err := mb.Status(ctx)\nif err != nil && strings.HasPrefix(err.Error(), \"unable to find any migrations for dialect:\") {\n    return fmt.Errorf(\"migrations not embedded/shipped for dialect: %w — fix embed glob or file naming\", err)\n}","preventionTips":["Use a non-empty go:embed pattern and assert at startup that it matched files.","Follow the '<version>_<name>.<dialect>.up.sql' naming convention exactly.","Configure dialect fallbacks (e.g. cockroach -> postgres) when sharing migration files.","Add a unit test listing embedded migrations per supported dialect."],"tags":["database","migration","configuration","embed"],"backgroundTag":"no-migrations-found","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"}