{"record":{"id":"85efd700fc5e6eee","repo":"hasura/graphql-engine","slug":"while-writing-data-from-server-into-the-up-sql-fil","errorCode":null,"errorMessage":"while writing data from server into the up.sql file: %w","messagePattern":"while writing data from server into the up\\.sql file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/commands/migrate_create.go","lineNumber":254,"sourceCode":"\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)\n\t\tif err != nil {\n\t\t\treturn 0, herrors.E(op, fmt.Errorf(\"cannot fetch schema dump: %w\", err))\n\t\t}\n\n\t\terr = createOptions.SetSQLUp(string(data))\n\t\tif err != nil {\n\t\t\treturn 0, herrors.E(\n\t\t\t\top,\n\t\t\t\tfmt.Errorf(\"while writing data from server into the up.sql file: %w\", err),\n\t\t\t)\n\t\t}\n\t}\n\n\t// create pure sql based migrations here\n\tif o.upSQLChanged {\n\t\terr = createOptions.SetSQLUp(o.upSQL)\n\t\tif err != nil {\n\t\t\treturn 0, herrors.E(\n\t\t\t\top,\n\t\t\t\tfmt.Errorf(\"up migration with SQL string could not be created: %w\", err),\n\t\t\t)\n\t\t}\n\t}\n\n\tif o.downSQLChanged {\n\t\terr = createOptions.SetSQLDown(o.downSQL)\n\t\tif err != nil {","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/commands/migrate_create.go#L236-L272","documentation":"After fetching a server schema dump (--sql-server), the dump text is loaded into the migration template via createOptions.SetSQLUp. This wraps failures writing/validating that content into the up.sql template (e.g. template generation or validation errors).","triggerScenarios":"`hasura migrate create --sql-server` where ExportSchemaDump succeeded but the dump content cannot be set — typically empty dump or template parse failure.","commonSituations":"Empty database (dump is blank and validation rejects it), or a corrupted migrations directory template.","solutions":["Verify the database actually has schema objects to dump","Retry after cleaning stale artifacts in migrations/","Check wrapped error for template/validation specifics"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":"if strings.Contains(err.Error(), \"writing data from server into the up.sql\") { /* verify DB has schema objects; retry */ }","preventionTips":["Skip --sql-server on empty databases","Keep the migrations template directory intact"],"tags":["migrate-create","sql-template","schema-dump"],"backgroundTag":"migration-template-write-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}