MCPcopy
hub / github.com/Effect-TS/effect / pgDump

Function pgDump

packages/sql-pg/src/PgMigrator.ts:39–65  ·  view source on GitHub ↗
(args: Array<string>)

Source from the content-addressed store, hash-verified

37> = Migrator.make({
38 dumpSchema(path, table) {
39 const pgDump = (args: Array<string>) =>
40 Effect.gen(function*() {
41 const sql = yield* PgClient
42 const dump = yield* pipe(
43 Command.make("pg_dump", ...args, "--no-owner", "--no-privileges"),
44 Command.env({
45 PATH: (globalThis as any).process?.env.PATH,
46 PGHOST: sql.config.host,
47 PGPORT: sql.config.port?.toString(),
48 PGUSER: sql.config.username,
49 PGPASSWORD: sql.config.password
50 ? Redacted.value(sql.config.password)
51 : undefined,
52 PGDATABASE: sql.config.database,
53 PGSSLMODE: sql.config.ssl ? "require" : "prefer"
54 }),
55 Command.string
56 )
57
58 return dump.replace(/^--.*$/gm, "")
59 .replace(/^SET .*$/gm, "")
60 .replace(/^SELECT pg_catalog\..*$/gm, "")
61 .replace(/\n{2,}/gm, "\n\n")
62 .trim()
63 }).pipe(
64 Effect.mapError((error) => new Migrator.MigrationError({ reason: "failed", message: error.message }))
65 )
66
67 const pgDumpSchema = pgDump(["--schema-only"])
68

Callers 1

dumpSchemaFunction · 0.85

Calls 5

pipeMethod · 0.65
makeMethod · 0.65
toStringMethod · 0.65
pipeFunction · 0.50
valueMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…