{"record":{"id":"940a92af9682ee69","repo":"hasura/graphql-engine","slug":"cannot-create-migration-w","errorCode":null,"errorMessage":"cannot create migration: %w","messagePattern":"cannot create migration: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/migrate/cmd/commands.go","lineNumber":260,"sourceCode":"\tfrom uint64,\n\tto int64,\n\tversion int64,\n\tname, directory string,\n) (versions []int64, err error) {\n\tvar op errors.Op = \"cmd.SquashCmd\"\n\n\tversions, upSql, downSql, err := m.Squash(from, to)\n\tif err != nil {\n\t\treturn versions, errors.E(op, err)\n\t}\n\n\tcreateOptions := New(version, name, directory)\n\tcreateOptions.SQLUp = upSql\n\tcreateOptions.SQLDown = downSql\n\n\terr = createOptions.Create()\n\tif err != nil {\n\t\treturn versions, errors.E(op, fmt.Errorf(\"cannot create migration: %w\", err))\n\t}\n\n\treturn versions, nil\n}\n\nfunc GotoVersionCmd(m *migrate.Migrate, gotoVersion int64) error {\n\tvar op errors.Op = \"cmd.GotoVersionCmd\"\n\n\terr := m.GotoVersion(gotoVersion)\n\tif err != nil {\n\t\treturn errors.E(op, err)\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":242,"sourceCodeEnd":276,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/cli/migrate/cmd/commands.go#L242-L276","documentation":"Returned by SquashCmd when creating the squashed migration files on disk fails after computing versions. The underlying createOptions.Create() error is wrapped with 'cannot create migration'.","triggerScenarios":"Running `hasura migrate squash` where writing the new migration files fails: unwritable migrations directory, a file with the same timestamp/version already exists, or invalid migration name.","commonSituations":"Read-only checkout, incorrect --name, running squash from the wrong directory, or leftover files from a previous squash attempt with the same version timestamp.","solutions":["Check the migrations directory is writable and the CLI is run from the project root","Remove or rename leftover partially-created migration files from a failed squash, then retry","Verify the --name flag produces a valid file name","Re-run squash; versions are recomputed each attempt"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"info, err := os.Stat(migrationsDir)\nif err != nil || !info.IsDir() { return fmt.Errorf(\"migrations dir missing\") }\nif err := os.WriteFile(filepath.Join(migrationsDir, \".probe\"), nil, 0644); err != nil { return err }\nos.Remove(filepath.Join(migrationsDir, \".probe\"))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run squash from the project root with a writable migrations directory","Clean up partial files after failed squash attempts before retrying"],"tags":["hasura","migration","squash","filesystem"],"backgroundTag":"migration-file-creation-failed","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}