@subodh001/pg-safe-migrate 1.1.2 → 2.2.0
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/ALL-MILESTONES-TESTING.md +41 -0
- package/README.md +303 -29
- package/bin/cli.js +83 -54
- package/examples/baseline.sql +7 -0
- package/examples/consumer-workflow.yml +35 -0
- package/examples/migrations/001_add_phone.sql +1 -0
- package/examples/migrations/002_add_email_index.sql +1 -0
- package/examples/safe.sql +2 -0
- package/examples/team-policy.json +7 -0
- package/examples/test-unsafe.sql +1 -0
- package/examples/unsafe.sql +2 -0
- package/examples/verify.sql +8 -0
- package/package.json +13 -4
- package/scripts/orm-runner/README.md +35 -0
- package/scripts/orm-runner/package-lock.json +659 -0
- package/scripts/orm-runner/package.json +14 -0
- package/scripts/orm-runner/verify.mjs +360 -0
- package/scripts/test-pg-matrix.cjs +30 -0
- package/src/advisor.js +22 -0
- package/src/analysis.js +258 -0
- package/src/combined.js +60 -0
- package/src/config.js +27 -0
- package/src/db-inspect.js +30 -0
- package/src/engine.js +3 -1
- package/src/github.js +17 -0
- package/src/locks.js +8 -0
- package/src/parser.js +5 -5
- package/src/plans.js +9 -0
- package/src/presets.js +5 -0
- package/src/reports.js +5 -0
- package/src/risk.js +5 -0
- package/src/rules/additionalRules.js +9 -0
- package/src/simulator.js +115 -0
- package/src/team-policy.js +23 -0
package/package.json
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@subodh001/pg-safe-migrate",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "PostgreSQL AST migration risk linter for Prisma, Drizzle and SQL",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
|
-
"pg-safe-migrate": "
|
|
7
|
+
"pg-safe-migrate": "bin/cli.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "node --test",
|
|
11
11
|
"lint": "node bin/cli.js",
|
|
12
|
-
"pack:check": "npm pack --dry-run"
|
|
12
|
+
"pack:check": "npm pack --dry-run",
|
|
13
|
+
"test:release": "node --test && node test/release-smoke.cjs",
|
|
14
|
+
"test:unit": "node --test test/*.test.js test/*.cjs"
|
|
13
15
|
},
|
|
14
16
|
"keywords": [
|
|
15
17
|
"postgresql",
|
|
@@ -34,7 +36,14 @@
|
|
|
34
36
|
"bin/",
|
|
35
37
|
"src/",
|
|
36
38
|
"README.md",
|
|
37
|
-
"LICENSE"
|
|
39
|
+
"LICENSE",
|
|
40
|
+
"examples/",
|
|
41
|
+
"scripts/test-pg-matrix.cjs",
|
|
42
|
+
"scripts/orm-runner/verify.mjs",
|
|
43
|
+
"scripts/orm-runner/package.json",
|
|
44
|
+
"scripts/orm-runner/package-lock.json",
|
|
45
|
+
"scripts/orm-runner/README.md",
|
|
46
|
+
"ALL-MILESTONES-TESTING.md"
|
|
38
47
|
],
|
|
39
48
|
"repository": {
|
|
40
49
|
"type": "git",
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Optional real ORM migration verification
|
|
2
|
+
|
|
3
|
+
This integration test runs **actual Prisma Migrate and Drizzle ORM migration runners** against a disposable PostgreSQL database. It is separate from the package's default `npm test` and GitHub Actions workflow.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Node.js and npm
|
|
8
|
+
- Docker with an available local PostgreSQL port, or another **disposable** PostgreSQL database
|
|
9
|
+
- Dependencies installed in `scripts/orm-runner` with `npm install`
|
|
10
|
+
|
|
11
|
+
## Windows PowerShell
|
|
12
|
+
|
|
13
|
+
From the repository root:
|
|
14
|
+
|
|
15
|
+
```powershell
|
|
16
|
+
docker run -d --name pg-safe-orm-test -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=pg_safe_local_test_2026 -e POSTGRES_DB=pg_safe_migrate_test -p 127.0.0.1:55432:5432 postgres:16
|
|
17
|
+
$env:DATABASE_URL = "postgresql://postgres:pg_safe_local_test_2026@127.0.0.1:55432/pg_safe_migrate_test"
|
|
18
|
+
cd scripts/orm-runner
|
|
19
|
+
npm install
|
|
20
|
+
npm run verify
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The Docker container command is for an isolated local test only. If the container already exists, start it with `docker start pg-safe-orm-test` instead of creating another one. Stop and remove it when finished with `docker rm -f pg-safe-orm-test`.
|
|
24
|
+
|
|
25
|
+
## Expected checks
|
|
26
|
+
|
|
27
|
+
1. Prisma applies a baseline table migration.
|
|
28
|
+
2. Prisma applies a **separate** concurrent-index migration and the index exists.
|
|
29
|
+
3. The tested Drizzle node-postgres migrator rejects `CREATE INDEX CONCURRENTLY` inside its transaction with PostgreSQL `25001`.
|
|
30
|
+
4. The rejected Drizzle index is absent.
|
|
31
|
+
5. Temporary database schemas and local temporary files are cleaned up.
|
|
32
|
+
|
|
33
|
+
`KEEP_TEST_SCHEMAS=1` retains test schemas for inspection; do not set it during normal verification.
|
|
34
|
+
|
|
35
|
+
**Safety:** This script creates and drops schemas. Run it only against a disposable test database, never a production or shared database. Results depend on the exact Prisma, Drizzle, PostgreSQL, and runner versions installed.
|