{"record":{"id":"906e71b3270f3426","repo":"hasura/graphql-engine","slug":"applying-migrations-failed-on-database-s-s","errorCode":null,"errorMessage":"applying migrations failed on database(s): %s","messagePattern":"applying migrations failed on database\\(s\\): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"cli/commands/migrate_apply.go","lineNumber":268,"sourceCode":"\tif err != nil {\n\t\treturn herrors.E(op, err)\n\t}\n\n\tvar failedSources []string\n\n\tfor result := range results {\n\t\tif result.Error != nil {\n\t\t\tfailedSources = append(failedSources, result.DatabaseName)\n\t\t\to.EC.Logger.Errorf(\"%v\", result.Error)\n\t\t} else if len(result.Message) > 0 {\n\t\t\to.EC.Logger.Infof(\"%s\", result.Message)\n\t\t}\n\t}\n\n\tif len(failedSources) != 0 {\n\t\treturn herrors.E(\n\t\t\top,\n\t\t\tfmt.Errorf(\n\t\t\t\t\"applying migrations failed on database(s): %s\",\n\t\t\t\tstrings.Join(failedSources, \",\"),\n\t\t\t),\n\t\t)\n\t}\n\n\treturn nil\n}\n\ntype MigrateApplyResult struct {\n\tDatabaseName string\n\tMessage      string\n\tError        error\n}\n\nfunc (o *MigrateApplyOptions) Apply() (chan MigrateApplyResult, error) {\n\tvar op herrors.Op = \"commands.MigrateApplyOptions.Apply\"\n","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/commands/migrate_apply.go#L250-L286","documentation":"`hasura migrate apply` attempts migrations across the requested sources and collects names of databases whose migration run returned an error. If any failed, it reports the comma-joined list; the per-source error details were already logged above.","triggerScenarios":"One or more sources return an error during their migration execution loop (bad SQL in a version file, connection failure to the database, version-chain conflict).","commonSituations":"A migration file fails against one database (e.g. PG syntax on a BigQuery source) while others succeed; database credentials changed; inconsistent migration history on the server.","solutions":["Scroll up in the output for the per-database error — this message only lists which sources failed","Fix the offending migration file or database state for each listed source","Run `hasura migrate status --database-name <failed>` to inspect version chain state","For history inconsistencies, consider `hasura migrate delete --up-to <version>` or squashing"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"hasura migrate status --database-name \"$DB\"","typeGuard":null,"tryCatchPattern":"err := applyCmd.Execute(); if err != nil && strings.Contains(err.Error(), \"applying migrations failed on database(s)\") { for _, db := range strings.Split(extractList(err), \",\") { fmt.Println(\"check logs for\", db) } }","preventionTips":["Run migrate status per database before apply","Test migration files against each target database kind locally"],"tags":["migrate-apply","multi-source","migration-failure"],"backgroundTag":"migration-apply-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}