hasura/graphql-engine · error

error removing migrations from project: %w

Error message

error removing migrations from project: %w

What it means

Thrown when deleting the migration files from the project directory fails after server-side removal succeeded (only when --only-server is not set). DeleteVersions removes the version files from the migrations directory on disk.

Source

Thrown at cli/commands/migrate_delete.go:204

			}

			if v.IsPresent {
				sourceVersions = append(sourceVersions, k)
			}
		}
	}

	// resets the migrations on server
	err = migrateDrv.RemoveVersions(serverVersions)
	if err != nil {
		return errors.E(op, fmt.Errorf("error removing migration from server: %w", err))
	}

	// removes the migrations on source
	if !o.OnlyServer {
		err = DeleteVersions(o.EC, sourceVersions, o.Source)
		if err != nil {
			return errors.E(op, fmt.Errorf("error removing migrations from project: %w", err))
		}
	}

	o.EC.Spinner.Stop()
	o.EC.Logger.Infof("Deleted migrations")

	return nil
}

func DeleteVersions(ec *cli.ExecutionContext, versions []uint64, source cli.Source) error {
	var op errors.Op = "commands.DeleteVersions"

	for _, v := range versions {
		delOptions := mig.CreateOptions{
			Version:   strconv.FormatUint(v, 10),
			Directory: filepath.Join(ec.MigrationDir, source.Name),
		}

View on GitHub (pinned to 724551b9ae)

Solutions

  1. Check permissions on the migrations directory (chmod/chown)
  2. Delete the leftover files manually if a prior run half-completed
  3. Re-run migrate status to reconcile disk vs server state
Defensive patterns

Strategy: validation

Validate before calling

// pre-flight writability check
if err := unix.Access(migrationsDir, unix.W_OK); err != nil { log.Fatal("read-only migrations dir") }

Prevention

When it happens

Trigger: Read-only migrations directory, permission denied, or files already deleted/renamed so the expected file paths are missing.

Common situations: Project directory owned by another user, editor/IDE locking files, out-of-sync disk state after a previous partial delete.

Related errors


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