{"record":{"id":"78cef344d459fdfd","repo":"nikivdev/code","slug":"postgres-project-path-not-found-override-with","errorCode":null,"errorMessage":"Postgres project path not found: {} (override with --project)","messagePattern":"Postgres project path not found: (.+?) \\(override with --project\\)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/storage.rs","lineNumber":96,"sourceCode":"        println!(\"Generating migrations in {}\", project_dir.display());\n        run_bun_script(&project_dir, \"db:generate\", Some(&database_url))?;\n    }\n\n    println!(\"Applying migrations in {}\", project_dir.display());\n    run_bun_script(&project_dir, \"db:migrate\", Some(&database_url))\n}\n\nfn resolve_postgres_project(project: Option<PathBuf>) -> Result<PathBuf> {\n    let path = match project {\n        Some(path) => path,\n        None => PathBuf::from(tilde(DEFAULT_POSTGRES_PROJECT).as_ref()),\n    };\n\n    if path.exists() {\n        return Ok(path);\n    }\n\n    bail!(\n        \"Postgres project path not found: {} (override with --project)\",\n        path.display()\n    )\n}\n\nfn resolve_database_url(database_url: Option<&str>, project_dir: &Path) -> Result<String> {\n    if let Some(url) = database_url {\n        let trimmed = url.trim();\n        if !trimmed.is_empty() {\n            return Ok(trimmed.to_string());\n        }\n    }\n\n    for key in [\n        \"DATABASE_URL\",\n        \"PLANETSCALE_DATABASE_URL\",\n        \"PSCALE_DATABASE_URL\",\n    ] {","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/storage.rs#L78-L114","documentation":"resolve_postgres_project validates that the Postgres (Drizzle/Bun) project directory exists before running generation or migrations. If the resolved project path (from --project, config, or a default like `postgres` under the app dir) does not exist on disk, it bails with this message. The message also hints that --project can override the path.","triggerScenarios":"Calling postgres_generate or postgres_migrate when the resolved project directory's path.exists() returns false — i.e. the default directory was never created, the configured path is wrong/typo'd/renamed, or the command is run from the wrong working directory.","commonSituations":"Fresh clone where the postgres subproject hasn't been initialized; user renamed or moved the project folder; running the CLI outside the repo root so relative path resolution misses; typo in the configured project path; monorepo where the schema lives in a package the default path doesn't point at.","solutions":["Re-run the command with an explicit --project <path> pointing at the existing Postgres project directory.","Verify the project directory exists (ls the resolved path) and that you're running the CLI from the expected working directory.","Create or restore the missing directory (e.g. scaffold the Drizzle project or check out the deleted files).","Fix the configured/default project path in your config if it points to an old location."],"exampleFix":"// before\nmyapp db migrate\n// error: Postgres project path not found: ./services/postgres\n// after\nmyapp db migrate --project ./packages/db-postgres","handlingStrategy":"validation","validationCode":"const projectPath = getResolvedPostgresProjectPath();\nif (!fs.existsSync(projectPath)) {\n  throw new Error(`Postgres project dir missing: ${projectPath}. Pass --project <path>.`);\n}\nawait cli.postgresMigrate({ project: projectPath });","typeGuard":"function isExistingDir(p: string): p is string {\n  return fs.existsSync(p) && fs.statSync(p).isDirectory();\n}","tryCatchPattern":"try {\n  await postgresMigrate({ project });\n} catch (e) {\n  if (String(e).includes('Postgres project path not found')) {\n    console.error(`Project dir not found at configured path; pass --project explicitly.`);\n  }\n  throw e;\n}","preventionTips":["Always pass --project explicitly in CI instead of relying on default path resolution.","Run CLI commands from the repository root where relative defaults resolve correctly.","Add a setup step that creates/scaffolds the postgres project directory on fresh clones.","Lint configured project paths against the filesystem in a preflight check."],"tags":["filesystem","path","postgres","cli","config"],"backgroundTag":"project-path-not-found","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}