hasura/graphql-engine · error
while writing data from server into the up.sql file: %w
Error message
while writing data from server into the up.sql file: %w
What it means
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).
Source
Thrown at cli/commands/migrate_create.go:254
}
}
if o.sqlServer {
data, err := migrateDrv.ExportSchemaDump(
o.includeSchemas,
o.excludeSchemas,
o.Source.Name,
o.Source.Kind,
)
if err != nil {
return 0, herrors.E(op, fmt.Errorf("cannot fetch schema dump: %w", err))
}
err = createOptions.SetSQLUp(string(data))
if err != nil {
return 0, herrors.E(
op,
fmt.Errorf("while writing data from server into the up.sql file: %w", err),
)
}
}
// create pure sql based migrations here
if o.upSQLChanged {
err = createOptions.SetSQLUp(o.upSQL)
if err != nil {
return 0, herrors.E(
op,
fmt.Errorf("up migration with SQL string could not be created: %w", err),
)
}
}
if o.downSQLChanged {
err = createOptions.SetSQLDown(o.downSQL)
if err != nil {View on GitHub (pinned to 724551b9ae)
Solutions
- Verify the database actually has schema objects to dump
- Retry after cleaning stale artifacts in migrations/
- Check wrapped error for template/validation specifics
Defensive patterns
Strategy: validation
Try / catch
if strings.Contains(err.Error(), "writing data from server into the up.sql") { /* verify DB has schema objects; retry */ } Prevention
- Skip --sql-server on empty databases
- Keep the migrations template directory intact
When it happens
Trigger: `hasura migrate create --sql-server` where ExportSchemaDump succeeded but the dump content cannot be set — typically empty dump or template parse failure.
Common situations: Empty database (dump is blank and validation rejects it), or a corrupted migrations directory template.
Related errors
- cannot fetch schema dump: %w
- cannot create migrate instance: %w
- cannot set sql file: %w
- up migration with SQL string could not be created: %w
- down migration with SQL string could not be created: %w
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/85efd700fc5e6eee.
Report an issue: GitHub.