Skip to content

refactor(postgres-adapter): relocate api/ → cli/api/ + update imports (Phase 2) - #5

Closed
ihistand wants to merge 1 commit into
adapter/postgres-depsfrom
adapter/postgres-relocate
Closed

refactor(postgres-adapter): relocate api/ → cli/api/ + update imports (Phase 2)#5
ihistand wants to merge 1 commit into
adapter/postgres-depsfrom
adapter/postgres-relocate

Conversation

@ihistand

Copy link
Copy Markdown
Collaborator

Summary

Phase 2 of `adapter/postgres-first-class` per `docs/postgres_first_class_design.md` — Phases 1-2 are inherited verbatim from `docs/postgres_reintegration_assessment.md`.

Moves the restored Postgres adapter files into the modern Dataform/sqlanvil CLI layout:

From To
`api/dbadapters/postgres.ts` `cli/api/dbadapters/postgres.ts`
`api/utils/postgres.ts` `cli/api/utils/postgres.ts`

Empty root-level `api/` directory removed.

Import path updates (mechanical)

Old New
`sa/api/commands/credentials` `sa/cli/api/commands/credentials`
`sa/api/dbadapters/index` `sa/cli/api/dbadapters/index`
`sa/api/utils/postgres` `sa/cli/api/utils/postgres`
`sa/api/utils/results` `sa/cli/api/utils/results`
`sa/core/adapters` `sa/cli/api/dbadapters/execution_sql`

Also dropped the (now-broken) imports for symbols that were deleted upstream when non-BQ warehouses were removed:

  • `sa/api/ssh_tunnel_proxy` (gone via upstream commit `b4d2b2f2`)
  • `sa/api/utils/error_parsing` → `parseRedshiftEvalError` (gone)

Why the file still won't compile yet

The body still references `SSHTunnelProxy` and `parseRedshiftEvalError` (used in the SSH block and the `evaluate()` method respectively). Plus the adapter is missing `executeRaw` and `deleteTable` and uses `sqlanvil.IJDBC` which doesn't exist in current protos. That's Phase 3 scope — interface alignment + proto additions + SSH removal + error formatter swap.

Until Phase 3 lands, the file is excluded from the BUILD globs in both `cli/api/BUILD` and `cli/api/utils/BUILD`:

```bazel

cli/api/BUILD

exclude = [
"utils//.",
"
/*_test.ts",
"dbadapters/postgres.ts", # ← Phase 2
],

cli/api/utils/BUILD

exclude = ["postgres.ts"], # ← Phase 2
```

Verification

```bash
./scripts/docker-bazel build //... # → 139 targets, success
```

Stack

Stacked on PR #4 (`adapter/postgres-deps`). Merge order: #1#2#3#4 → this.

Next

Phase 3a — implement `PostgresDbAdapter` against the current `IDbAdapter` contract. Removes the BUILD excludes added here.

Test plan

  • `./scripts/docker-bazel build //...` (139 targets)
  • File compiles standalone (intentionally — Phase 3)

🤖 Generated with Claude Code

… (Phase 2)

Phase 2 of `adapter/postgres-first-class` per docs/postgres_first_class_design.md
(Phases 1-2 inherited verbatim from docs/postgres_reintegration_assessment.md).

Moves the restored Postgres adapter files into the modern Dataform/sqlanvil
CLI layout:

  api/dbadapters/postgres.ts → cli/api/dbadapters/postgres.ts
  api/utils/postgres.ts      → cli/api/utils/postgres.ts

Updated imports (mechanical) to point at the current `cli/api/...`
modules:

  sa/api/commands/credentials       → sa/cli/api/commands/credentials
  sa/api/dbadapters/index           → sa/cli/api/dbadapters/index
  sa/api/utils/postgres             → sa/cli/api/utils/postgres
  sa/api/utils/results              → sa/cli/api/utils/results
  sa/core/adapters                  → sa/cli/api/dbadapters/execution_sql

Also dropped the (now-broken) imports for symbols that were deleted
upstream when non-BQ warehouses were removed:

  sa/api/ssh_tunnel_proxy           — gone, deleted via commit b4d2b2f
  sa/api/utils/error_parsing        — gone (parseRedshiftEvalError)

The file still references `SSHTunnelProxy` and `parseRedshiftEvalError`
in the body; that's fine — file is **excluded from the BUILD glob** in
both `cli/api/BUILD` and `cli/api/utils/BUILD` until Phase 3 does the
proper interface alignment (executeRaw, deleteTable, schemas signature,
sqlanvil.IJDBC → new PostgresConnection proto, SSH removal, error
formatter swap).

Verified:
  ./scripts/docker-bazel build //...   → 139 targets, success

Empty root-level api/ directory removed.

Next: Phase 3a — implement IDbAdapter against the relocated file.
ihistand added a commit that referenced this pull request Jun 4, 2026
…(no hardcode)

#4: The two index_compile_test cases that npm-install specific @sqlanvil/core
versions (2.9.0, 3.0.50) from the public registry can't pass until those are
published (only 0.0.1 placeholders exist). Gate them behind
SA_TEST_PUBLISHED_CORE so //cli:tests is green by default; opt in once published.

#5: DEFAULT_DATABASE was a hardcoded "sqlanvil" working edit. Make index_test_base
derive the project from test_credentials/bigquery.json's projectId (same source
tests/integration/utils.ts uses), overridable via SA_TEST_BIGQUERY_PROJECT, with a
placeholder fallback. No hardcoded project committed; no machine-specific working
edits. The bigquery_project/workflow_settings.yaml `defaultProject` placeholder is
left as-is (the integration specs override it from the creds projectId).

Verified: //cli:index_compile_test passes (2 gated tests skipped),
//cli:index_run_e2e_test passes against live BigQuery (project from creds).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@ihistand

ihistand commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded: the Postgres reintegration + Dataform→SQLAnvil rename landed on main directly, and the docs moved to the SQLAnvil/docs repo. Closing as part of #12 (stale-branch prune). The one un-migrated draft, gcp_test_project_setup.md, was migrated to SQLAnvil/docs.

@ihistand ihistand closed this Jun 7, 2026
@ihistand
ihistand deleted the adapter/postgres-relocate branch June 7, 2026 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant