hasura/graphql-engine · error

cannot fetch schema dump: %w

Error message

cannot fetch schema dump: %w

What it means

With --sql-server, migrate create asks the server for a schema dump via migrateDrv.ExportSchemaDump (driven by include/exclude schemas). This wraps failures of that server-side export: unsupported kind, DB connection error from the server, or metadata/API error.

Source

Thrown at cli/commands/migrate_create.go:247

	}

	if o.sqlFile != "" {
		// sql-file flag is set
		err := createOptions.SetSQLUpFromFile(o.sqlFile)
		if err != nil {
			return 0, herrors.E(op, fmt.Errorf("cannot set sql file: %w", err))
		}
	}

	if o.sqlServer {
		data, err := migrateDrv.ExportSchemaDump(
			o.includeSchemas,
			o.excludeSchemas,
			o.Source.Name,
			o.Source.Kind,
		)
		if err != nil {
			return 0, herrors.E(op, fmt.Errorf("cannot fetch schema dump: %w", err))
		}

		err = createOptions.SetSQLUp(string(data))
		if err != nil {
			return 0, herrors.E(
				op,
				fmt.Errorf("while writing data from server into the up.sql file: %w", err),
			)
		}
	}

	// create pure sql based migrations here
	if o.upSQLChanged {
		err = createOptions.SetSQLUp(o.upSQL)
		if err != nil {
			return 0, herrors.E(
				op,
				fmt.Errorf("up migration with SQL string could not be created: %w", err),

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Check the server's DB connection (run a query via console/hasura db execute)
  2. Verify include/exclude schema names are valid for the kind
  3. Upgrade CLI/server for broader dump support; fall back to --sql-file with a manual dump
Defensive patterns

Strategy: retry

Validate before calling

hasura db execute --database-name "$DB" --sql 'select 1' <<< '' >/dev/null 2>&1 || echo "db unreachable from server"

Try / catch

if strings.Contains(err.Error(), "cannot fetch schema dump") { /* check server->DB connectivity, retry */ }

Prevention

When it happens

Trigger: `hasura migrate create X --sql-server --database-name N` when the server cannot connect to the underlying database, or the source kind doesn't support schema dumps.

Common situations: Database credentials rotated on the server, network egress from server to DB blocked, using --sql-server against non-postgres sources in older versions.

Related errors


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