also looking at this
fix(schema): emit inline FOREIGN KEY on SQLite CREATE TABLE (#1019)
#1020
6 files
+239
-10
| @@ -186,6 +186,16 @@ export class PostgresDriver implements DialectDriver { | ||
| 186 | 186 | parts.push(defaultValue) |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | // PostgreSQL FKs are added via a separate `ALTER TABLE … ADD | |
| 190 | // CONSTRAINT FOREIGN KEY` pass (see migrations.ts), NOT inline. | |
| 191 | // Postgres strictly requires the referenced table to exist | |
| 192 | // before CREATE TABLE with an inline FK, so the deferred-ALTER | |
| 193 | // form sidesteps dependency-ordering questions when | |
| 194 | // `plan.tables` is iterated in (e.g.) alphabetical order. | |
| 195 | // SQLite is the only driver where the inline path is forced — | |
| 196 | // it doesn't support ALTER TABLE ADD CONSTRAINT and is lenient | |
| 197 | // about forward-reference targets. | |
| 198 | ||
| 189 | 199 | return parts.join(' ') |
| 190 | 200 | } |
| 191 | 201 | } |