@effect/sql-pg 4.0.0-beta.9 → 4.0.0-beta.90

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/PgMigrator.ts CHANGED
@@ -1,5 +1,13 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * Runs database migrations for PostgreSQL projects that use Effect SQL.
3
+ *
4
+ * This module reuses the shared SQL migrator and connects it to PostgreSQL. It
5
+ * exposes the common migration helpers and adds `run` and `layer` functions
6
+ * that apply pending migration files with the current SQL client. When schema
7
+ * dumps are requested, it uses `pg_dump` and the usual process and filesystem
8
+ * services.
9
+ *
10
+ * @since 4.0.0
3
11
  */
4
12
  import * as Effect from "effect/Effect"
5
13
  import * as FileSystem from "effect/FileSystem"
@@ -7,20 +15,22 @@ import * as Layer from "effect/Layer"
7
15
  import * as Path from "effect/Path"
8
16
  import * as Redacted from "effect/Redacted"
9
17
  import * as ChildProcess from "effect/unstable/process/ChildProcess"
10
- import type * as ChildProcessSpawner from "effect/unstable/process/ChildProcessSpawner"
18
+ import * as ChildProcessSpawner from "effect/unstable/process/ChildProcessSpawner"
11
19
  import * as Migrator from "effect/unstable/sql/Migrator"
12
20
  import type { SqlClient } from "effect/unstable/sql/SqlClient"
13
21
  import type { SqlError } from "effect/unstable/sql/SqlError"
14
22
  import { PgClient } from "./PgClient.ts"
15
23
 
16
24
  /**
17
- * @since 1.0.0
25
+ * @since 4.0.0
18
26
  */
19
27
  export * from "effect/unstable/sql/Migrator"
20
28
 
21
29
  /**
22
- * @category constructor
23
- * @since 1.0.0
30
+ * Runs PostgreSQL SQL migrations using the configured clients. Schema dumps use `pg_dump` and require child process, filesystem, and path services.
31
+ *
32
+ * @category constructors
33
+ * @since 4.0.0
24
34
  */
25
35
  export const run: <R2 = never>(
26
36
  options: Migrator.MigratorOptions<R2>
@@ -38,6 +48,7 @@ export const run: <R2 = never>(
38
48
  const pgDump = (args: Array<string>) =>
39
49
  Effect.gen(function*() {
40
50
  const sql = yield* PgClient
51
+ const spawner = yield* ChildProcessSpawner.ChildProcessSpawner
41
52
  const dump = yield* ChildProcess.make("pg_dump", [...args, "--no-owner", "--no-privileges"], {
42
53
  env: {
43
54
  PATH: (globalThis as any).process?.env.PATH,
@@ -50,7 +61,7 @@ export const run: <R2 = never>(
50
61
  PGDATABASE: sql.config.database,
51
62
  PGSSLMODE: sql.config.ssl ? "require" : "prefer"
52
63
  }
53
- }).pipe(ChildProcess.string)
64
+ }).pipe(spawner.string)
54
65
 
55
66
  return dump.replace(/^--.*$/gm, "")
56
67
  .replace(/^SET .*$/gm, "")
@@ -90,8 +101,10 @@ export const run: <R2 = never>(
90
101
  })
91
102
 
92
103
  /**
104
+ * Creates a layer that runs PostgreSQL migrations during layer construction, including `pg_dump`-based schema dump support when requested.
105
+ *
93
106
  * @category layers
94
- * @since 1.0.0
107
+ * @since 4.0.0
95
108
  */
96
109
  export const layer = <R>(
97
110
  options: Migrator.MigratorOptions<R>
package/src/index.ts CHANGED
@@ -1,15 +1,15 @@
1
1
  /**
2
- * @since 1.0.0
2
+ * @since 4.0.0
3
3
  */
4
4
 
5
5
  // @barrel: Auto-generated exports. Do not edit manually.
6
6
 
7
7
  /**
8
- * @since 1.0.0
8
+ * @since 4.0.0
9
9
  */
10
10
  export * as PgClient from "./PgClient.ts"
11
11
 
12
12
  /**
13
- * @since 1.0.0
13
+ * @since 4.0.0
14
14
  */
15
15
  export * as PgMigrator from "./PgMigrator.ts"