Skip to content

A one-command switch from postgres to the fork, with a report of what to check #55

Closed

Description

@okomarov

Switching an existing project from postgres to @steadybrew/postgresjs should be one command that makes the switch and reports what to check, published to the Codemod registry as npx codemod @steadybrew/postgresjs-migrate.

Switch (the only auto-fix)

  • Add the npm alias in package.json: "postgres": "npm:@steadybrew/postgresjs@^4". The alias is preferred over rewriting imports because Drizzle (drizzle-orm/postgres-js, drizzle-kit), kysely-postgres-js and the tracers all match the name postgres.
  • Check the Node version (22 or newer) in engines, .nvmrc, Dockerfiles and CI files.

Static checks, reported with file and line

  • Code that 4.x behaviour changes affect: handles used after release() or after begin() returns, fetch_types: false with arrays, transaction sql.prepare(name) names, and code that expects a hang or a specific error where the fork now rejects with CONNECTION_ENDED, COPY_IN_PROGRESS or TRANSACTION_ROLLED_BACK.
  • Workarounds the fork makes unnecessary: Promise.race query timeouts, a custom json serializer for Drizzle, and patch-package patches of postgres.

Runtime check for value serialization

Static analysis can't see column types, so the report recommends running with parameter_types: 'warn' in staging or production for a few days (#41, #42, #43). Zero warnings is the signal to switch to 'client'.

Tracing check

Detect dd-trace and @sentry/node (and other @sentry/* server SDKs) and say what the switch means for database spans:

  • dd-trace matches the alias by path and version >=3.0.0; spans match upstream from 4.5.0 on. Under the scoped name without the alias there are no spans.
  • Sentry's automatic integration targets postgres >=3.0.0 <4, so it records no spans on 4.x. Offer to add the README's sentry-postgres.mjs preload, which widens that range before Sentry registers its hooks, and the --import flag that loads it first. Under pnpm, also add @sentry/server-utils at the @sentry/node version.

Done when

  • The codemod runs against a sample project using Drizzle, one using Kysely and one using plain postgres, and each test case checks its report.
  • It is published to the Codemod registry with trusted publishing from this repository.

Activity

  1. moved this to In progress in Roadmapon Oct 15, 2026
  2. added
    area: project
    enhancement
    on Oct 16, 2026
  3. okomarov commented on Oct 18, 2026

    @okomarov
    Author

    Shipped as @steadybrew/postgresjs-migrate 0.1.0, on npm and on the Codemod registry:

    npx @steadybrew/postgresjs-migrate .            # report only
    npx @steadybrew/postgresjs-migrate . --switch   # report, then switch
    npx codemod @steadybrew/postgresjs-migrate      # the same switch from the Codemod registry
    • Checks: fixture projects for every rule, plus 15 real projects at pinned commits (Drizzle, Kysely and plain postgres among them) whose reports are checked on every change. Installs with npm, pnpm and yarn after --switch are checked to load the fork, including a dependency that brings its own postgres.
    • Publishing: migrate-v* tags stage new versions on npm through trusted publishing and publish to the Codemod registry with GitHub OIDC. 0.1.0 was published once by hand, because npm only lets a package that already exists set up trusted publishing, so it has no provenance; later versions do.
    • Sentry: the report lists it and --switch links the README's preload. It does not write the preload into the project.
  4. moved this from In progress to Shipped in Roadmapon Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: projectenhancement

    Type

    No type

    Projects

    • Status
      Shipped

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions