Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/commands/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ export abstract class BaseCommand extends Command<Context> {
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) {
Expand All @@ -27,9 +23,6 @@ export abstract class BaseCommand extends Command<Context> {
try {
this.context.pgslice ??= await Pgslice.connect(
new URL(this.getDatabaseUrl()),
{
dryRun: this.dryRun,
},
);

await this.perform(this.context.pgslice);
Expand Down
4 changes: 4 additions & 0 deletions src/commands/synchronize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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", {
Expand Down
8 changes: 0 additions & 8 deletions src/pgslice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
}
Expand Down Expand Up @@ -88,10 +84,6 @@ export class Pgslice {
async start<T>(
handler: (transaction: DatabasePoolConnection) => Promise<T>,
): Promise<T> {
if (this.#dryRun) {
throw new Error("Dry run not yet supported.");
}

return this.pool.connect(handler);
}

Expand Down