{"record":{"id":"5f02d53fa91fbc70","repo":"hasura/graphql-engine","slug":"cannot-create-migrate-instance-w","errorCode":null,"errorMessage":"cannot create migrate instance: %w","messagePattern":"cannot create migrate instance: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/commands/migrate_create.go","lineNumber":227,"sourceCode":"}\n\nfunc (o *migrateCreateOptions) run() (version int64, err error) {\n\tvar op herrors.Op = \"migrate.migrateCreateOptions.run\"\n\n\ttimestamp := getTime()\n\tcreateOptions := mig.New(timestamp, o.name, filepath.Join(o.EC.MigrationDir, o.Source.Name))\n\n\tif o.fromServer {\n\t\to.sqlServer = true\n\t}\n\n\tvar migrateDrv *migrate.Migrate\n\t// disabling auto state migrations for migrate create command\n\to.EC.DisableAutoStateMigration = true\n\tif o.sqlServer || o.upSQLChanged || o.downSQLChanged {\n\t\tmigrateDrv, err = migrate.NewMigrate(o.EC, true, o.Source.Name, o.Source.Kind)\n\t\tif err != nil {\n\t\t\treturn 0, herrors.E(op, fmt.Errorf(\"cannot create migrate instance: %w\", err))\n\t\t}\n\t}\n\n\tif o.sqlFile != \"\" {\n\t\t// sql-file flag is set\n\t\terr := createOptions.SetSQLUpFromFile(o.sqlFile)\n\t\tif err != nil {\n\t\t\treturn 0, herrors.E(op, fmt.Errorf(\"cannot set sql file: %w\", err))\n\t\t}\n\t}\n\n\tif o.sqlServer {\n\t\tdata, err := migrateDrv.ExportSchemaDump(\n\t\t\to.includeSchemas,\n\t\t\to.excludeSchemas,\n\t\t\to.Source.Name,\n\t\t\to.Source.Kind,\n\t\t)","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/commands/migrate_create.go#L209-L245","documentation":"`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.","triggerScenarios":"`hasura migrate create ... --sql-server` against an unreachable server, unsupported source kind, or when config v3 setup cannot resolve the named database.","commonSituations":"Creating server-based SQL migrations while the local dev server is down; --database-name pointing to a non-existent source; old config.yaml version.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"hasura migrate status --database-name \"$DB\" >/dev/null || echo \"cannot init migrate driver\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify server and source before using --sql-server","Keep config.yaml version current"],"tags":["migrate-create","driver-init","hasura-cli"],"backgroundTag":"migration-driver-init-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}