Telaio
Upgrade Guide

Upgrading to v1.13

PostgreSQL driver migration from pg to postgres.js

Upgrading to v1.13

Telaio's PostgreSQL driver changed from pg (node-postgres) to postgres (postgres.js). The Kysely dialect changed from PostgresDialect to PostgresJSDialect (via kysely-postgres-js).

Dependency changes

# Remove old deps
pnpm remove pg @types/pg postgres-array

# Add new deps
pnpm add postgres kysely-postgres-js

# pg is still needed as a dev dep for kysely-codegen introspection
pnpm add -D pg

Removed: registerCitextParser

The registerCitextParser function has been removed. postgres.js handles PostgreSQL types natively, so no custom parser registration is required for CITEXT or CITEXT[] columns.

// Before -- remove this
import { registerCitextParser } from 'telaio/db';
await registerCitextParser(pool);

// After -- nothing needed

Removed: WithDatabaseOptions.citext

The citext option on .withDatabase() has been removed along with registerCitextParser.

// Before
.withDatabase({ citext: false })

// After
.withDatabase()

Pool type change

The type of app.pool (and the argument to createDatabase) changed from pg.Pool to import('postgres').Sql.

// Before
import type pg from 'pg';
const pool: pg.Pool = await createPool(config);

// After
import type postgres from 'postgres';
const sql: postgres.Sql = await createPool(config);

Query API change

Direct pool queries using pool.query() must be rewritten as tagged template literals:

// Before
await pool.query('SELECT $1::text as message', ['hello']);

// After
await sql`SELECT ${sql('hello')}::text as message`;

If you were using raw pool queries for migrations or scripts, update them to the tagged template syntax.

Shutdown lifecycle

db.destroy() no longer implicitly closes the underlying connection. You must call sql.end() explicitly:

// Before -- db.destroy() also closed the pg Pool
await db.destroy();

// After -- must close sql separately
await db.destroy();
await sql.end();

The builder's app.stop() handles this automatically. The change only affects code that calls db.destroy() directly.

On this page