caspian-utils 0.0.7 → 0.0.8

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.
@@ -21,7 +21,7 @@ The current workspace includes a local `prisma` binary, but it does not include
21
21
  Use Caspian CLI commands for three main tasks:
22
22
 
23
23
  - Create a new application.
24
- - Generate code from your Prisma schema.
24
+ - Regenerate Node and Python ORM code from your Prisma schema.
25
25
  - Update framework-managed project files.
26
26
 
27
27
  Before running update commands, review `caspian.config.json` because it controls overwrite behavior.
@@ -60,15 +60,23 @@ Common scaffold flags include:
60
60
 
61
61
  ## Code Generation
62
62
 
63
- When your Prisma schema changes in this workspace, regenerate the client with the local Prisma CLI:
63
+ When `prisma/schema.prisma` changes in this workspace, use this command flow:
64
64
 
65
65
  ```bash
66
+ npx prisma migrate dev
67
+
68
+ # If the change requires refreshed seed data:
66
69
  npx prisma generate
70
+ npx prisma db seed
71
+
72
+ npx ppy generate
67
73
  ```
68
74
 
69
- This flow regenerates the Prisma client defined by `generator client` in `prisma/schema.prisma`. In the current workspace, that generator uses `prisma-client-js`.
75
+ Use `npx prisma migrate dev` first so the development database and migration history stay aligned. If the updated schema affects seed data, run `npx prisma generate` before `npx prisma db seed` so Node-side tooling such as `prisma/seed.ts` uses the current generated client.
76
+
77
+ Always finish with `npx ppy generate`. That is the required way to refresh the Python ORM classes used by the app after a schema change.
70
78
 
71
- This workspace already includes an app-owned Python database layer in `src/lib/prisma/`, so reuse that package for Python-side database access instead of creating a second helper.
79
+ This workspace already includes an app-owned Python database layer in `src/lib/prisma/`, so reuse that package for Python-side database access instead of creating a second helper. Do not hand-edit generated ORM classes.
72
80
 
73
81
  See `database.md` for the full Prisma workflow, including `.env`, `prisma.config.ts`, migrations, and async usage patterns.
74
82
 
@@ -113,7 +121,10 @@ If an AI agent is deciding which command flow to use, apply these rules first.
113
121
  - Use `npx create-caspian-app@latest` when the user is creating a new project.
114
122
  - Use `npx casp update project` only for an existing Caspian project.
115
123
  - Read `caspian.config.json` before running update commands.
116
- - Use `npx prisma generate` after Prisma schema changes in this workspace.
124
+ - When `prisma/schema.prisma` changes, run `npx prisma migrate dev` first.
125
+ - If the change requires seed data, run `npx prisma generate` and then `npx prisma db seed`.
126
+ - Run `npx ppy generate` after every Prisma schema change to refresh the Python ORM classes.
127
+ - Never hand-edit generated Prisma or Python ORM classes.
117
128
  - Check `database.md` when the task involves Prisma setup, schema updates, or the current workspace's schema, migration, and seed tooling.
118
129
  - Check [routing.md](./routing.md) before generating or modifying route folders under `src/app/`.
119
130
  - Check [project-structure.md](./project-structure.md) before placing generated files into the project.
@@ -22,9 +22,10 @@ The standard Prisma flow in Caspian is:
22
22
 
23
23
  1. Define models in `prisma/schema.prisma`.
24
24
  2. Configure `DATABASE_URL` in `.env`.
25
- 3. Run `npx prisma generate` after schema changes.
26
- 4. Use the generated client from Node-side tooling such as `prisma/seed.ts`.
27
- 5. Reuse the shared Python database layer in `src/lib/prisma/` when Python route or RPC code needs database access.
25
+ 3. Run `npx prisma migrate dev` after schema changes so the development database and migration history stay aligned.
26
+ 4. If the change requires seed data, run `npx prisma generate` and then `npx prisma db seed`.
27
+ 5. Run `npx ppy generate` so the Python ORM classes stay aligned with the updated schema.
28
+ 6. Reuse the shared Python database layer in `src/lib/prisma/` when Python route or RPC code needs database access, and never hand-edit generated ORM classes.
28
29
 
29
30
  Use this workflow instead of writing raw SQL first. Drop to raw SQL only when a query cannot be expressed clearly with the generated client.
30
31
 
@@ -99,22 +100,30 @@ model Post {
99
100
  }
