Skip to content

Commit 92467ca

Browse files
committed
feat: append-migration (living migration module) and diff-live-db examples
1 parent 4bd3a1c commit 92467ca

33 files changed

Lines changed: 757 additions & 3 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ jobs:
8282
sudo apt-get update -qq
8383
sudo apt-get install -y -qq postgresql-client-18
8484
echo "PG_DUMP=/usr/lib/postgresql/18/bin/pg_dump" >> "$GITHUB_ENV"
85+
echo "/usr/lib/postgresql/18/bin" >> "$GITHUB_PATH"
8586
8687
- name: Seed pg and app_user
8788
run: |

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
**/.DS_Store
33
**/dist
44
**/pnpm-debug.log
5-
lerna-debug.log
5+
lerna-debug.log
6+
# generated at test time by scripts/acceptance.sh (diff-live-db example)
7+
examples/diff-live-db/output/

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ produced it.
4545
| [import-granularity](examples/import-granularity) | [raw pg_dump](examples/import-dump/input/shop.v1.sql) | [atomic module in one step](examples/import-granularity/output/shop-atomic-direct) (`import --granularity atomic`) |
4646
| [naming-flat](examples/naming-flat) | [the module](examples/import-dump/output/shop) | [flat change-path layout](examples/naming-flat/output/shop-object) (`--naming flat`) |
4747
| [emit-bundle](examples/emit-bundle) | [the module](examples/import-dump/output/shop) | [content-addressed bundle](examples/emit-bundle/output/shop.bundle.tar.gz) powering `pgpm deploy --fast` |
48+
| [append-migration](examples/append-migration) | v1→v2 delta + [shop.v3.sql](examples/append-migration/input/shop.v3.sql) | [one living migration module](examples/append-migration/output/shop-migrations) (`diff --append-module`) covering v1→v3 |
49+
| [diff-live-db](examples/diff-live-db) | two **live databases** (`db:a` vs `db:b`) | migration module generated on demand at test time |
4850

49-
More examples are planned (`--append-module`, live-db diff sides) — see the full combination matrix in
50-
[constructive-planning#1344](https://github.com/constructive-io/constructive-planning/issues/1344).
51+
See the full combination matrix in
52+
[constructive-planning#1344](https://github.com/constructive-io/constructive-planning/issues/1344);
53+
the remaining unbuilt rows are blocked on known `pgpm diff` raw-SQL
54+
normalization bugs or on CLI features that haven't landed yet.
5155

5256
## Layout
5357

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# append-migration — a living migration module (v1 → v2 → v3)
2+
3+
**Input:** [`../import-dump/output/shop/`](../import-dump/output/shop) (v1), [`../diff-migration/input/shop.v2.sql`](../diff-migration/input/shop.v2.sql) (v2), and [`input/shop.v3.sql`](input/shop.v3.sql) (v3 = v2 + a `shop.coupons` table).
4+
5+
**Output:** [`output/shop-migrations/`](output/shop-migrations) — ONE migration module that accumulates deltas over time: the v1→v2 delta emitted first, then the v2→v3 delta **appended** into the same module (existing changes, scripts, and `.control` untouched).
6+
7+
```sh
8+
# v1 -> v2: emit the initial migration module
9+
pgpm import examples/diff-migration/input/shop.v2.sql --pkg shop-v2 --out /tmp/v2mod
10+
pgpm diff examples/import-dump/output/shop /tmp/v2mod/shop-v2 \
11+
--emit-migration examples/append-migration/output --pkg shop-migrations
12+
13+
# v2 -> v3: append the next delta into the SAME module
14+
pgpm import examples/append-migration/input/shop.v3.sql --pkg shop-v3 --out /tmp/v3mod
15+
pgpm diff /tmp/v2mod/shop-v2 /tmp/v3mod/shop-v3 \
16+
--append-module examples/append-migration/output/shop-migrations
17+
```
18+
19+
CI deploys shop@v1 then `shop-migrations` and asserts the catalog equals v3 loaded fresh — one deploy covers the whole v1→v3 history.
20+
21+
Note: appended changes whose derived path collides with an existing change in the module (e.g. two deltas both altering `shop.orders`) are currently skipped with a notice rather than sequenced — tracked upstream in [constructive-planning#1344](https://github.com/constructive-io/constructive-planning/issues/1344).

0 commit comments

Comments
 (0)