hasura/graphql-engine · error

down migration with SQL string could not be created: %w

Error message

down migration with SQL string could not be created: %w

What it means

Mirror of error 116 for the --down flag: createOptions.SetSQLDown(o.downSQL) failed while validating/storing the down SQL string, typically because it is empty or whitespace-only.

Source

Thrown at cli/commands/migrate_create.go:275

	}

	// 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 {
			return 0, herrors.E(
				op,
				fmt.Errorf("down migration with SQL string could not be created: %w", err),
			)
		}
	}

	if o.sqlFile == "" && !o.sqlServer && o.EC.Config.Version != cli.V1 {
		// Set empty data for [up|down].sql
		if !o.upSQLChanged {
			createOptions.SQLUp = []byte(``)
		}

		if !o.downSQLChanged {
			createOptions.SQLDown = []byte(``)
		}
	}

	defer func() {
		if err != nil {
			err := createOptions.Delete()

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Verify the --down value is non-empty SQL
  2. Omit --down entirely if no down migration is needed (a default empty down may be created)
  3. Fix shell quoting/variable expansion
Defensive patterns

Strategy: validation

Validate before calling

[ -n "$(echo "$DOWN_SQL" | tr -d '[:space:]')" ] || { echo 'empty --down'; exit 1; }

Prevention

When it happens

Trigger: `hasura migrate create X --down ""` or --down "$DOWN" with DOWN unset/empty.

Common situations: Scripts that always pass both --up and --down but the down variable is conditionally empty.

Related errors


AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28). Data as JSON: /api/errors/b18f21d775497379. Report an issue: GitHub.