{"record":{"id":"86be0cbe602903e4","repo":"hasura/graphql-engine","slug":"creating-target-migrations-directory-w","errorCode":null,"errorMessage":"creating target migrations directory: %w","messagePattern":"creating target migrations directory: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/internal/scripts/update-project-v3.go","lineNumber":173,"sourceCode":"\t// get directory names to move\n\tmigrationDirectoriesToMove, err := getMigrationDirectoryNames(\n\t\topts.Fs,\n\t\topts.MigrationsAbsDirectoryPath,\n\t)\n\tif err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"getting list of migrations to move: %w\", err))\n\t}\n\t// move seed child directories\n\t// get directory names to move\n\tseedFilesToMove, err := getSeedFiles(opts.Fs, opts.SeedsAbsDirectoryPath)\n\tif err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"getting list of seed files to move: %w\", err))\n\t}\n\n\t// create a new directory for TargetDatabase\n\ttargetMigrationsDirectoryName := filepath.Join(opts.MigrationsAbsDirectoryPath, targetDatabase)\n\tif err = opts.Fs.Mkdir(targetMigrationsDirectoryName, 0o755); err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"creating target migrations directory: %w\", err))\n\t}\n\n\t// create a new directory for TargetDatabase\n\ttargetSeedsDirectoryName := filepath.Join(opts.SeedsAbsDirectoryPath, targetDatabase)\n\tif err = opts.Fs.Mkdir(targetSeedsDirectoryName, 0o755); err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"creating target seeds directory: %w\", err))\n\t}\n\n\t// move migration directories to target database directory\n\tif err := copyMigrations(\n\t\topts.Fs,\n\t\tmigrationDirectoriesToMove,\n\t\topts.MigrationsAbsDirectoryPath,\n\t\ttargetMigrationsDirectoryName,\n\t); err != nil {\n\t\treturn errors.E(op, fmt.Errorf(\"moving migrations to target database directory: %w\", err))\n\t}\n\t// move seed directories to target database directory","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/internal/scripts/update-project-v3.go#L155-L191","documentation":"Thrown by UpdateProjectV3 when the CLI cannot create the per-database subdirectory (e.g. <migrations>/<targetDatabase>) while restructuring a config v2 project to the v3 multi-database layout. It wraps the underlying filesystem error (billyfs/afero Mkdir).","triggerScenarios":"Running `hasura scripts update-project-v3` when opts.MigrationsAbsDirectoryPath cannot accept a new subdirectory: read-only filesystem, permissions denied, the directory already exists, or a file with the same name exists.","commonSituations":"Running the update in a directory without write permission, on a mounted/read-only volume, re-running the script after a partial failure that already created the directory, or a corrupted migrations directory.","solutions":["Check the underlying error for EEXIST/EROFS/EACCES and fix permissions (chmod/chown) on the migrations directory","If the target directory already exists from a previous partial run, remove it or restore from backup before re-running","Ensure the project directory is writable and not on a read-only mount","Re-run `hasura scripts update-project-v3` once the filesystem issue is fixed"],"exampleFix":"# before\nhasura scripts update-project-v3\n# mkdir /path/to/migrations/postgres: file exists\n\n# after (clean partial state)\nrm -rf migrations/postgres seeds/postgres\nhasura scripts update-project-v3","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(filepath.Join(migrationsDir, targetDB)); err == nil {\n    return fmt.Errorf(\"target migrations dir already exists; remove it before re-running\")\n}\nif err := os.MkdirAll(migrationsDir, 0o755); err != nil { return err }","typeGuard":null,"tryCatchPattern":"if err := scripts.UpdateProjectV3(opts); err != nil {\n    if strings.Contains(err.Error(), \"creating target migrations directory\") {\n        // inspect wrapped fs error, fix perms/existing dir, retry after cleanup\n    }\n}","preventionTips":["Run the script from a writable checkout owned by the current user","Back up migrations/ and seeds/ before running update-project-v3","Never re-run the script over a half-completed run without cleanup"],"tags":["filesystem","mkdir","permissions","hasura-cli","config-v3-migration"],"backgroundTag":"filesystem-permission-denied","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}