Skip to content

Commit a4b5b66

Browse files
committed
fix: use pgfence.com domain, update to v0.2.3
1 parent 664ee22 commit a4b5b66

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

apps/docs/content/docs/guides/integrations/pgfence.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ metaDescription: Learn how to analyze Prisma migration SQL files with pgfence to
88

99
## Introduction
1010

11-
[pgfence](https://pgfence.dev) is a PostgreSQL migration safety CLI that analyzes SQL migration files and reports lock modes, risk levels, and safe rewrite recipes. It uses PostgreSQL's actual parser ([libpg-query](https://github.com/pganalyze/libpg-query-node)) to understand exactly what each DDL statement does, what locks it acquires, and what it blocks.
11+
[pgfence](https://pgfence.com) is a PostgreSQL migration safety CLI that analyzes SQL migration files and reports lock modes, risk levels, and safe rewrite recipes. It uses PostgreSQL's actual parser ([libpg-query](https://github.com/pganalyze/libpg-query-node)) to understand exactly what each DDL statement does, what locks it acquires, and what it blocks.
1212

1313
Prisma Migrate generates plain SQL files at `prisma/migrations/*/migration.sql`. pgfence can analyze those files directly, catching dangerous patterns before they reach production.
1414

@@ -32,15 +32,15 @@ For each dangerous pattern, pgfence provides the exact safe alternative -- the e
3232
Add pgfence as a development dependency in your project:
3333

3434
```npm
35-
npm install -D @flvmnt/pgfence@0.2.1
35+
npm install -D @flvmnt/pgfence@0.2.3
3636
```
3737

3838
## 2. Analyze your migrations locally
3939

4040
Run pgfence against your Prisma migration files:
4141

4242
```bash
43-
npx --yes @flvmnt/pgfence@0.2.1 analyze prisma/migrations/**/migration.sql
43+
npx --yes @flvmnt/pgfence@0.2.3 analyze prisma/migrations/**/migration.sql
4444
```
4545

4646
pgfence parses every SQL statement and reports the lock mode, risk level, and any safe rewrites available.
@@ -64,7 +64,7 @@ CREATE INDEX "User_email_idx" ON "User"("email");
6464
```
6565

6666
```bash
67-
npx --yes @flvmnt/pgfence@0.2.1 analyze prisma/migrations/20240115_add_index/migration.sql
67+
npx --yes @flvmnt/pgfence@0.2.3 analyze prisma/migrations/20240115_add_index/migration.sql
6868
```
6969

7070
pgfence will flag this as a `MEDIUM` risk because `CREATE INDEX` takes a `SHARE` lock, which blocks all writes to the table for the duration of the index build. It will suggest using `CREATE INDEX CONCURRENTLY` instead.
@@ -78,13 +78,13 @@ Prisma Migrate does not generate `CONCURRENTLY` variants automatically. If pgfen
7878
pgfence supports JSON output, which is useful for integrating with other tools or scripts:
7979

8080
```bash
81-
npx --yes @flvmnt/pgfence@0.2.1 analyze --output json prisma/migrations/**/migration.sql
81+
npx --yes @flvmnt/pgfence@0.2.3 analyze --output json prisma/migrations/**/migration.sql
8282
```
8383

8484
You can also set a maximum risk threshold for CI pipelines. The command exits with code 1 if any statement exceeds the threshold:
8585

8686
```bash
87-
npx --yes @flvmnt/pgfence@0.2.1 analyze --ci --max-risk medium prisma/migrations/**/migration.sql
87+
npx --yes @flvmnt/pgfence@0.2.3 analyze --ci --max-risk medium prisma/migrations/**/migration.sql
8888
```
8989

9090
## 4. Add pgfence to your CI pipeline
@@ -119,7 +119,7 @@ jobs:
119119
- name: Run pgfence analysis
120120
run: |
121121
shopt -s globstar
122-
npx --yes @flvmnt/pgfence@0.2.1 analyze --ci --max-risk medium prisma/migrations/**/migration.sql
122+
npx --yes @flvmnt/pgfence@0.2.3 analyze --ci --max-risk medium prisma/migrations/**/migration.sql
123123
```
124124
125125
This workflow only triggers when migration files change. If pgfence detects any statement with risk higher than `MEDIUM`, the check fails and blocks the pull request from merging.
@@ -136,7 +136,7 @@ If you have an existing deployment workflow, add pgfence as a step before `prism
136136
- name: Run pgfence migration safety check
137137
run: |
138138
shopt -s globstar
139-
npx --yes @flvmnt/pgfence@0.2.1 analyze --ci --max-risk medium prisma/migrations/**/migration.sql
139+
npx --yes @flvmnt/pgfence@0.2.3 analyze --ci --max-risk medium prisma/migrations/**/migration.sql
140140
141141
- name: Apply pending migrations
142142
run: npx prisma migrate deploy
@@ -151,10 +151,10 @@ pgfence can adjust risk levels based on actual table sizes. A `CREATE INDEX` on
151151
To use size-aware scoring without giving pgfence direct database access, export a stats snapshot from your database and pass it to pgfence:
152152

153153
```bash
154-
npx --yes @flvmnt/pgfence@0.2.1 analyze --stats-file pgfence-stats.json prisma/migrations/**/migration.sql
154+
npx --yes @flvmnt/pgfence@0.2.3 analyze --stats-file pgfence-stats.json prisma/migrations/**/migration.sql
155155
```
156156

157-
The stats file contains row counts and table sizes from `pg_stat_user_tables`. Run `npx --yes @flvmnt/pgfence@0.2.1 extract-stats --db-url <connection-string>` to generate this file, or see the [pgfence README](https://github.com/flvmnt/pgfence#db-size-aware-risk-scoring) for details.
157+
The stats file contains row counts and table sizes from `pg_stat_user_tables`. Run `npx --yes @flvmnt/pgfence@0.2.3 extract-stats --db-url <connection-string>` to generate this file, or see the [pgfence README](https://github.com/flvmnt/pgfence#db-size-aware-risk-scoring) for details.
158158

159159
## Next steps
160160

0 commit comments

Comments
 (0)