Skip to content

Migrate connection string to new connections model#80

Merged
kristof-siket merged 3 commits intomainfrom
ptl-1046-migrate-create-db-to-use-new-connection-model-fields
Mar 2, 2026
Merged

Migrate connection string to new connections model#80
kristof-siket merged 3 commits intomainfrom
ptl-1046-migrate-create-db-to-use-new-connection-model-fields

Conversation

@kristof-siket
Copy link
Contributor

@kristof-siket kristof-siket commented Mar 2, 2026

Summary

Migrates create-db from reading deprecated apiKeys[0].directConnection fields to the new connections[0].endpoints.direct.connectionString from the Management API response (PTL-1046).

  • Reads the connection string directly from connections[0].endpoints.direct.connectionString, falling back to pooled.connectionString
  • Preserves backward compatibility by falling back to the legacy apiKeys path when connections is absent (for older API versions)
  • Removes manual postgresql://... DSN construction from the main flow
  • Adds ConnectionEndpoint and Connection type interfaces reflecting the new response shape

Context

PR #3365 added the new connection model to the Management API. The deprecated fields (apiKeys[0].directConnection.*) will be removed in a future release — this migration must land before that happens.

Test plan

  • Run npm test (unit tests pass locally)
  • Manually test against production Management API — verify connection string is returned correctly
  • Manually test against preview Management API — verify new connections[] path is used
  • Verify backward compat: when API returns only apiKeys (no connections), the legacy fallback still produces a valid connection string

Closes PTL-1046

Summary by CodeRabbit

  • New Features

    • Support for multiple connection endpoint types (direct, pooled, accelerate) for more flexible connectivity.
  • Improvements

    • Connection string resolution now prefers endpoint-provided connection strings instead of constructing them from individual credentials.
    • Internal flow refined for more reliable detection of available endpoints; no public API changes.

Loading
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