hasura/graphql-engine · error

error getting status for database

Error message

error getting status for database '%s': %w

What it means

Thrown by migrate status Run in --all-databases mode when RunOnSource returns an error for a specific source (database) listed in metadata. The underlying error typically comes from building the migrate driver or executing status against that source.

Solutions

  1. Check the specific source's database connectivity (psql/connect with its connection string)
  2. Fix or remove the broken source in Hasura metadata and re-run status
  3. Run 'hasura migrate status --database <name>' on the failing source for a detailed error
  4. Verify the database kind is supported by migrate (e.g. postgres)
Defensive patterns

Strategy: try-catch

Validate before calling

// preflight each source's DB connectivity before status
for _, s := range sources {
    db, err := sql.Open("pgx", s.DatabaseURL)
    if err == nil { err = db.Ping() }
    if err != nil { log.Warnf("source %s unhealthy: %v", s.Name, err) }
    db.Close()
}

Try / catch

Per-source try/catch: log and continue with healthy sources, collect failing source names, and exit non-zero only if all fail — the loop context (%s = source name) tells you which to retry.

Prevention

When it happens

Trigger: Running 'hasura migrate status --all-databases' where one of the connected sources has a bad connection string, unreachable database, unsupported database kind, or mismatched migrations state.

Common situations: A source in metadata pointing to a database that is down or credentials rotated; a source added with a wrong DB URL; network egress blocked from server to database.

Related errors


AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28). Data as JSON: /api/errors/e44ecdba045c28a9. Report an issue: GitHub.

Appendix: source

Thrown at cli/commands/migrate_status.go:81

	o.EC.Spin("Fetching migration status...")
	defer o.EC.Spinner.Stop()

	if ec.AllDatabases {
		sourcesAndKind, err := metadatautil.GetSourcesAndKind(
			o.EC.APIClient.V1Metadata.ExportMetadata,
		)
		if err != nil {
			return errors.E(op, fmt.Errorf("got error while getting the sources list : %w", err))
		}

		for _, source := range sourcesAndKind {
			o.Source = cli.Source(source)

			status, err := o.RunOnSource()
			if err != nil {
				return errors.E(
					op,
					fmt.Errorf("error getting status for database '%s': %w", o.Source.Name, err),
				)
			}

			o.StatusOpts[o.Source] = status
		}

		return nil
	}

	o.Source = ec.Source

	status, err := o.RunOnSource()
	if err != nil {
		return errors.E(
			op,
			fmt.Errorf("error getting status for database '%s': %w", o.Source.Name, err),
		)
	}

View on GitHub (pinned to 724551b9ae)