npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@migration-preflight/adapters-postgres

v0.2.0

Published

PGlite (in-memory WASM Postgres) driver for migration-preflight: test your Postgres migrations with no Docker, no external server.

Downloads

297

Readme

🐘 @migration-preflight/adapters-postgres



The Postgres driver for migration-preflight. A migration that silently drops or corrupts data usually only fails once it meets real data, and by then it already ran. This package is what lets that test run against Postgres.

Backed by PGlite, an in-memory WASM Postgres. No Docker, no external server, no network. It boots in milliseconds.

flowchart LR
    Core["migration-preflight<br/>(replay engine)"] --> Pg["@migration-preflight/adapters-postgres<br/>(PGlite)"]
    Pg --> Test["Your migrations,<br/>tested with real data"]

Install

pnpm add -D migration-preflight @migration-preflight/adapters-postgres

Two entry points

So a consumer of the raw driver never has to install drizzle-orm:

| Import | Use it for | | ------------------------------------------------ | ------------------------------------------------------- | | @migration-preflight/adapters-postgres | Seed-between-migrations tests, the one that matters | | @migration-preflight/adapters-postgres/drizzle | Quick "does the whole history apply cleanly" smoke test |

// Seed-between-migrations test
import { createPgliteMigrationDatabase } from "@migration-preflight/adapters-postgres";
// Quick smoke test
import { runDrizzlePgliteMigrations } from "@migration-preflight/adapters-postgres/drizzle";

Usage

Works with any bundled migration source, Drizzle, Prisma, or plain SQL files:

import { createPgliteMigrationDatabase } from "@migration-preflight/adapters-postgres";
import { MigrationChain } from "migration-preflight";
import { drizzleFileSource, prismaFileSource, sqlFileSource } from "migration-preflight/sources";

const migrations = drizzleFileSource(join(import.meta.dirname, "out"));
// or: prismaFileSource(join(import.meta.dirname, "../prisma/migrations"))
// or: sqlFileSource(join(import.meta.dirname, "migrations"))

const chain = new MigrationChain(createPgliteMigrationDatabase(), migrations);

await chain.applyAll();

See How-to § Pick a migration source for what each folder layout looks like.

Foreign keys behave differently here than in SQLite

foreignKeyViolations() always returns [] on Postgres; a violation surfaces as a thrown error from the run/transaction call that caused it instead. See Explanation for why, and How-to § Assert on foreign key integrity for how to test it.

Postgres extensions (e.g. pg_trgm)

If a migration runs CREATE EXTENSION ..., PGlite needs that extension loaded up front, by building the client yourself and passing it in. See How-to § Load Postgres extensions for the recipe.

Known issue: high memory use in tests

Each PGlite instance is a full WASM-compiled Postgres, roughly 700MB+ peak RSS on its own. See Explanation for why, and how this package's own test suite works around it.

📦 Packages

| Package | What it's for | | ------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------- | | migration-preflight | Core: replay engine, ports | | @migration-preflight/adapters-sqlite | SQLite driver (node:sqlite) | | @migration-preflight/adapters-postgres | Postgres driver (PGlite) |

@migration-preflight/adapters-postgres isn't linked above: that's this package.

📚 Documentation

Contributing

pnpm --filter @migration-preflight/adapters-postgres test:db        # run the test suite
pnpm --filter @migration-preflight/adapters-postgres typecheck      # type-check
pnpm --filter @migration-preflight/adapters-postgres lint           # eslint

License

MIT