ory/hydra · error
unable to find any migrations for dialect: %s
Error message
unable to find any migrations for dialect: %s
What it means
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.
Source
Thrown at oryx/popx/migrator.go:621
func errIsTableNotFound(err error) bool {
return strings.Contains(err.Error(), "no such table:") || // sqlite
strings.Contains(err.Error(), "Error 1146") || // MySQL
strings.Contains(err.Error(), "SQLSTATE 42P01") // PostgreSQL / CockroachDB
}
// Status prints out the status of applied/pending migrations.
func (mb *MigrationBox) Status(ctx context.Context) (MigrationStatuses, error) {
ctx, span := startSpan(ctx, MigrationStatusOpName)
defer span.End()
con := mb.c.WithContext(ctx)
dialect := mb.c.Dialect.Name()
fallbacks := mb.migrationFallbacks()
migrationsUp := mb.migrationsUp.sortAndFilter(dialect, fallbacks...)
if len(migrationsUp) == 0 {
return nil, errors.Errorf("unable to find any migrations for dialect: %s", dialect)
}
alreadyApplied := make([]string, 0, len(migrationsUp))
err := con.RawQuery(fmt.Sprintf("SELECT version FROM %s", sanitizedMigrationTableName(con))).All(&alreadyApplied)
if err != nil {
if errIsTableNotFound(err) {
// This means that no migrations have been applied and we need to apply all of them first!
//
// It also means that we can ignore this state and act as if no migrations have been applied yet.
} else {
// On any other error, we fail.
return nil, errors.Wrap(err, "problem with migration")
}
}
statuses := make(MigrationStatuses, len(migrationsUp))
for k, mf := range migrationsUp {
downContent := "-- error: no down migration defined for this migration"View on GitHub (pinned to 4174065ffb)
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.
Example fix
// before: files named 20210101000000_init.pg.up.sql while dialect is cockroach // after: add fallback or correctly named files -- migrations/20210101000000_init.cockroach.up.sql -- or configure fallbacks so cockroach resolves postgres migrations
Defensive patterns
Strategy: validation
Validate before calling
// verify migration files match the dialect before calling Status
entries, _ := fs.ReadDir(migrationsFS, ".")
dialect := c.Dialect.Name() // e.g. "postgres"
found := false
for _, e := range entries {
if strings.HasSuffix(e.Name(), "."+dialect+".up.sql") {
found = true
break
}
}
if !found {
return fmt.Errorf("no %s up-migrations present in migrations FS", dialect)
} Try / catch
statuses, err := mb.Status(ctx)
if err != nil && strings.HasPrefix(err.Error(), "unable to find any migrations for dialect:") {
return fmt.Errorf("migrations not embedded/shipped for dialect: %w — fix embed glob or file naming", err)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Could not create driver
- problem inserting migration version %s
- problem inserting migration version %s. YOUR DATABASE MAY BE
- migration down: unable count existing migration
- problem checking for legacy migration version %s
AI-assisted analysis of ory/hydra@4174065ffb (2026-09-03).
Data as JSON: /api/errors/d3f523d9f9deb321.
Report an issue: GitHub.