{"record":{"id":"ea30f4cefe7ef14c","repo":"hasura/graphql-engine","slug":"applying-migrations-on-source-s-w","errorCode":null,"errorMessage":"applying migrations on source: %s: %w","messagePattern":"applying migrations on source: (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/commands/init.go","lineNumber":575,"sourceCode":"\t\tif err != nil {\n\t\t\tcontext.err = err\n\t\t\tcontext.logger.Debugf(\n\t\t\t\t\"getting list of connected databases from server (%s) failed\",\n\t\t\t\tcontext.initOps.Endpoint,\n\t\t\t)\n\n\t\t\treturn createMigrationFailed\n\t\t}\n\n\t\tfor _, source := range sources {\n\t\t\topts.EC.Logger.Infof(\"Creating migrations for source: %s\", source.Name)\n\t\t\topts.Source = cli.Source(source)\n\n\t\t\t_, err := opts.run()\n\t\t\tif err != nil {\n\t\t\t\terrs = append(\n\t\t\t\t\terrs,\n\t\t\t\t\tfmt.Errorf(\"applying migrations on source: %s: %w\", source.Name, err),\n\t\t\t\t)\n\t\t\t}\n\t\t}\n\t}\n\n\tif len(errs) > 0 {\n\t\tcontext.err = stderrors.Join(errs...)\n\n\t\treturn createMigrationFailed\n\t}\n\n\treturn gotoEndstate\n}\n\ntype failedCreatingMigrationAction struct{}\n\nfunc (a *failedCreatingMigrationAction) Execute(ctx fsm.EventContext) eventType {\n\tcontext := ctx.(*initCtx)","sourceCodeStart":557,"sourceCodeEnd":593,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/commands/init.go#L557-L593","documentation":"During `hasura init --endpoint <url>` with metadata/migrations fetch, applying fetched migrations to a named source failed; the CLI collects per-source errors and wraps them as 'applying migrations on source: <name>'.","triggerScenarios":"Init from an endpoint where the source database is unreachable from your machine, admin secret invalid for the source, or a fetched migration fails to apply (version conflict, incompatible SQL).","commonSituations":"Source DB behind a firewall not reachable from the init environment; server requires credentials the CLI lacks; migrations reference objects existing only on the server's source; clock/version conflicts causing 'migration already applied' style failures.","solutions":["Verify network reachability and credentials for the specific source database named in the error","Use --dry-run style inspection or fetch metadata/migrations without applying, then apply manually with fixes","Resolve migration version conflicts on the target (mark applied or adjust down migrations)","Retry init from an environment with access to the source DB"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// verify source DB reachability before init --endpoint\nif _, err := net.DialTimeout(\"tcp\", sourceDbHost+\":\"+sourceDbPort, 5*time.Second); err != nil {\n    log.Fatal(\"source DB unreachable from this environment\")\n}","typeGuard":null,"tryCatchPattern":"for attempt := 1; attempt <= 3; attempt++ {\n    if err := initRun(); err != nil && strings.Contains(err.Error(), \"applying migrations on source\") {\n        time.Sleep(time.Duration(attempt) * 2 * time.Second)\n        continue\n    } else if err != nil { break }\n}","preventionTips":["Run init from an environment with network access to source databases","Validate admin secret/permissions for all sources first","Resolve migration version conflicts before re-applying"],"tags":["hasura","cli","init","migrations","sources","network"],"backgroundTag":"migration-apply-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}