@clickup/pg-microsharding
Version:
Microshards support for PostgreSQL
29 lines (26 loc) • 652 B
text/typescript
import type { TableInfo } from "./getTablesInSchema";
import { subName } from "./names";
import { ident, sql } from "./quote";
import { runSql } from "./runSql";
/**
* Pauses the destination subscription. When resumed (enabled), the replication
* will continue from the paused position (no data loss).
*/
export async function disableSubscription({
toDsn,
tables,
schema,
}: {
toDsn: string;
tables: TableInfo[];
schema: string;
}): Promise<void> {
if (tables.length === 0) {
return;
}
await runSql(
toDsn,
sql`ALTER SUBSCRIPTION ${ident(subName(schema))} DISABLE`,
"Pausing the destination subscription",
);
}