From eb3a905058768cb7360cc7d638ccf16976460093 Mon Sep 17 00:00:00 2001 From: Michael Hadley Date: Tue, 10 Feb 2026 11:52:38 -0800 Subject: [PATCH] Make --dry-run a synchronize-specific option --dry-run was defined on BaseCommand but only implemented by the synchronize command. All other commands would throw "Dry run not yet supported." at runtime. Move the option to SynchronizeCommand and remove the dry-run plumbing from Pgslice. Co-Authored-By: Claude Opus 4.6 --- src/commands/base.ts | 7 ------- src/commands/synchronize.ts | 4 ++++ src/pgslice.ts | 8 -------- 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/commands/base.ts b/src/commands/base.ts index 54046f1..c90c04e 100644 --- a/src/commands/base.ts +++ b/src/commands/base.ts @@ -11,10 +11,6 @@ export abstract class BaseCommand extends Command { required: false, }); - dryRun = Option.Boolean("--dry-run", false, { - description: "Print statements without executing", - }); - protected getDatabaseUrl(): string { const url = this.url ?? process.env.PGSLICE_URL; if (!url) { @@ -27,9 +23,6 @@ export abstract class BaseCommand extends Command { try { this.context.pgslice ??= await Pgslice.connect( new URL(this.getDatabaseUrl()), - { - dryRun: this.dryRun, - }, ); await this.perform(this.context.pgslice); diff --git a/src/commands/synchronize.ts b/src/commands/synchronize.ts index f03bc8b..819a8de 100644 --- a/src/commands/synchronize.ts +++ b/src/commands/synchronize.ts @@ -39,6 +39,10 @@ export class SynchronizeCommand extends BaseCommand { ], }); + dryRun = Option.Boolean("--dry-run", false, { + description: "Print statements without executing", + }); + table = Option.String({ required: true, name: "table" }); start = Option.String("--start", { diff --git a/src/pgslice.ts b/src/pgslice.ts index d019c5b..7201102 100644 --- a/src/pgslice.ts +++ b/src/pgslice.ts @@ -35,8 +35,6 @@ import { Swapper } from "./swapper.js"; import { AdvisoryLock } from "./advisory-lock.js"; interface PgsliceOptions { - dryRun?: boolean; - /** * Whether to use Postgres advisory locks to prevent concurrent operations * on the same table for the same operation. Defaults to true. @@ -46,11 +44,9 @@ interface PgsliceOptions { export class Pgslice { #pool: DatabasePool | null = null; - #dryRun: boolean; #advisoryLocks: boolean; constructor(pool: DatabasePool, options: PgsliceOptions) { - this.#dryRun = options.dryRun ?? false; this.#advisoryLocks = options.advisoryLocks ?? true; this.#pool = pool; } @@ -88,10 +84,6 @@ export class Pgslice { async start( handler: (transaction: DatabasePoolConnection) => Promise, ): Promise { - if (this.#dryRun) { - throw new Error("Dry run not yet supported."); - } - return this.pool.connect(handler); }