/** * Drizzle ORM adapter for postgres.do * * This module provides first-class Drizzle ORM integration with postgres.do, * enabling type-safe database queries in Cloudflare Workers and other * serverless environments. * * @example Basic usage * ```typescript * import { drizzle } from 'postgres.do/drizzle' * import postgres from 'postgres.do' * import { users } from './schema' * * const sql = postgres('postgres://db.postgres.do/mydb') * const db = drizzle(sql) * * // Type-safe queries * const allUsers = await db.select().from(users) * ``` * * @example With schema and relations * ```typescript * import { drizzle } from 'postgres.do/drizzle' * import postgres from 'postgres.do' * import * as schema from './schema' * * const sql = postgres('postgres://db.postgres.do/mydb') * const db = drizzle(sql, { schema }) * * // Query with relations * const usersWithPosts = await db.query.users.findMany({ * with: { posts: true } * }) * ``` * * @example In a Durable Object * ```typescript * import { drizzle } from 'postgres.do/drizzle' * import { PostgresDO } from 'postgres.do' * import * as schema from './schema' * * export class MyDatabase extends PostgresDO { * db = drizzle(this.sql, { schema }) * * async getActiveUsers() { * return this.db * .select() * .from(schema.users) * .where(eq(schema.users.active, true)) * } * } * ``` * * @packageDocumentation */ // Main exports export { drizzle, PostgresDoDatabase, type PostgresDoDriverOptions } from './driver.js' // Session exports export { PostgresDoSession, PostgresDoPreparedQuery, PostgresDoTransaction, type PostgresDoClient, type PostgresDoSessionOptions, type PostgresDoQueryResultHKT, } from './session.js' // Migrator export (re-exported for convenience, also available at postgres.do/drizzle/migrator) export { migrate } from './migrator.js' // ============================================================================ // Drizzle Migrations Integration // ============================================================================ // Drizzle migrator for postgres.do export { DrizzleMigrator, createDrizzleMigrator, parseDrizzleJournal, bundleDrizzleMigrations, type DrizzleJournal, type DrizzleJournalEntry, type BundledDrizzleMigrations, type DrizzleMigrationRecord, type DrizzleMigrationResult, type DrizzleMigrationProgressEvent, type DrizzleMigratorConfig, type DrizzleMigratorState, } from './drizzle-migrator.js' // Migration bridge between Drizzle and postgres.do export { MigrationBridge, createMigrationBridge, convertDrizzleToPostgresDo, runCombinedMigrations, type PostgresDoMigration, type MigrationBridgeConfig, type CombinedMigratorConfig, } from './migration-bridge.js' // Auto Drizzle Migrator - unified migration runner for DO init export { AutoDrizzleMigrator, createAutoDrizzleMigrator, type AutoDrizzleMigratorConfig, type AutoDrizzleMigrationResult, type AutoDrizzleMigratorState, } from './auto-drizzle-migrator.js' // Schema generator exports export { // High-level API generateSchemaFromTypeScript, generateSchemaFromDatabase, generateSchemaWithTypes, // Low-level API introspectDatabase, parseTypeScriptInterfaces, convertInterfacesToTables, generateDrizzleSchema, // Types type SchemaColumnDefinition, type SchemaTableDefinition, type SchemaIndexDefinition, type SchemaEnumDefinition, type DatabaseSchemaDefinition, type SchemaGeneratorOptions, type TypeScriptInterface, type TypeScriptProperty, type DrizzleColumnType, } from './schema-generator.js' // ============================================================================ // Schema Diff and Sync // ============================================================================ // Schema diff and migration generation export { // High-level API compareSchemas, compareDatabaseToSchema, diffSchemas, generateMigrationSQL, generateDrizzleMigration, // Formatting formatSchemaDiff, formatSchemaDiffJSON, // Types type SchemaDiff, type SchemaDiffOptions, type MigrationSQLOptions, type GeneratedMigration, type TableChange, type ColumnChange, type IndexChange, type EnumChange, type ColumnAttributeChange, type ChangeType, } from './schema-diff.js'