also looking at this
fix(schema): emit inline FOREIGN KEY on SQLite CREATE TABLE (#1019)
#1020
6 files
+239
-10
| @@ -205,6 +205,17 @@ export class MySQLDriver implements DialectDriver { | ||
| 205 | 205 | parts.push(defaultValue) |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | // MySQL FKs are added via a separate `ALTER TABLE … ADD | |
| 209 | // CONSTRAINT FOREIGN KEY` pass (see migrations.ts), NOT inline. | |
| 210 | // MySQL strictly requires the referenced table to exist before | |
| 211 | // CREATE TABLE with an inline FK, which makes inline FKs in the | |
| 212 | // initial-migration pass fragile when `plan.tables` is | |
| 213 | // alphabetically ordered (e.g. `comments` before `users`). The | |
| 214 | // deferred-ALTER form sidesteps the dependency order entirely. | |
| 215 | // SQLite is the only driver where the inline path is forced — | |
| 216 | // it doesn't support ALTER TABLE ADD CONSTRAINT and is lenient | |
| 217 | // about forward-reference targets. | |
| 218 | ||
| 208 | 219 | return parts.join(' ') |
| 209 | 220 | } |
| 210 | 221 | } |