hasura/graphql-engine · error
moving migrations to target database directory: %w
Error message
moving migrations to target database directory: %w
What it means
UpdateProjectV3 could not copy the old per-database migration directories into the newly created target migrations directory. copyMigrations uses util.CopyDirAfero/CopyFileAfero and this error wraps their failure.
Source
Thrown at cli/internal/scripts/update-project-v3.go:189
targetMigrationsDirectoryName := filepath.Join(opts.MigrationsAbsDirectoryPath, targetDatabase)
if err = opts.Fs.Mkdir(targetMigrationsDirectoryName, 0o755); err != nil {
return errors.E(op, fmt.Errorf("creating target migrations directory: %w", err))
}
// create a new directory for TargetDatabase
targetSeedsDirectoryName := filepath.Join(opts.SeedsAbsDirectoryPath, targetDatabase)
if err = opts.Fs.Mkdir(targetSeedsDirectoryName, 0o755); err != nil {
return errors.E(op, fmt.Errorf("creating target seeds directory: %w", err))
}
// move migration directories to target database directory
if err := copyMigrations(
opts.Fs,
migrationDirectoriesToMove,
opts.MigrationsAbsDirectoryPath,
targetMigrationsDirectoryName,
); err != nil {
return errors.E(op, fmt.Errorf("moving migrations to target database directory: %w", err))
}
// move seed directories to target database directory
if err := copyFiles(
opts.Fs,
seedFilesToMove,
opts.SeedsAbsDirectoryPath,
targetSeedsDirectoryName,
); err != nil {
return errors.E(op, fmt.Errorf("moving seeds to target database directory: %w", err))
}
opts.EC.Logger.Debug("completed: copy old migrations to new directory structure")
opts.EC.Logger.Debug("start: generate new config file")
opts.EC.Spin("Generating new config file ")
// write new config file
newConfig := *opts.EC.Config
View on GitHub (pinned to 724551b9ae)
Solutions
- Check the wrapped error for the exact file that failed; verify it exists and is readable
- Free disk space and close programs holding locks on the migrations directory
- Restore a clean backup of migrations/ and re-run the script
- Re-run `hasura scripts update-project-v3`
Defensive patterns
Strategy: try-catch
Validate before calling
for _, d := range migrationDirs {
if fi, err := os.Stat(filepath.Join(migrationsDir, d)); err != nil || !fi.IsDir() {
return fmt.Errorf("missing migration dir %s", d)
}
} Try / catch
if err := scripts.UpdateProjectV3(opts); err != nil {
if strings.Contains(err.Error(), "moving migrations to target database directory") { /* check locked/missing files, retry */ }
} Prevention
- Close editors/tools that lock migration files
- Commit migrations to VCS so restore is trivial
- Run the upgrade on a quiet tree with no concurrent processes
When it happens
Trigger: `hasura scripts update-project-v3` when a migration directory or file listed for the move cannot be read (permissions, missing after concurrent modification) or written into the new target directory.
Common situations: Locked files (Windows/IDE), migrations modified by another process mid-upgrade, disk full, or a stale file list from a partially completed earlier run.
Related errors
- moving %s to %s : %w
- error in copying starter kit: %w
- getting list of migrations to move: %w
- moving seeds to target database directory: %w
- removing up original migrations: %w
AI-assisted analysis of hasura/graphql-engine@724551b9ae (2026-08-28).
Data as JSON: /api/errors/f70318094923dc14.
Report an issue: GitHub.