@warlock.js/cascade 5.8.0 → 5.10.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/CHANGELOG.md CHANGED
@@ -4,6 +4,24 @@ All notable changes to `@warlock.js/cascade` are documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). `@warlock.js/*` packages are released in lockstep — every package shares the same version number, so a version below may list only the changes that affected this package.
6
6
 
7
+ ## 5.10.0 - 2026-09-14
8
+
9
+ _Released in lockstep with the `@warlock.js/*` family; no package-specific changes in 5.10.0._
10
+
11
+ ## 5.9.0 - 2026-09-13
12
+
13
+ _Released in lockstep with the `@warlock.js/*` family; no package-specific changes in 5.9.0._
14
+
15
+ ## 5.8.0 - 2026-09-13
16
+
17
+ ### Added
18
+
19
+ - `Migration.foreignId(name)` derives a foreign-key column's type from `migrationDefaults.primaryKey`, so FK columns match the app's chosen primary-key type (integer / bigInteger / uuid).
20
+
21
+ ### Fixed
22
+
23
+ - Numeric-looking Postgres connection config (e.g. a numeric `DB_NAME`) is coerced to a string via `buildPostgresPoolConfig`, instead of crashing the driver with an inscrutable buffer error.
24
+
7
25
  ## 5.7.0 - 2026-09-11
8
26
 
9
27
  ### Fixed
package/llms-full.txt CHANGED
@@ -2771,6 +2771,35 @@ export default class BackfillStatuses extends Migration {
2771
2771
 
2772
2772
  Class-form builders include `createTable()` / `createTableIfNotExists()`, `dropTable()` / `dropTableIfExists()`, `dropColumn(name)`, `renameTableTo(name)`, `timestamps()`, `index(...)`, `primaryUuid()`, and `raw(sql)` for a raw statement.
2773
2773
 
2774
+ ### Foreign-key columns that match the app's PK type — `this.foreignId`
2775
+
2776
+ `this.foreignId(name)` (5.8+) derives the column's type from `migrationDefaults.primaryKey` so a foreign-key column always matches the type of the `id` it points at, instead of hardcoding one:
2777
+
2778
+ | `migrationDefaults.primaryKey` | `foreignId` produces |
2779
+ | --- | --- |
2780
+ | `uuid` | `uuid` column |
2781
+ | `bigInt` | `bigInteger` column |
2782
+ | anything else (default) | `integer` column |
2783
+
2784
+ ```ts
2785
+ import { Migration } from "@warlock.js/cascade";
2786
+
2787
+ export default class AddUserToPosts extends Migration {
2788
+ public readonly table = "posts";
2789
+
2790
+ public async up(): Promise<void> {
2791
+ // uuid / bigInteger / integer, matching the app's chosen PK type
2792
+ this.foreignId("user_id").index();
2793
+ }
2794
+
2795
+ public down(): void {
2796
+ this.dropColumn("user_id");
2797
+ }
2798
+ }
2799
+ ```
2800
+
2801
+ Reach for it on plain (non-`.references()`) FK id columns — e.g. a polymorphic `user_id` paired with a `user_type` — so a reference to a default-PK model is always type-compatible with that model's `id`.
2802
+
2774
2803
  ## Raw SQL migrations
2775
2804
 
2776
2805
  For SQL-only changes (Postgres), `Migration.rawSql` builds a migration class for you:
package/package.json CHANGED
@@ -13,9 +13,9 @@
13
13
  "@mongez/events": "^2.2.7",
14
14
  "@mongez/reinforcements": "^4.0.1",
15
15
  "@mongez/supportive-is": "^2.1.4",
16
- "@warlock.js/context": "5.8.0",
17
- "@warlock.js/logger": "5.8.0",
18
- "@warlock.js/seal": "5.8.0",
16
+ "@warlock.js/context": "5.10.0",
17
+ "@warlock.js/logger": "5.10.0",
18
+ "@warlock.js/seal": "5.10.0",
19
19
  "citty": "^0.2.2",
20
20
  "fast-glob": "^3.3.3"
21
21
  },
@@ -43,7 +43,7 @@
43
43
  ],
44
44
  "author": "hassanzohdy",
45
45
  "license": "MIT",
46
- "version": "5.8.0",
46
+ "version": "5.10.0",
47
47
  "main": "./cjs/index.cjs",
48
48
  "module": "./esm/index.mjs",
49
49
  "types": "./esm/index.d.mts",
@@ -124,6 +124,35 @@ export default class BackfillStatuses extends Migration {
124
124
 
125
125
  Class-form builders include `createTable()` / `createTableIfNotExists()`, `dropTable()` / `dropTableIfExists()`, `dropColumn(name)`, `renameTableTo(name)`, `timestamps()`, `index(...)`, `primaryUuid()`, and `raw(sql)` for a raw statement.
126
126
 
127
+ ### Foreign-key columns that match the app's PK type — `this.foreignId`
128
+
129
+ `this.foreignId(name)` (5.8+) derives the column's type from `migrationDefaults.primaryKey` so a foreign-key column always matches the type of the `id` it points at, instead of hardcoding one:
130
+
131
+ | `migrationDefaults.primaryKey` | `foreignId` produces |
132
+ | --- | --- |
133
+ | `uuid` | `uuid` column |
134
+ | `bigInt` | `bigInteger` column |
135
+ | anything else (default) | `integer` column |
136
+
137
+ ```ts
138
+ import { Migration } from "@warlock.js/cascade";
139
+
140
+ export default class AddUserToPosts extends Migration {
141
+ public readonly table = "posts";
142
+
143
+ public async up(): Promise<void> {
144
+ // uuid / bigInteger / integer, matching the app's chosen PK type
145
+ this.foreignId("user_id").index();
146
+ }
147
+
148
+ public down(): void {
149
+ this.dropColumn("user_id");
150
+ }
151
+ }
152
+ ```
153
+
154
+ Reach for it on plain (non-`.references()`) FK id columns — e.g. a polymorphic `user_id` paired with a `user_type` — so a reference to a default-PK model is always type-compatible with that model's `id`.
155
+
127
156
  ## Raw SQL migrations
128
157
 
129
158
  For SQL-only changes (Postgres), `Migration.rawSql` builds a migration class for you: