Skip to content

d1 import: fix Postgres SSL default, D1 metadata table, verify errors - #1433

Open
claude[bot] wants to merge 1 commit into
mainfrom
fix/d1-import-verify-issues
Open

claude[bot] wants to merge 1 commit into
mainfrom
fix/d1-import-verify-issues

Conversation

@claude

@claude claude Bot commented Sep 19, 2026

Copy link
Copy Markdown

<!-- ccr-slack-attribution -->
Requested by Elom Gomez

Summary

Four small fixes to the D1 (Cloudflare) → Postgres import/verify path:

  • Destination SSL default: the ephemeral destination role used sslmode=verify-full with no sslrootcert, so libpq fell back to ~/.postgresql/root.crt, which usually doesn't exist. Now defaults sslrootcert=system.
  • D1-internal table exclusion: _cf_METADATA is now excluded from schema conversion, data load, and verification, via the same exclusion mechanism already used for ORM bookkeeping tables (e.g. _prisma_migrations).
  • Verify error context: a raw scan error from the per-row signature check in verify is now wrapped with the table name and primary key value, matching the existing table-fingerprint error pattern.
  • --sqlite input path: passing --sqlite explicitly to verify no longer skips backfilling the dump's input path from saved migration state, since verification needs it later regardless.

Test plan

  • go build ./..., go vet ./..., go test ./internal/import/d1/...
  • Extended existing table-driven tests for the metadata exclusion and the --sqlite input-path backfill.

🤖 Generated with Claude Code

https://claude.ai/code/session_01MjeJgHVQNc5nQc15Yb9dNB

- Default sslrootcert=system for the destination Postgres role so
  verify-full mode doesn't fall back to a missing ~/.postgresql/root.crt.
- Exclude Cloudflare's _cf_METADATA table using the existing ORM/metadata
  table exclusion mechanism, so it's skipped during schema conversion,
  data load, and verify like other internal bookkeeping tables.
- Wrap the row-fetch error in postgresRowSignature with the table and
  primary key context, matching tableFingerprintFromPostgres.
- Backfill opts.InputPath from saved migration state when --sqlite is
  passed explicitly, since Verify() needs InputPath regardless.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MjeJgHVQNc5nQc15Yb9dNB
@no-itsbackpack
no-itsbackpack marked this pull request as ready for review September 19, 2026 16:02
@no-itsbackpack
no-itsbackpack requested a review from a team as a code owner September 19, 2026 16:02
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.

2 participants