100
101
  ```
101
102
 
102
- After changing the schema, run `npx prisma generate` so the generated Node Prisma client stays in sync with the schema. If the Python layer in `src/lib/prisma/` depends on the updated shape, regenerate or refresh that application-owned code too.
103
+ After changing the schema, use this order in the current workspace:
104
+
105
+ 1. Run `npx prisma migrate dev`.
106
+ 2. If seed data or the seed script needs the new schema, run `npx prisma generate` and then `npx prisma db seed`.
107
+ 3. Run `npx ppy generate` to refresh the generated Python ORM classes.
108
+
109
+ Do not hand-edit generated Prisma or Python ORM output. Treat `prisma/schema.prisma` as the source of truth and regenerate from it.
103
110
 
104
111
  ## Command Reference
105
112
 
106
113
  Use these commands for the normal Prisma lifecycle in Caspian:
107
114
 
108
- - `npx prisma generate` compiles `schema.prisma` into the generated Prisma client. Run this after every schema change.
109
- - `npx prisma migrate dev` creates and applies a development migration.
115
+ - `npx prisma migrate dev` creates and applies a development migration. This is the first command to run after changing `prisma/schema.prisma`.
116
+ - `npx prisma generate` compiles `schema.prisma` into the generated Node Prisma client. Run it before `npx prisma db seed` when the updated seed flow depends on the new schema.
117
+ - `npx prisma db seed` runs the configured seeding script.
118
+ - `npx ppy generate` regenerates the Python ORM classes used by the app. Use this after every schema change.
110
119
  - `npx prisma migrate deploy` applies pending migrations in deployment environments.
111
120
  - `npx prisma db push` syncs schema changes without creating a migration file, which is useful for prototyping.
112
- - `npx prisma db seed` runs the configured seeding script.
113
121
  - `npx prisma studio` opens the Prisma data browser.
114
122
 
115
123
  Default rule:
116
124
 
117
- - Use `npx prisma generate` every time the schema changes.
125
+ - When `prisma/schema.prisma` changes, use this order: `npx prisma migrate dev`; if seeding is involved, run `npx prisma generate` and `npx prisma db seed`; then run `npx ppy generate`.
126
+ - Never hand-edit generated Prisma or Python ORM classes, and never replace `npx ppy generate` with a manual class update.
118
127
  - Use migrations for tracked application changes.
119
128
  - Use `db push` only when you intentionally want a faster, migration-free prototype loop.
120
129
 
@@ -142,7 +151,7 @@ After `npx prisma generate`, Prisma writes the generated JavaScript client into
142
151
 
143
152
  This workspace already includes an app-owned async Python database package that exports `prisma`, `PrismaClient`, generated models, and helper types.
144
153
 
145
- If Python route or RPC code needs database access, import from `src.lib.prisma` and keep that import path explicit in application code.
154
+ If Python route or RPC code needs database access, import from `src.lib.prisma` and keep that import path explicit in application code. Refresh generated classes with `npx ppy generate` instead of editing them manually.
146
155
 
147
156
  ## Python Route Usage
148
157
 
@@ -306,8 +315,9 @@ Use raw SQL sparingly. Prefer the generated Prisma API when the query can be exp
306
315
 
307
316
  ## Recommended Project Rules
308
317
 
309
- - Keep the schema in `prisma/schema.prisma` and regenerate the client after changes.
318
+ - Keep the schema in `prisma/schema.prisma` and follow the required regeneration order after changes: `npx prisma migrate dev`, optional seed flow, then `npx ppy generate`.
310
319
  - Reuse `src/lib/prisma/` for Python-side database access instead of creating a second bridge.
320
+ - Never hand-edit generated Prisma or Python ORM classes.
311
321
  - Keep reusable database helpers in `src/lib/`, and keep route-specific orchestration in `src/app/`.
312
322
  - Use `await` with Prisma operations.
313
323
  - Convert Prisma objects to template-safe dictionaries when rendering HTML.
@@ -320,7 +330,10 @@ If an AI agent is working on a Caspian app with Prisma enabled, apply these rule
320
330
 
321
331
  - Treat Prisma as the default ORM and persistence layer.
322
332
  - Read `prisma/schema.prisma` before proposing model, relation, or field changes.
323
- - Run `npx prisma generate` after schema changes.
333
+ - When `prisma/schema.prisma` changes, run `npx prisma migrate dev` first.
334
+ - If the schema change requires seed data, run `npx prisma generate` and then `npx prisma db seed`.
335
+ - Run `npx ppy generate` after schema changes to refresh the Python ORM classes.
336
+ - Never hand-edit generated Prisma or Python ORM classes.
324
337
  - Read `prisma.config.ts` and `prisma/seed.ts` when you need the current workspace's Prisma tooling examples.
325
338
  - Reuse the existing `src/lib/prisma/` package when the Python app needs database access.
326
339
  - Put reusable database helpers in `src/lib/`; keep route and RPC orchestration in `src/app/`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "caspian-utils",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Caspian tooling",
5
5
  "main": "index.js",
6
6
  "scripts": {