Drizzle ORM, Drizzle Kit and Drizzle Pulse v1.0.0-rc.6 release

Drizzle ORM

Breaking changes

New features

Improvements and fixes

Drizzle Kit

Breaking changes

Improvements

Fixes

Drizzle Pulse

Drizzle Pulse keeps query results up to date by streaming changes from PostgreSQL’s write-ahead log. It requires wal_level = logical and now follows the same release version as Drizzle ORM and Drizzle Kit.

See the Drizzle Pulse overview and server setup guide.

In this example, a live collection tracks orders with the accepted status. The event stream reports inserts, updates and deletes relative to that query result. See live collections and CDC event streams.

import { drizzle } from 'drizzle-orm/postgres';
import { pulse } from 'drizzle-pulse';
import { createRuntime } from 'drizzle-pulse/embedded';
import { z } from 'zod';
import { orders } from './schema.ts';

// Queries are defined once, on the server; `.args()` takes any Standard Schema
const ordersByStatus = pulse(orders)
  .args(z.object({ status: z.enum(['requested', 'accepted', 'completed', 'cancelled']) }))
  .query((ctx) => ctx.query({ status: ctx.args.status }));

const runtime = createRuntime({
  queries: { ordersByStatus },
  databaseUrl: process.env.DATABASE_URL!,
  // the app's own connection: baseline reads keep its session context (RLS, `search_path`)
  sourceDb: drizzle(process.env.DATABASE_URL!),
});

// provisions the publication, replication slot and events tables, then starts reading the WAL
await runtime.start();

// Live collection: current result, kept up to date
const accepted = await runtime.client.ordersByStatus({ status: 'accepted' });
console.log(accepted.list());
accepted.onChange(({ events, state }) => console.log(events, state));

// CDC event stream: `insert` / `update` / `delete` relative to the query's result
const unsubscribe = runtime.events.ordersByStatus({ status: 'accepted' }, (event, lsn) => console.log(event.op, lsn));

Breaking changes

New features

Improvements and fixes

Sources