@kattebak/typespec-drizzle-orm-generator 5.1.0 → 5.1.1
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/README.md +11 -0
- package/dist/ir/default-value.d.ts +2 -2
- package/dist/ir/default-value.js +2 -2
- package/dist/lib.js +2 -2
- package/dist/lib.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -391,6 +391,17 @@ options:
|
|
|
391
391
|
|
|
392
392
|
`relations.ts`, `describe.ts`, and the `DrizzleClient` type use the Drizzle v2 relational API (`defineRelations`, `PgAsyncDatabase`). Set `schema-only: true` to emit just the table schema (`schema.ts` + the `base36Uuid` / nullable custom types), which stays compatible with Drizzle v1 consumers that manage relations themselves. The generated `package.json` then declares a `drizzle-orm` peer range of `>=0.30.0`.
|
|
393
393
|
|
|
394
|
+
## Getting SQL DDL
|
|
395
|
+
|
|
396
|
+
The emitter writes TypeScript only. To get SQL, run `drizzle-kit export` over the generated `schema.ts`; it needs no database and no migration folder:
|
|
397
|
+
|
|
398
|
+
```sh
|
|
399
|
+
npx drizzle-kit export --dialect postgresql --schema ./build/drizzle-entities/schema.ts > ddl.sql
|
|
400
|
+
npx drizzle-kit export --dialect sqlite --schema ./build/drizzle-entities/schema.ts > ddl.sql
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
Enums, indexes, partial indexes (`WHERE`) and array defaults come through. For migrations over an existing database, use `drizzle-kit generate`.
|
|
404
|
+
|
|
394
405
|
## Foreign keys and id defaults
|
|
395
406
|
|
|
396
407
|
`foreign-keys: false` drops the collection-derived foreign keys for a consumer that manages referential integrity and delete cascades in the application (a database `ON DELETE CASCADE` would otherwise fight an app-managed cascade). `id-default: true` attaches `.$defaultFn(() => generateBase36Id())` to single-column text primary keys so a caller may omit the id. Both are honoured by the `remit` front-end.
|
|
@@ -11,8 +11,8 @@ export type DefaultRead = {
|
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* Reads a model property's default for its column. A default no column can hold
|
|
14
|
-
* is
|
|
15
|
-
*
|
|
14
|
+
* is dropped with a warning, since a dropped default turns a NOT NULL column
|
|
15
|
+
* without one into a failed migration on a table with rows.
|
|
16
16
|
*/
|
|
17
17
|
export declare function readColumnDefault(program: ProgramStateAccess, prop: ModelProperty): DefaultValue | undefined;
|
|
18
18
|
/**
|
package/dist/ir/default-value.js
CHANGED
|
@@ -2,8 +2,8 @@ import { $lib } from "../lib.js";
|
|
|
2
2
|
const none = { kind: "none" };
|
|
3
3
|
/**
|
|
4
4
|
* Reads a model property's default for its column. A default no column can hold
|
|
5
|
-
* is
|
|
6
|
-
*
|
|
5
|
+
* is dropped with a warning, since a dropped default turns a NOT NULL column
|
|
6
|
+
* without one into a failed migration on a table with rows.
|
|
7
7
|
*/
|
|
8
8
|
export function readColumnDefault(program, prop) {
|
|
9
9
|
const read = readDefaultValue(prop);
|
package/dist/lib.js
CHANGED
|
@@ -21,9 +21,9 @@ export const $lib = createTypeSpecLibrary({
|
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
23
|
"unrepresentable-default": {
|
|
24
|
-
severity: "
|
|
24
|
+
severity: "warning",
|
|
25
25
|
messages: {
|
|
26
|
-
default: paramMessage `The default of property "${"property"}" holds ${"element"}, which no column default can hold. Use string, number, boolean or enum elements, or remove the default.`,
|
|
26
|
+
default: paramMessage `The default of property "${"property"}" holds ${"element"}, which no column default can hold, so the column is emitted without one. Use string, number, boolean or enum elements, or remove the default.`,
|
|
27
27
|
},
|
|
28
28
|
},
|
|
29
29
|
},
|
package/dist/lib.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEzE,MAAM,CAAC,MAAM,IAAI,GAAG,qBAAqB,CAAC;IACxC,IAAI,EAAE,0CAA0C;IAChD,WA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4B,UAAU,WAAW,SAAS,gJAAgJ;aAChO;SACF;KACF;IACD,KAAK,EAAE;QACL,KAAK,EAAE,EAAE,WAAW,EAAE,4BAA4B,EAAE;QACpD,UAAU,EAAE,EAAE,WAAW,EAAE,iCAAiC,EAAE;QAC9D,EAAE,EAAE,EAAE,WAAW,EAAE,4CAA4C,EAAE;QACjE,UAAU,EAAE,EAAE,WAAW,EAAE,iCAAiC,EAAE;QAC9D,QAAQ,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE;QAC1D,IAAI,EAAE,EAAE,WAAW,EAAE,2BAA2B,EAAE;QAClD,SAAS,EAAE,EAAE,WAAW,EAAE,gCAAgC,EAAE;QAC5D,SAAS,EAAE,EAAE,WAAW,EAAE,gCAAgC,EAAE;QAC5D,MAAM,EAAE,EAAE,WAAW,EAAE,6CAA6C,EAAE;QACtE,eAAe,EAAE,EAAE,WAAW,EAAE,oDAAoD,EAAE;QACtF,KAAK,EAAE,EAAE,WAAW,EAAE,4BAA4B,EAAE;QACpD,QAAQ,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE;QAC1D,aAAa,EAAE,EAAE,WAAW,EAAE,oCAAoC,EAAE;QACpE,QAAQ,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE;QAC1D,QAAQ,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE;QAC1D,gBAAgB,EAAE,EAAE,WAAW,EAAE,uCAAuC,EAAE;KAC3E;CACO,CAAC,CAAC;AAEZ,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kattebak/typespec-drizzle-orm-generator",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"@typescript/native-preview": "latest",
|
|
55
55
|
"@typespec/compiler": "^1.17.0",
|
|
56
56
|
"better-sqlite3": "^12.6.2",
|
|
57
|
+
"drizzle-kit": "^1.0.0-beta.15-859cf75",
|
|
57
58
|
"drizzle-orm": "^1.0.0-beta.15-859cf75",
|
|
58
59
|
"short-uuid": "^5.2.0",
|
|
59
60
|
"tsx": "^4.21.0"
|