@clickup/pg-microsharding
Version:
Microshards support for PostgreSQL
24 lines (22 loc) • 522 B
text/typescript
import { cleanUpPubSub } from "./cleanUpPubSub";
import { ident, sql } from "./quote";
import { runSql } from "./runSql";
/**
* Cleans up after the shard migration on failure.
*/
export async function resultAbort({
fromDsn,
toDsn,
schema,
}: {
fromDsn: string;
toDsn: string;
schema: string;
}): Promise<void> {
await cleanUpPubSub({ fromDsn, toDsn, schema });
await runSql(
toDsn,
sql`DROP schema IF EXISTS ${ident(schema)} CASCADE`,
"Dropping destination semi-migrated microshard",
);
}