hasura/graphql-engine · error
cannot create migrate instance: %w
Error message
cannot create migrate instance: %w
What it means
`hasura migrate create` builds a migrate.Migrate driver instance when SQL-related flags (--sql-server, --up/sql-file, etc.) are set. This wraps any failure of migrate.NewMigrate, which validates config, server connectivity, and source support.
Source
Thrown at cli/commands/migrate_create.go:227
}
func (o *migrateCreateOptions) run() (version int64, err error) {
var op herrors.Op = "migrate.migrateCreateOptions.run"
timestamp := getTime()
createOptions := mig.New(timestamp, o.name, filepath.Join(o.EC.MigrationDir, o.Source.Name))
if o.fromServer {
o.sqlServer = true
}
var migrateDrv *migrate.Migrate
// disabling auto state migrations for migrate create command
o.EC.DisableAutoStateMigration = true
if o.sqlServer || o.upSQLChanged || o.downSQLChanged {
migrateDrv, err = migrate.NewMigrate(o.EC, true, o.Source.Name, o.Source.Kind)
if err != nil {
return 0, herrors.E(op, fmt.Errorf("cannot create migrate instance: %w", err))
}
}
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,
)View on GitHub (pinned to 724551b9ae)
Solutions
- Confirm server endpoint/admin secret and that the database exists (hasura migrate status)
- Verify the database kind supports migrations (see errors 101/102)
- Fix or regenerate config.yaml (hasura init) if the config version/state is broken
Defensive patterns
Strategy: validation
Validate before calling
hasura migrate status --database-name "$DB" >/dev/null || echo "cannot init migrate driver"
Prevention
- Verify server and source before using --sql-server
- Keep config.yaml version current
When it happens
Trigger: `hasura migrate create ... --sql-server` against an unreachable server, unsupported source kind, or when config v3 setup cannot resolve the named database.
Common situations: Creating server-based SQL migrations while the local dev server is down; --database-name pointing to a non-existent source; old config.yaml version.
Related errors
- pulling latest actions codegen files from internet failed: %
- unable to fetch introspection schema: %w
- error getting actions file content: %w
- error generating codegen for action %s: %w
- error in fetching introspection schema: %w
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/5f02d53fa91fbc70.
Report an issue: GitHub.