neoorm 0.1.3 → 0.1.5
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 +311 -12
- package/dist/bin/neoorm.js +68 -26
- package/dist/bin/neoorm.js.map +1 -1
- package/dist/codegen/diff-manifest.d.ts +14 -0
- package/dist/codegen/diff-manifest.d.ts.map +1 -0
- package/dist/codegen/diff-manifest.js +585 -0
- package/dist/codegen/diff-manifest.js.map +1 -0
- package/dist/codegen/generate-summary.d.ts +21 -0
- package/dist/codegen/generate-summary.d.ts.map +1 -0
- package/dist/codegen/generate-summary.js +101 -0
- package/dist/codegen/generate-summary.js.map +1 -0
- package/dist/codegen/generate.d.ts +11 -5
- package/dist/codegen/generate.d.ts.map +1 -1
- package/dist/codegen/generate.js +35 -55
- package/dist/codegen/generate.js.map +1 -1
- package/dist/codegen/manifest-relations.d.ts.map +1 -1
- package/dist/codegen/manifest-relations.js +9 -2
- package/dist/codegen/manifest-relations.js.map +1 -1
- package/dist/codegen/schema-to-manifest.d.ts +4 -1
- package/dist/codegen/schema-to-manifest.d.ts.map +1 -1
- package/dist/codegen/schema-to-manifest.js +65 -16
- package/dist/codegen/schema-to-manifest.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js.map +1 -1
- package/dist/dialect/index.d.ts +1 -1
- package/dist/dialect/index.d.ts.map +1 -1
- package/dist/dialect/index.js.map +1 -1
- package/dist/dialect/postgres.d.ts +11 -1
- package/dist/dialect/postgres.d.ts.map +1 -1
- package/dist/dialect/postgres.js +290 -29
- package/dist/dialect/postgres.js.map +1 -1
- package/dist/dialect/types.d.ts +68 -4
- package/dist/dialect/types.d.ts.map +1 -1
- package/dist/index.d.ts +6 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/dist/introspect/pull.d.ts.map +1 -1
- package/dist/introspect/pull.js +15 -32
- package/dist/introspect/pull.js.map +1 -1
- package/dist/introspect/queries.d.ts +41 -0
- package/dist/introspect/queries.d.ts.map +1 -0
- package/dist/introspect/queries.js +119 -0
- package/dist/introspect/queries.js.map +1 -0
- package/dist/introspect/to-manifest.d.ts +4 -0
- package/dist/introspect/to-manifest.d.ts.map +1 -0
- package/dist/introspect/to-manifest.js +232 -0
- package/dist/introspect/to-manifest.js.map +1 -0
- package/dist/migrate/runner.d.ts +33 -1
- package/dist/migrate/runner.d.ts.map +1 -1
- package/dist/migrate/runner.js +142 -19
- package/dist/migrate/runner.js.map +1 -1
- package/dist/plugins/builtin.d.ts +35 -2
- package/dist/plugins/builtin.d.ts.map +1 -1
- package/dist/plugins/builtin.js +312 -1
- package/dist/plugins/builtin.js.map +1 -1
- package/dist/plugins/registry.d.ts.map +1 -1
- package/dist/plugins/registry.js +3 -1
- package/dist/plugins/registry.js.map +1 -1
- package/dist/runtime/client.d.ts +3 -0
- package/dist/runtime/client.d.ts.map +1 -1
- package/dist/runtime/client.js +11 -12
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/executor.d.ts +1 -0
- package/dist/runtime/executor.d.ts.map +1 -1
- package/dist/runtime/executor.js +27 -4
- package/dist/runtime/executor.js.map +1 -1
- package/dist/runtime/query/compile.d.ts +8 -3
- package/dist/runtime/query/compile.d.ts.map +1 -1
- package/dist/runtime/query/compile.js +275 -47
- package/dist/runtime/query/compile.js.map +1 -1
- package/dist/runtime/query/count.d.ts.map +1 -1
- package/dist/runtime/query/count.js +1 -1
- package/dist/runtime/query/count.js.map +1 -1
- package/dist/runtime/query/create.d.ts +7 -0
- package/dist/runtime/query/create.d.ts.map +1 -1
- package/dist/runtime/query/create.js +50 -104
- package/dist/runtime/query/create.js.map +1 -1
- package/dist/runtime/query/delete.d.ts.map +1 -1
- package/dist/runtime/query/delete.js +11 -5
- package/dist/runtime/query/delete.js.map +1 -1
- package/dist/runtime/query/find.d.ts.map +1 -1
- package/dist/runtime/query/find.js +16 -12
- package/dist/runtime/query/find.js.map +1 -1
- package/dist/runtime/query/primary-key.d.ts +11 -1
- package/dist/runtime/query/primary-key.d.ts.map +1 -1
- package/dist/runtime/query/primary-key.js +55 -0
- package/dist/runtime/query/primary-key.js.map +1 -1
- package/dist/runtime/query/relation-writes.d.ts +24 -0
- package/dist/runtime/query/relation-writes.d.ts.map +1 -0
- package/dist/runtime/query/relation-writes.js +325 -0
- package/dist/runtime/query/relation-writes.js.map +1 -0
- package/dist/runtime/query/unique.d.ts.map +1 -1
- package/dist/runtime/query/unique.js +1 -5
- package/dist/runtime/query/unique.js.map +1 -1
- package/dist/runtime/query/update.d.ts.map +1 -1
- package/dist/runtime/query/update.js +46 -29
- package/dist/runtime/query/update.js.map +1 -1
- package/dist/runtime/types.d.ts +3 -2
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/schema/column-where.d.ts +39 -0
- package/dist/schema/column-where.d.ts.map +1 -0
- package/dist/schema/column-where.js +2 -0
- package/dist/schema/column-where.js.map +1 -0
- package/dist/schema/column.d.ts +2 -2
- package/dist/schema/column.d.ts.map +1 -1
- package/dist/schema/column.js +2 -2
- package/dist/schema/column.js.map +1 -1
- package/dist/schema/index.d.ts +4 -4
- package/dist/schema/index.d.ts.map +1 -1
- package/dist/schema/index.js +1 -1
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/nested-relation-types.d.ts +60 -0
- package/dist/schema/nested-relation-types.d.ts.map +1 -0
- package/dist/schema/nested-relation-types.js +2 -0
- package/dist/schema/nested-relation-types.js.map +1 -0
- package/dist/schema/relation-types.d.ts +174 -25
- package/dist/schema/relation-types.d.ts.map +1 -1
- package/dist/schema/relation.d.ts +13 -13
- package/dist/schema/relation.d.ts.map +1 -1
- package/dist/schema/relation.js.map +1 -1
- package/dist/schema/types.d.ts +37 -74
- package/dist/schema/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,6 +43,7 @@ export default defineConfig({
|
|
|
43
43
|
datasource: {
|
|
44
44
|
provider: "postgresql",
|
|
45
45
|
url: process.env.DATABASE_URL!,
|
|
46
|
+
enum: "check", // "check" (default) | "union" | "native"
|
|
46
47
|
},
|
|
47
48
|
});
|
|
48
49
|
```
|
|
@@ -81,20 +82,118 @@ Column field names use camelCase in TypeScript. By default, SQL column names are
|
|
|
81
82
|
|
|
82
83
|
### Column types
|
|
83
84
|
|
|
84
|
-
| Builder | SQL type | Notes |
|
|
85
|
-
|
|
86
|
-
| `id.primary()` | `TEXT` | App-generated string IDs (e.g. `user_a1b2c3d4`) |
|
|
87
|
-
| `uuid()` | `UUID` | Defaults to UUID v7; pass `{ version: 4 }` for v4 |
|
|
88
|
-
| `uuid().primary()` | `UUID` | Primary key; auto-generated on create if omitted |
|
|
89
|
-
| `
|
|
90
|
-
| `
|
|
91
|
-
| `
|
|
92
|
-
| `
|
|
85
|
+
| Builder | SQL type | TypeScript | Notes |
|
|
86
|
+
|---------|----------|------------|-------|
|
|
87
|
+
| `id.primary()` | `TEXT` | `string` | App-generated string IDs (e.g. `user_a1b2c3d4`) |
|
|
88
|
+
| `uuid()` | `UUID` | `string` | Defaults to UUID v7; pass `{ version: 4 }` for v4 |
|
|
89
|
+
| `uuid().primary()` | `UUID` | `string` | Primary key; auto-generated on create if omitted |
|
|
90
|
+
| `serial()` | `INTEGER GENERATED BY DEFAULT AS IDENTITY` | `number` | Auto-increment; omit on insert, DB assigns via `RETURNING` |
|
|
91
|
+
| `serial().primary()` | same | `number` | Integer PK with DB-generated values |
|
|
92
|
+
| `text()` | `TEXT` | `string \| null` | |
|
|
93
|
+
| `bool()` | `BOOLEAN` | `boolean \| null` | |
|
|
94
|
+
| `int()` | `INTEGER` | `number \| null` | |
|
|
95
|
+
| `timestamp()` | `TIMESTAMPTZ` | `Date \| null` | Use `.defaultNow()` for `DEFAULT NOW()` |
|
|
96
|
+
| `json()` | `JSON` | `unknown \| null` | Generic: `json<MyType>()` |
|
|
97
|
+
| `jsonb()` | `JSONB` | `unknown \| null` | Generic: `jsonb<MyType>()` |
|
|
98
|
+
| `decimal()` / `numeric()` | `NUMERIC` or `NUMERIC(p,s)` | `string \| null` | Use strings to avoid float precision loss |
|
|
99
|
+
| `enumType(["a", "b"])` | mode-dependent | union literals | See [Enum columns](#enum-columns) |
|
|
100
|
+
| `bytea()` | `BYTEA` | `Buffer \| null` | Binary data |
|
|
101
|
+
| `textArray()` | `TEXT[]` | `string[] \| null` | |
|
|
102
|
+
| `intArray()` | `INTEGER[]` | `number[] \| null` | |
|
|
103
|
+
| `citext()` | `CITEXT` | `string \| null` | Case-insensitive text; requires `citext` extension |
|
|
93
104
|
|
|
94
105
|
All column builders support `.notNull()`, `.unique()`, `.default(value)`, `.defaultNow()`, `.primary()`, and `.map(name)`.
|
|
95
106
|
|
|
96
107
|
Foreign keys use `fk("target_table.target_column", { as, inverse, nullable?, onDelete? })`.
|
|
97
108
|
|
|
109
|
+
### Enum columns
|
|
110
|
+
|
|
111
|
+
Define allowed values in the schema:
|
|
112
|
+
|
|
113
|
+
```ts
|
|
114
|
+
import { enumType, table } from "neoorm/schema";
|
|
115
|
+
|
|
116
|
+
posts: table("posts", {
|
|
117
|
+
status: enumType(["draft", "published", "archived"] as const)
|
|
118
|
+
.notNull()
|
|
119
|
+
.default("draft"),
|
|
120
|
+
})
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Control how enums are stored via `datasource.enum` in `neoorm.config.ts`:
|
|
124
|
+
|
|
125
|
+
| Mode | SQL | DB enforcement |
|
|
126
|
+
|------|-----|----------------|
|
|
127
|
+
| `check` (default) | `TEXT` + `CHECK (...)` | yes |
|
|
128
|
+
| `union` | `TEXT` | no (TypeScript union only) |
|
|
129
|
+
| `native` | Postgres `CREATE TYPE ... AS ENUM` | yes |
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
export default defineConfig({
|
|
133
|
+
schema: "./schema.ts",
|
|
134
|
+
out: "./neoorm",
|
|
135
|
+
datasource: {
|
|
136
|
+
provider: "postgresql",
|
|
137
|
+
url: process.env.DATABASE_URL!,
|
|
138
|
+
enum: "check", // or "union" | "native"
|
|
139
|
+
},
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Optional custom SQL type name for native mode: `enumType(["draft", "published"], { name: "post_status" })`.
|
|
144
|
+
|
|
145
|
+
Query and mutate enum columns like strings with compile-time union checking:
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
await db.posts.findMany({ where: { status: "published" } });
|
|
149
|
+
await db.posts.create({ data: { title: "Hello", status: "draft" } });
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### JSON and decimal columns
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
posts: table("posts", {
|
|
156
|
+
metadata: jsonb<{ tags: string[]; featured?: boolean }>(),
|
|
157
|
+
price: decimal({ precision: 10, scale: 2 }).default("0.00"),
|
|
158
|
+
})
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
// jsonb — equality match on the full object
|
|
163
|
+
await db.posts.findMany({
|
|
164
|
+
where: { metadata: { featured: true, category: "engineering" } },
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// decimal — compare as strings
|
|
168
|
+
await db.posts.findMany({
|
|
169
|
+
where: { price: { gte: "9.99", lte: "49.99" } },
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
await db.posts.create({
|
|
173
|
+
data: {
|
|
174
|
+
title: "Premium",
|
|
175
|
+
price: "19.99",
|
|
176
|
+
metadata: { featured: true, tags: ["orm"] },
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Serial primary keys
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
items: table("items", {
|
|
185
|
+
id: serial().primary(),
|
|
186
|
+
name: text().notNull(),
|
|
187
|
+
})
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
Omit `id` on insert — the database assigns it and `RETURNING` populates the result:
|
|
191
|
+
|
|
192
|
+
```ts
|
|
193
|
+
const item = await db.items.create({ data: { name: "Widget" } });
|
|
194
|
+
// item.id is the DB-generated integer
|
|
195
|
+
```
|
|
196
|
+
|
|
98
197
|
### UUID columns
|
|
99
198
|
|
|
100
199
|
```ts
|
|
@@ -158,6 +257,143 @@ manyToMany(schema.posts, schema.tags, {
|
|
|
158
257
|
});
|
|
159
258
|
```
|
|
160
259
|
|
|
260
|
+
## Relation writes
|
|
261
|
+
|
|
262
|
+
`create` and `update` accept nested relation writes alongside scalar fields. Relation-only updates are supported (no scalar `SET` required).
|
|
263
|
+
|
|
264
|
+
| Relation kind | Operations |
|
|
265
|
+
|---------------|------------|
|
|
266
|
+
| **To-one** (outgoing FK) | `connect`, `create`, `disconnect` (nullable FK only) |
|
|
267
|
+
| **One-to-many** (inverse) | `create`, `connect`, `disconnect`, `set` |
|
|
268
|
+
| **Many-to-many** | `connect`, `connectOrCreate`, `disconnect`, `set` |
|
|
269
|
+
|
|
270
|
+
```ts
|
|
271
|
+
// To-one on update
|
|
272
|
+
await db.posts.update({
|
|
273
|
+
where: { id: postId },
|
|
274
|
+
data: { author: { connect: { id: userId } } },
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
// Nested create on one-to-many (full nested relation writes inside create items)
|
|
278
|
+
await db.posts.update({
|
|
279
|
+
where: { id: postId },
|
|
280
|
+
data: {
|
|
281
|
+
comments: {
|
|
282
|
+
create: [{ body: "Hi", author: { connect: { id: userId } } }],
|
|
283
|
+
connect: [{ id: commentId }],
|
|
284
|
+
disconnect: [{ id: oldCommentId }], // or `true` to unlink all
|
|
285
|
+
set: [{ id: commentId }], // replace all links
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
// M2M on create or update
|
|
291
|
+
await db.posts.update({
|
|
292
|
+
where: { id: postId },
|
|
293
|
+
data: {
|
|
294
|
+
tags: {
|
|
295
|
+
connect: [{ id: tagId }],
|
|
296
|
+
set: [{ id: tagId }],
|
|
297
|
+
connectOrCreate: [
|
|
298
|
+
{ where: { slug: "orm" }, create: { slug: "orm", name: "ORM" } },
|
|
299
|
+
],
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
});
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
Within a single relation field, operations run in order: `disconnect` → `set` → `connect` / `connectOrCreate` → `create`. Mixing `set` with `connect` or `create` is discouraged — `set` replaces the full link set.
|
|
306
|
+
|
|
307
|
+
`updateMany` does not support relation writes. Nested `delete` on relations is not supported yet.
|
|
308
|
+
|
|
309
|
+
## Where clauses
|
|
310
|
+
|
|
311
|
+
`findMany`, `findFirst`, `findUnique`, `count`, `update`, `updateMany`, `delete`, and `deleteMany` all accept a typed `where` argument.
|
|
312
|
+
|
|
313
|
+
### Column filters
|
|
314
|
+
|
|
315
|
+
Equality shorthand and explicit operators:
|
|
316
|
+
|
|
317
|
+
```ts
|
|
318
|
+
// equality
|
|
319
|
+
await db.posts.findMany({ where: { published: true } });
|
|
320
|
+
|
|
321
|
+
// operators
|
|
322
|
+
await db.posts.findFirst({
|
|
323
|
+
where: {
|
|
324
|
+
title: { contains: "ORM" },
|
|
325
|
+
views: { gte: 100 },
|
|
326
|
+
id: { in: ["post_1", "post_2"] },
|
|
327
|
+
},
|
|
328
|
+
});
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
String columns support `equals`, `contains`, `startsWith`, `endsWith`, `in`, and `notIn`. Numeric, boolean, and date columns support `equals`, `gt`, `gte`, `lt`, `lte`, `in`, and `notIn`. All nullable columns also support `isNull` and `isNotNull`.
|
|
332
|
+
|
|
333
|
+
```ts
|
|
334
|
+
await db.users.findMany({
|
|
335
|
+
where: {
|
|
336
|
+
name: null, // shorthand for IS NULL
|
|
337
|
+
email: { isNotNull: true },
|
|
338
|
+
id: { notIn: ["user_1", "user_2"] },
|
|
339
|
+
},
|
|
340
|
+
});
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
### Logical combinators
|
|
344
|
+
|
|
345
|
+
Top-level `AND`, `OR`, and `NOT` keys combine conditions. Multiple sibling keys still imply `AND`:
|
|
346
|
+
|
|
347
|
+
```ts
|
|
348
|
+
await db.users.findMany({
|
|
349
|
+
where: {
|
|
350
|
+
OR: [
|
|
351
|
+
{ email: { contains: "@example.com" } },
|
|
352
|
+
{ email: { contains: "@test.com" } },
|
|
353
|
+
],
|
|
354
|
+
NOT: { name: { isNull: true } },
|
|
355
|
+
createdAt: { gte: new Date("2025-01-01") },
|
|
356
|
+
},
|
|
357
|
+
});
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### Relation filters
|
|
361
|
+
|
|
362
|
+
Relation names come from `fk(..., { as: "author", inverse: "posts" })` and `manyToMany(..., { as: "tags" })` — they are not the FK column names on the table.
|
|
363
|
+
|
|
364
|
+
| Pattern | Use for |
|
|
365
|
+
|---------|---------|
|
|
366
|
+
| `authorId: "user_1"` | Filter by FK column value |
|
|
367
|
+
| `author: { email: "a@b.c" }` | Filter by related record (to-one) |
|
|
368
|
+
| `posts: { some: { ... } }` | At least one related record matches (to-many) |
|
|
369
|
+
| `posts: { every: { ... } }` | All related records match (to-many) |
|
|
370
|
+
| `posts: { none: { ... } }` | No related records match (to-many) |
|
|
371
|
+
|
|
372
|
+
```ts
|
|
373
|
+
// users who have at least one published post
|
|
374
|
+
await db.users.findMany({
|
|
375
|
+
where: {
|
|
376
|
+
posts: { some: { published: true } },
|
|
377
|
+
},
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
// posts whose author has a verified email
|
|
381
|
+
await db.posts.findMany({
|
|
382
|
+
where: {
|
|
383
|
+
author: { email: { contains: "@" } },
|
|
384
|
+
},
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
// posts tagged "orm" (many-to-many via junction table)
|
|
388
|
+
await db.posts.findMany({
|
|
389
|
+
where: {
|
|
390
|
+
tags: { some: { slug: "orm" } },
|
|
391
|
+
},
|
|
392
|
+
});
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
Relation filters compile to SQL `EXISTS` subqueries, so they work with `findMany`, `count`, `updateMany`, and `deleteMany` without duplicate rows.
|
|
396
|
+
|
|
161
397
|
## Transactions
|
|
162
398
|
|
|
163
399
|
```ts
|
|
@@ -178,14 +414,28 @@ const [user, post] = await db.$transaction([
|
|
|
178
414
|
(tx) => tx.posts.create({ data: { title: "Hello" } }),
|
|
179
415
|
]);
|
|
180
416
|
|
|
181
|
-
// Options
|
|
417
|
+
// Options (outermost transaction only)
|
|
182
418
|
await db.$transaction(fn, {
|
|
183
419
|
isolationLevel: "Serializable", // ReadUncommitted | ReadCommitted | RepeatableRead | Serializable
|
|
184
420
|
readOnly: true,
|
|
185
421
|
});
|
|
422
|
+
|
|
423
|
+
// Nested $transaction uses PostgreSQL savepoints on the same connection.
|
|
424
|
+
// A nested failure rolls back only that block; the outer transaction can continue.
|
|
425
|
+
await db.$transaction(async (tx) => {
|
|
426
|
+
await tx.users.create({ data: { email: "outer@example.com" } });
|
|
427
|
+
|
|
428
|
+
await tx.$transaction(async (nested) => {
|
|
429
|
+
await nested.posts.create({
|
|
430
|
+
data: { title: "Nested", body: "...", authorId: "user_1" },
|
|
431
|
+
});
|
|
432
|
+
}).catch(() => undefined);
|
|
433
|
+
|
|
434
|
+
// Outer writes are kept even if the nested block failed.
|
|
435
|
+
});
|
|
186
436
|
```
|
|
187
437
|
|
|
188
|
-
Nested `create` calls inside a transaction do not start a separate transaction.
|
|
438
|
+
Nested `create` calls inside a transaction do not start a separate transaction. Nested `$transaction` calls use savepoints; `readOnly` and `isolationLevel` apply only to the outermost `BEGIN`.
|
|
189
439
|
|
|
190
440
|
## CLI
|
|
191
441
|
|
|
@@ -194,10 +444,43 @@ Nested `create` calls inside a transaction do not start a separate transaction.
|
|
|
194
444
|
| `neoorm generate` | Emit manifest, typed client, models, includes, and migrations |
|
|
195
445
|
| `neoorm migrate dev` | Apply pending migrations, then generate a new one if the schema changed |
|
|
196
446
|
| `neoorm migrate deploy` | Apply pending migrations |
|
|
447
|
+
| `neoorm migrate status` | List applied vs pending migrations |
|
|
448
|
+
| `neoorm migrate reset --force` | Drop public schema and re-apply migrations (local dev) |
|
|
197
449
|
| `neoorm db push` | Push the current snapshot schema to the database |
|
|
198
450
|
| `neoorm db pull` | Introspect the database into a schema file |
|
|
199
451
|
|
|
200
|
-
|
|
452
|
+
### Generate outcomes
|
|
453
|
+
|
|
454
|
+
`neoorm generate` always refreshes generated TypeScript files (`client.ts`, `manifest.ts`, `models.ts`, etc.). It prints one of four outcomes:
|
|
455
|
+
|
|
456
|
+
| Outcome | Meaning |
|
|
457
|
+
|---------|---------|
|
|
458
|
+
| **Schema unchanged** | Snapshot hash matches — no manifest or migration changes |
|
|
459
|
+
| **Client regenerated** | Manifest changed but no database DDL was needed (e.g. `enumMode`, relation metadata) |
|
|
460
|
+
| **Migration created** | New `migrations/<timestamp>/migration.sql` written |
|
|
461
|
+
| **Migration blocked** | Destructive or manual changes prevented writing SQL |
|
|
462
|
+
|
|
463
|
+
When migration is blocked or skipped, the CLI explains why — for example unsupported type casts (`alter_column_type_manual`), enum value changes, or destructive drops. Re-run with `--accept-data-loss` to include destructive DDL, or write a manual migration for unsupported type changes.
|
|
464
|
+
|
|
465
|
+
```bash
|
|
466
|
+
neoorm generate --accept-data-loss
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
### Migration status and reset
|
|
470
|
+
|
|
471
|
+
```bash
|
|
472
|
+
neoorm migrate status
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
Shows applied migrations (with timestamps), pending folders on disk, and warnings for drift (applied in DB but missing on disk).
|
|
476
|
+
|
|
477
|
+
```bash
|
|
478
|
+
neoorm migrate reset --force
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
Drops the `public` schema and re-applies all migrations from disk. Requires `--force`. Use `--skip-apply` to only drop the schema without re-applying.
|
|
482
|
+
|
|
483
|
+
`generate` creates migration SQL only when the schema diff produces DDL changes (new tables/columns, column renames via `.map()`, etc.).
|
|
201
484
|
|
|
202
485
|
## Plugins
|
|
203
486
|
|
|
@@ -231,6 +514,22 @@ await db.places.findMany({
|
|
|
231
514
|
|
|
232
515
|
PostGIS columns are stored as geometry/geography in PostgreSQL and exposed as GeoJSON in TypeScript.
|
|
233
516
|
|
|
517
|
+
### Citext
|
|
518
|
+
|
|
519
|
+
`citext()` is registered as a separate plugin that enables the `citext` extension when used in a schema:
|
|
520
|
+
|
|
521
|
+
```ts
|
|
522
|
+
import { citext, table } from "neoorm/schema";
|
|
523
|
+
|
|
524
|
+
users: table("users", {
|
|
525
|
+
email: citext().notNull().unique(),
|
|
526
|
+
})
|
|
527
|
+
```
|
|
528
|
+
|
|
529
|
+
## Examples
|
|
530
|
+
|
|
531
|
+
The [blog example](examples/blog/schema.ts) demonstrates relations, many-to-many, `jsonb`, `decimal`, and `enumType` columns. See [queries.example.ts](examples/blog/queries.example.ts) for typed queries and mutations using those types.
|
|
532
|
+
|
|
234
533
|
## API surface
|
|
235
534
|
|
|
236
535
|
| Import | Purpose |
|
package/dist/bin/neoorm.js
CHANGED
|
@@ -3,8 +3,8 @@ import { Command } from "commander";
|
|
|
3
3
|
import { join, resolve } from "node:path";
|
|
4
4
|
import { Pool } from "pg";
|
|
5
5
|
import { loadConfig } from "../config.js";
|
|
6
|
-
import { generateFromSchema } from "../codegen/generate.js";
|
|
7
|
-
import { migrateDeploy, dbPush } from "../migrate/runner.js";
|
|
6
|
+
import { generateFromSchema, formatGenerateSummary } from "../codegen/generate.js";
|
|
7
|
+
import { migrateDeploy, migrateReset, migrateStatus, formatMigrateStatus, dbPush, dbPushWarnings, } from "../migrate/runner.js";
|
|
8
8
|
import { introspectPostgres } from "../introspect/pull.js";
|
|
9
9
|
import { writeFile } from "node:fs/promises";
|
|
10
10
|
const program = new Command();
|
|
@@ -15,22 +15,18 @@ program
|
|
|
15
15
|
program
|
|
16
16
|
.command("generate")
|
|
17
17
|
.description("Generate manifest, client, and migrations from schema")
|
|
18
|
-
.
|
|
18
|
+
.option("--accept-data-loss", "Include destructive schema changes in generated migrations")
|
|
19
|
+
.action(async (options) => {
|
|
19
20
|
const cwd = process.cwd();
|
|
20
21
|
const config = await loadConfig(cwd);
|
|
21
22
|
const schemaPath = resolve(cwd, config.schema);
|
|
22
23
|
const outDir = resolve(cwd, config.out);
|
|
23
|
-
const {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
else if (schemaChanged) {
|
|
30
|
-
console.log("Manifest updated (no migration SQL needed)");
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
console.log("No schema changes detected");
|
|
24
|
+
const { warnings, summary } = await generateFromSchema(schemaPath, outDir, {
|
|
25
|
+
...(options.acceptDataLoss ? { acceptDataLoss: true } : {}),
|
|
26
|
+
...(config.datasource.enum ? { enumMode: config.datasource.enum } : {}),
|
|
27
|
+
});
|
|
28
|
+
for (const line of formatGenerateSummary(summary, outDir)) {
|
|
29
|
+
console.log(line);
|
|
34
30
|
}
|
|
35
31
|
for (const warning of warnings) {
|
|
36
32
|
console.warn(`Warning: ${warning}`);
|
|
@@ -39,14 +35,44 @@ program
|
|
|
39
35
|
program
|
|
40
36
|
.command("migrate")
|
|
41
37
|
.description("Run migrations")
|
|
42
|
-
.argument("[subcommand]", "dev | deploy")
|
|
43
|
-
.
|
|
38
|
+
.argument("[subcommand]", "dev | deploy | status | reset")
|
|
39
|
+
.option("--accept-data-loss", "Include destructive schema changes in generated migrations")
|
|
40
|
+
.option("--force", "Required for reset — drops the public schema and all data")
|
|
41
|
+
.option("--skip-apply", "With reset, only drop schema without re-applying migrations")
|
|
42
|
+
.action(async (subcommand, options) => {
|
|
44
43
|
const cwd = process.cwd();
|
|
45
44
|
const config = await loadConfig(cwd);
|
|
46
45
|
const outDir = resolve(cwd, config.out);
|
|
47
46
|
const migrationsDir = join(outDir, "migrations");
|
|
48
47
|
const pool = new Pool({ connectionString: config.datasource.url });
|
|
49
48
|
try {
|
|
49
|
+
if (subcommand === "status") {
|
|
50
|
+
const status = await migrateStatus(pool, migrationsDir);
|
|
51
|
+
for (const line of formatMigrateStatus(status, migrationsDir)) {
|
|
52
|
+
console.log(line);
|
|
53
|
+
}
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (subcommand === "reset") {
|
|
57
|
+
const { reapplied } = await migrateReset(pool, migrationsDir, {
|
|
58
|
+
force: options.force ?? false,
|
|
59
|
+
...(options.skipApply ? { skipApply: true } : {}),
|
|
60
|
+
});
|
|
61
|
+
console.log("✓ Database schema reset (public schema dropped and recreated)");
|
|
62
|
+
if (options.skipApply) {
|
|
63
|
+
console.log(" Skipped re-applying migrations (--skip-apply)");
|
|
64
|
+
}
|
|
65
|
+
else if (reapplied.length === 0) {
|
|
66
|
+
console.log(" No migrations on disk to apply");
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
console.log(` Re-applied ${reapplied.length} migration(s):`);
|
|
70
|
+
for (const name of reapplied) {
|
|
71
|
+
console.log(` - ${name}`);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
50
76
|
if (subcommand === "deploy" || subcommand === "dev") {
|
|
51
77
|
const applied = await migrateDeploy(pool, migrationsDir);
|
|
52
78
|
if (applied.length === 0) {
|
|
@@ -59,22 +85,28 @@ program
|
|
|
59
85
|
}
|
|
60
86
|
}
|
|
61
87
|
if (subcommand === "dev") {
|
|
62
|
-
const { generateFromSchema } = await import("../codegen/generate.js");
|
|
63
88
|
const schemaPath = resolve(cwd, config.schema);
|
|
64
|
-
const {
|
|
89
|
+
const { warnings, summary, migrationName } = await generateFromSchema(schemaPath, outDir, {
|
|
90
|
+
...(options.acceptDataLoss ? { acceptDataLoss: true } : {}),
|
|
91
|
+
...(config.datasource.enum ? { enumMode: config.datasource.enum } : {}),
|
|
92
|
+
});
|
|
93
|
+
for (const line of formatGenerateSummary(summary, outDir)) {
|
|
94
|
+
console.log(line);
|
|
95
|
+
}
|
|
65
96
|
for (const warning of warnings) {
|
|
66
97
|
console.warn(`Warning: ${warning}`);
|
|
67
98
|
}
|
|
68
99
|
if (migrationName) {
|
|
69
|
-
await migrateDeploy(pool, join(outDir, "migrations"));
|
|
70
|
-
|
|
100
|
+
const newlyApplied = await migrateDeploy(pool, join(outDir, "migrations"));
|
|
101
|
+
if (newlyApplied.length > 0) {
|
|
102
|
+
console.log(`Applied new migration: ${newlyApplied.join(", ")}`);
|
|
103
|
+
}
|
|
71
104
|
}
|
|
72
105
|
}
|
|
106
|
+
return;
|
|
73
107
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
process.exit(1);
|
|
77
|
-
}
|
|
108
|
+
console.error("Usage: neoorm migrate dev | deploy | status | reset");
|
|
109
|
+
process.exit(1);
|
|
78
110
|
}
|
|
79
111
|
finally {
|
|
80
112
|
await pool.end();
|
|
@@ -85,6 +117,7 @@ program
|
|
|
85
117
|
.description("Database utilities")
|
|
86
118
|
.argument("<subcommand>", "push | pull")
|
|
87
119
|
.option("-o, --output <file>", "Output file for pull", "schema.pulled.ts")
|
|
120
|
+
.option("--accept-data-loss", "Apply destructive schema changes when pushing to the database")
|
|
88
121
|
.action(async (subcommand, options) => {
|
|
89
122
|
const cwd = process.cwd();
|
|
90
123
|
const config = await loadConfig(cwd);
|
|
@@ -98,8 +131,17 @@ program
|
|
|
98
131
|
console.error("Run neoorm generate first");
|
|
99
132
|
process.exit(1);
|
|
100
133
|
}
|
|
101
|
-
await dbPush(pool, manifest)
|
|
102
|
-
|
|
134
|
+
const { appliedStatements, destructiveBlocked } = await dbPush(pool, manifest, { ...(options.acceptDataLoss ? { acceptDataLoss: true } : {}),
|
|
135
|
+
});
|
|
136
|
+
for (const warning of dbPushWarnings(destructiveBlocked)) {
|
|
137
|
+
console.warn(`Warning: ${warning}`);
|
|
138
|
+
}
|
|
139
|
+
if (appliedStatements === 0 && destructiveBlocked.length === 0) {
|
|
140
|
+
console.log("Database schema is up to date");
|
|
141
|
+
}
|
|
142
|
+
else {
|
|
143
|
+
console.log(`Database schema pushed (${appliedStatements} statement(s) applied)`);
|
|
144
|
+
}
|
|
103
145
|
}
|
|
104
146
|
else if (subcommand === "pull") {
|
|
105
147
|
const content = await introspectPostgres(pool);
|
package/dist/bin/neoorm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"neoorm.js","sourceRoot":"","sources":["../../src/bin/neoorm.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"neoorm.js","sourceRoot":"","sources":["../../src/bin/neoorm.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EACL,aAAa,EACb,YAAY,EACZ,aAAa,EACb,mBAAmB,EACnB,MAAM,EACN,cAAc,GACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CAAC,YAAY,CAAC;KACzB,OAAO,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AAG,CAAC,+BAA+B,CAAC,CAAC;YAC/C,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,GAAG,CACT,2BAA2B,iBAAiB,wBAAwB,CACrE,CAAC;YACJ,CAAC;QACH,CAAC;aAAM,IAAI,UAAU,KAAK,MAAM,EAAE,CAAC;YACjC,MAAM,OAAO,GAAG,MAAM,kBAAkB,CAAC,IAAI,CAAC,CAAC;YAC/C,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,IAAI,kBAAkB,CAAC,CAAC;YACtE,MAAM,SAAS,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9C,OAAO,CAAC,GAAG,CAAC,qBAAqB,UAAU,EAAE,CAAC,CAAC;QACjD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;YAC9C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;YAAS,CAAC;QACT,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;IACnB,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DestructiveChange, Manifest, ManifestColumn, ManifestDiff, TableDiff } from "../dialect/types.js";
|
|
2
|
+
export declare function columnSqlType(col: ManifestColumn, manifest?: Manifest): string;
|
|
3
|
+
export declare function columnsEqual(a: ManifestColumn, b: ManifestColumn, manifest?: Manifest): boolean;
|
|
4
|
+
export declare function buildMigrationSql(tableDiffs: TableDiff[], extensions?: string[], manifest?: Manifest, newEnumTypes?: Record<string, {
|
|
5
|
+
values: readonly string[];
|
|
6
|
+
}>): string[];
|
|
7
|
+
export declare function diffManifest(prev: Manifest | null, next: Manifest): ManifestDiff;
|
|
8
|
+
export declare function resolveMigrationSql(diff: ManifestDiff, prev: Manifest | null, next: Manifest, acceptDataLoss: boolean): {
|
|
9
|
+
sql: string[];
|
|
10
|
+
blocked: DestructiveChange[];
|
|
11
|
+
};
|
|
12
|
+
export declare function explainNoMigrationSql(prev: Manifest | null, next: Manifest, diff: ManifestDiff): string[];
|
|
13
|
+
export declare function formatDestructiveWarnings(destructive: DestructiveChange[]): string[];
|
|
14
|
+
//# sourceMappingURL=diff-manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-manifest.d.ts","sourceRoot":"","sources":["../../src/codegen/diff-manifest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,iBAAiB,EAEjB,QAAQ,EACR,cAAc,EAGd,YAAY,EACZ,SAAS,EACV,MAAM,qBAAqB,CAAC;AAiB7B,wBAAgB,aAAa,CAC3B,GAAG,EAAE,cAAc,EACnB,QAAQ,CAAC,EAAE,QAAQ,GAClB,MAAM,CAER;AAuCD,wBAAgB,YAAY,CAC1B,CAAC,EAAE,cAAc,EACjB,CAAC,EAAE,cAAc,EACjB,QAAQ,CAAC,EAAE,QAAQ,GAClB,OAAO,CAaT;AA0bD,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,SAAS,EAAE,EACvB,UAAU,GAAE,MAAM,EAAO,EACzB,QAAQ,CAAC,EAAE,QAAQ,EACnB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,CAAC,GAC3D,MAAM,EAAE,CAyCV;AAiCD,wBAAgB,YAAY,CAC1B,IAAI,EAAE,QAAQ,GAAG,IAAI,EACrB,IAAI,EAAE,QAAQ,GACb,YAAY,CAoDd;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,QAAQ,GAAG,IAAI,EACrB,IAAI,EAAE,QAAQ,EACd,cAAc,EAAE,OAAO,GACtB;IAAE,GAAG,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,iBAAiB,EAAE,CAAA;CAA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