@danielcok17/prisma-db 1.13.0 → 1.13.2
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 +129 -129
- package/package.json +47 -47
- package/prisma/app.prisma +1187 -1186
- package/prisma/law.prisma +82 -82
- package/prisma/migrations/20250818134929_init/migration.sql +374 -374
- package/prisma/migrations/20250903104817_add_workflow_log/migration.sql +103 -103
- package/prisma/migrations/20251009213916_add_email_authentication/migration.sql +54 -54
- package/prisma/migrations/20251031112719_change_default_message_count_to_10/migration.sql +2 -2
- package/prisma/migrations/20251111182842_add_stripe_integration_and_organizations/migration.sql +246 -246
- package/prisma/migrations/20260102162551_add_billing_interval/migration.sql +8 -8
- package/prisma/migrations/20260102220947_add_lawyer_pro_tier/migration.sql +2 -2
- package/prisma/migrations/20260110200252_add_canvas_documents/migration.sql +80 -80
- package/prisma/migrations/20260113150746_add_admin_grant_expiration/migration.sql +5 -5
- package/prisma/migrations/20260113205726_add_organization_invite/migration.sql +40 -40
- package/prisma/migrations/20260120212010_add_user_company_fields/migration.sql +22 -22
- package/prisma/migrations/20260129094625_add_utm_tracking_attribution/migration.sql +198 -198
package/README.md
CHANGED
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
# @danielcok17/prisma-db
|
|
2
|
-
|
|
3
|
-
Shared Prisma setup with dual Prisma clients: one for your app tables (`app` schema), one for existing law tables (`public` schema).
|
|
4
|
-
|
|
5
|
-
## Structure
|
|
6
|
-
- `prisma/app.prisma` — your models, migrate here (uses schema `app`)
|
|
7
|
-
- `prisma/law.prisma` — existing `public.law_*` and `public.version_paragraphs` tables (introspection only)
|
|
8
|
-
- `src/utils.ts` — exports `appPrisma` and `lawPrisma`
|
|
9
|
-
|
|
10
|
-
## Scripts
|
|
11
|
-
- `npm run db:generate` — generate both Prisma clients
|
|
12
|
-
- `npm run db:migrate` — run migrations for `app.prisma` only
|
|
13
|
-
- `npm run db:migrate:prod` — deploy migrations (app)
|
|
14
|
-
- `npm run db:pull:law` — introspect existing public law tables
|
|
15
|
-
- `npm run db:studio` — open Prisma Studio for `app`
|
|
16
|
-
|
|
17
|
-
## Import
|
|
18
|
-
```ts
|
|
19
|
-
import { appPrisma, lawPrisma } from '@danielcok17/prisma-db';
|
|
20
|
-
// or direct clients if you need advanced typing control
|
|
21
|
-
import { AppPrismaClient, LawPrismaClient } from '@danielcok17/prisma-db';
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
## Environment
|
|
25
|
-
Set the following env vars in your runtime/build (names match the `.prisma` files):
|
|
26
|
-
|
|
27
|
-
```
|
|
28
|
-
POSTGRES_PRISMA_URL=postgres://USER:PASS@HOST:PORT/DB?schema=app
|
|
29
|
-
POSTGRES_URL_NON_POOLING=postgres://USER:PASS@HOST:PORT/DB?schema=app
|
|
30
|
-
POSTGRES_PRISMA_URL_LAW=postgres://READONLY_USER:PASS@HOST:PORT/DB
|
|
31
|
-
POSTGRES_URL_NON_POOLING_LAW=postgres://READONLY_USER:PASS@HOST:PORT/DB
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Notes:
|
|
35
|
-
- Use a read-only role for `POSTGRES_PRISMA_URL_LAW`.
|
|
36
|
-
- Ensure the DB has `CREATE SCHEMA IF NOT EXISTS app;` executed once.
|
|
37
|
-
|
|
38
|
-
## Schema paths (for tooling / CI)
|
|
39
|
-
This package publishes the `prisma` directory. You can get absolute paths to the schemas programmatically:
|
|
40
|
-
|
|
41
|
-
```ts
|
|
42
|
-
import { appPrismaSchemaPath, lawPrismaSchemaPath, prismaMigrationsPath } from '@danielcok17/prisma-db';
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Examples:
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
# Use the packaged app schema with Prisma CLI
|
|
49
|
-
npx prisma migrate deploy --schema "$(node -e "console.log(require('@danielcok17/prisma-db').appPrismaSchemaPath)")"
|
|
50
|
-
|
|
51
|
-
# Or resolve directly to the file shipped in the package
|
|
52
|
-
APP_SCHEMA=$(node -e "console.log(require.resolve('@danielcok17/prisma-db/prisma/app.prisma'))")
|
|
53
|
-
npx prisma generate --schema "$APP_SCHEMA"
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
## Installation
|
|
59
|
-
```bash
|
|
60
|
-
npm install @danielcok17/prisma-db
|
|
61
|
-
# or
|
|
62
|
-
yarn add @danielcok17/prisma-db
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
The package runs Prisma generate on postinstall. If your environment blocks lifecycle scripts, run generate manually using `appPrismaSchemaPath` as shown below.
|
|
66
|
-
|
|
67
|
-
## Quick start
|
|
68
|
-
1) Set env vars (match the names used in `.prisma` files):
|
|
69
|
-
```
|
|
70
|
-
POSTGRES_PRISMA_URL=postgres://USER:PASS@HOST:PORT/DB?schema=app
|
|
71
|
-
POSTGRES_URL_NON_POOLING=postgres://USER:PASS@HOST:PORT/DB?schema=app
|
|
72
|
-
POSTGRES_PRISMA_URL_LAW=postgres://READONLY_USER:PASS@HOST:PORT/DB
|
|
73
|
-
POSTGRES_URL_NON_POOLING_LAW=postgres://READONLY_USER:PASS@HOST:PORT/DB
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
2) Apply migrations for the `app` schema:
|
|
77
|
-
```bash
|
|
78
|
-
APP_SCHEMA=$(node -e "console.log(require('@danielcok17/prisma-db').appPrismaSchemaPath)")
|
|
79
|
-
npx prisma migrate deploy --schema "$APP_SCHEMA"
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
3) Use the clients:
|
|
83
|
-
```ts
|
|
84
|
-
import { appPrisma, lawPrisma } from '@danielcok17/prisma-db';
|
|
85
|
-
|
|
86
|
-
const users = await appPrisma.user.findMany();
|
|
87
|
-
const laws = await lawPrisma.lawVersion.findMany({ take: 5 });
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## Upgrading to a new version
|
|
91
|
-
When you update the package, always apply migrations shipped with the new version.
|
|
92
|
-
|
|
93
|
-
```bash
|
|
94
|
-
npm install @danielcok17/prisma-db@latest
|
|
95
|
-
|
|
96
|
-
# Regenerate client (if your CI blocks postinstall or you want to be explicit)
|
|
97
|
-
APP_SCHEMA=$(node -e "console.log(require('@danielcok17/prisma-db').appPrismaSchemaPath)")
|
|
98
|
-
npx prisma generate --schema "$APP_SCHEMA"
|
|
99
|
-
|
|
100
|
-
# Apply new migrations
|
|
101
|
-
npx prisma migrate deploy --schema "$APP_SCHEMA"
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
Notes:
|
|
105
|
-
- Do not run `prisma migrate dev` in consumer apps. Schema changes are managed in this package and released via versions.
|
|
106
|
-
- If there are breaking changes, check the release notes for manual steps.
|
|
107
|
-
|
|
108
|
-
## CI/CD snippet
|
|
109
|
-
Add a deploy step to apply migrations using the schema from this package:
|
|
110
|
-
```bash
|
|
111
|
-
APP_SCHEMA=$(node -e "console.log(require('@danielcok17/prisma-db').appPrismaSchemaPath)")
|
|
112
|
-
npx prisma migrate deploy --schema "$APP_SCHEMA"
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Optionally regenerate the client at build/deploy time:
|
|
116
|
-
```bash
|
|
117
|
-
npx prisma generate --schema "$APP_SCHEMA"
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
## Prisma Studio (optional)
|
|
121
|
-
```bash
|
|
122
|
-
APP_SCHEMA=$(node -e "console.log(require('@danielcok17/prisma-db').appPrismaSchemaPath)")
|
|
123
|
-
npx prisma studio --schema "$APP_SCHEMA"
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
## Troubleshooting
|
|
127
|
-
- Missing client types/runtime: run `npx prisma generate --schema "$(node -e "console.log(require('@danielcok17/prisma-db').appPrismaSchemaPath)")"`.
|
|
128
|
-
- Migrate deploy fails: verify env vars and DB connectivity; ensure the `app` schema exists.
|
|
129
|
-
- Read-only access to law tables: use a user/role with SELECT-only permissions for `POSTGRES_PRISMA_URL_LAW`.
|
|
1
|
+
# @danielcok17/prisma-db
|
|
2
|
+
|
|
3
|
+
Shared Prisma setup with dual Prisma clients: one for your app tables (`app` schema), one for existing law tables (`public` schema).
|
|
4
|
+
|
|
5
|
+
## Structure
|
|
6
|
+
- `prisma/app.prisma` — your models, migrate here (uses schema `app`)
|
|
7
|
+
- `prisma/law.prisma` — existing `public.law_*` and `public.version_paragraphs` tables (introspection only)
|
|
8
|
+
- `src/utils.ts` — exports `appPrisma` and `lawPrisma`
|
|
9
|
+
|
|
10
|
+
## Scripts
|
|
11
|
+
- `npm run db:generate` — generate both Prisma clients
|
|
12
|
+
- `npm run db:migrate` — run migrations for `app.prisma` only
|
|
13
|
+
- `npm run db:migrate:prod` — deploy migrations (app)
|
|
14
|
+
- `npm run db:pull:law` — introspect existing public law tables
|
|
15
|
+
- `npm run db:studio` — open Prisma Studio for `app`
|
|
16
|
+
|
|
17
|
+
## Import
|
|
18
|
+
```ts
|
|
19
|
+
import { appPrisma, lawPrisma } from '@danielcok17/prisma-db';
|
|
20
|
+
// or direct clients if you need advanced typing control
|
|
21
|
+
import { AppPrismaClient, LawPrismaClient } from '@danielcok17/prisma-db';
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Environment
|
|
25
|
+
Set the following env vars in your runtime/build (names match the `.prisma` files):
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
POSTGRES_PRISMA_URL=postgres://USER:PASS@HOST:PORT/DB?schema=app
|
|
29
|
+
POSTGRES_URL_NON_POOLING=postgres://USER:PASS@HOST:PORT/DB?schema=app
|
|
30
|
+
POSTGRES_PRISMA_URL_LAW=postgres://READONLY_USER:PASS@HOST:PORT/DB
|
|
31
|
+
POSTGRES_URL_NON_POOLING_LAW=postgres://READONLY_USER:PASS@HOST:PORT/DB
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Notes:
|
|
35
|
+
- Use a read-only role for `POSTGRES_PRISMA_URL_LAW`.
|
|
36
|
+
- Ensure the DB has `CREATE SCHEMA IF NOT EXISTS app;` executed once.
|
|
37
|
+
|
|
38
|
+
## Schema paths (for tooling / CI)
|
|
39
|
+
This package publishes the `prisma` directory. You can get absolute paths to the schemas programmatically:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
import { appPrismaSchemaPath, lawPrismaSchemaPath, prismaMigrationsPath } from '@danielcok17/prisma-db';
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Examples:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# Use the packaged app schema with Prisma CLI
|
|
49
|
+
npx prisma migrate deploy --schema "$(node -e "console.log(require('@danielcok17/prisma-db').appPrismaSchemaPath)")"
|
|
50
|
+
|
|
51
|
+
# Or resolve directly to the file shipped in the package
|
|
52
|
+
APP_SCHEMA=$(node -e "console.log(require.resolve('@danielcok17/prisma-db/prisma/app.prisma'))")
|
|
53
|
+
npx prisma generate --schema "$APP_SCHEMA"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
## Installation
|
|
59
|
+
```bash
|
|
60
|
+
npm install @danielcok17/prisma-db
|
|
61
|
+
# or
|
|
62
|
+
yarn add @danielcok17/prisma-db
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The package runs Prisma generate on postinstall. If your environment blocks lifecycle scripts, run generate manually using `appPrismaSchemaPath` as shown below.
|
|
66
|
+
|
|
67
|
+
## Quick start
|
|
68
|
+
1) Set env vars (match the names used in `.prisma` files):
|
|
69
|
+
```
|
|
70
|
+
POSTGRES_PRISMA_URL=postgres://USER:PASS@HOST:PORT/DB?schema=app
|
|
71
|
+
POSTGRES_URL_NON_POOLING=postgres://USER:PASS@HOST:PORT/DB?schema=app
|
|
72
|
+
POSTGRES_PRISMA_URL_LAW=postgres://READONLY_USER:PASS@HOST:PORT/DB
|
|
73
|
+
POSTGRES_URL_NON_POOLING_LAW=postgres://READONLY_USER:PASS@HOST:PORT/DB
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
2) Apply migrations for the `app` schema:
|
|
77
|
+
```bash
|
|
78
|
+
APP_SCHEMA=$(node -e "console.log(require('@danielcok17/prisma-db').appPrismaSchemaPath)")
|
|
79
|
+
npx prisma migrate deploy --schema "$APP_SCHEMA"
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
3) Use the clients:
|
|
83
|
+
```ts
|
|
84
|
+
import { appPrisma, lawPrisma } from '@danielcok17/prisma-db';
|
|
85
|
+
|
|
86
|
+
const users = await appPrisma.user.findMany();
|
|
87
|
+
const laws = await lawPrisma.lawVersion.findMany({ take: 5 });
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Upgrading to a new version
|
|
91
|
+
When you update the package, always apply migrations shipped with the new version.
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npm install @danielcok17/prisma-db@latest
|
|
95
|
+
|
|
96
|
+
# Regenerate client (if your CI blocks postinstall or you want to be explicit)
|
|
97
|
+
APP_SCHEMA=$(node -e "console.log(require('@danielcok17/prisma-db').appPrismaSchemaPath)")
|
|
98
|
+
npx prisma generate --schema "$APP_SCHEMA"
|
|
99
|
+
|
|
100
|
+
# Apply new migrations
|
|
101
|
+
npx prisma migrate deploy --schema "$APP_SCHEMA"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Notes:
|
|
105
|
+
- Do not run `prisma migrate dev` in consumer apps. Schema changes are managed in this package and released via versions.
|
|
106
|
+
- If there are breaking changes, check the release notes for manual steps.
|
|
107
|
+
|
|
108
|
+
## CI/CD snippet
|
|
109
|
+
Add a deploy step to apply migrations using the schema from this package:
|
|
110
|
+
```bash
|
|
111
|
+
APP_SCHEMA=$(node -e "console.log(require('@danielcok17/prisma-db').appPrismaSchemaPath)")
|
|
112
|
+
npx prisma migrate deploy --schema "$APP_SCHEMA"
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Optionally regenerate the client at build/deploy time:
|
|
116
|
+
```bash
|
|
117
|
+
npx prisma generate --schema "$APP_SCHEMA"
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Prisma Studio (optional)
|
|
121
|
+
```bash
|
|
122
|
+
APP_SCHEMA=$(node -e "console.log(require('@danielcok17/prisma-db').appPrismaSchemaPath)")
|
|
123
|
+
npx prisma studio --schema "$APP_SCHEMA"
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Troubleshooting
|
|
127
|
+
- Missing client types/runtime: run `npx prisma generate --schema "$(node -e "console.log(require('@danielcok17/prisma-db').appPrismaSchemaPath)")"`.
|
|
128
|
+
- Migrate deploy fails: verify env vars and DB connectivity; ensure the `app` schema exists.
|
|
129
|
+
- Read-only access to law tables: use a user/role with SELECT-only permissions for `POSTGRES_PRISMA_URL_LAW`.
|
package/package.json
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@danielcok17/prisma-db",
|
|
3
|
-
"version": "1.13.
|
|
4
|
-
"description": "Shared Prisma schema for Legal AI applications",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist",
|
|
9
|
-
"prisma/*.prisma",
|
|
10
|
-
"prisma/migrations"
|
|
11
|
-
],
|
|
12
|
-
"publishConfig": {
|
|
13
|
-
"access": "public"
|
|
14
|
-
},
|
|
15
|
-
"scripts": {
|
|
16
|
-
"build": "npm run db:generate && tsc",
|
|
17
|
-
"dev": "tsc --watch",
|
|
18
|
-
"db:generate": "prisma generate --schema ./prisma/app.prisma && prisma generate --schema ./prisma/law.prisma",
|
|
19
|
-
"db:push": "prisma db push --schema ./prisma/app.prisma",
|
|
20
|
-
"db:migrate": "prisma migrate dev --schema ./prisma/app.prisma",
|
|
21
|
-
"db:migrate:prod": "prisma migrate deploy --schema ./prisma/app.prisma",
|
|
22
|
-
"db:studio": "prisma studio --schema ./prisma/app.prisma",
|
|
23
|
-
"db:pull:law": "prisma db pull --schema ./prisma/law.prisma",
|
|
24
|
-
"db:seed": "tsx prisma/seed.ts",
|
|
25
|
-
"postinstall": "npm run db:generate"
|
|
26
|
-
},
|
|
27
|
-
"keywords": [
|
|
28
|
-
"prisma",
|
|
29
|
-
"postgres",
|
|
30
|
-
"schema",
|
|
31
|
-
"migrations"
|
|
32
|
-
],
|
|
33
|
-
"author": "",
|
|
34
|
-
"license": "MIT",
|
|
35
|
-
"engines": {
|
|
36
|
-
"node": ">=18.18"
|
|
37
|
-
},
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"@prisma/client": "^6.17.0"
|
|
40
|
-
},
|
|
41
|
-
"devDependencies": {
|
|
42
|
-
"@types/node": "^24.3.0",
|
|
43
|
-
"prisma": "^6.17.0",
|
|
44
|
-
"tsx": "^4.0.0",
|
|
45
|
-
"typescript": "^5.0.0"
|
|
46
|
-
}
|
|
47
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@danielcok17/prisma-db",
|
|
3
|
+
"version": "1.13.2",
|
|
4
|
+
"description": "Shared Prisma schema for Legal AI applications",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist",
|
|
9
|
+
"prisma/*.prisma",
|
|
10
|
+
"prisma/migrations"
|
|
11
|
+
],
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "npm run db:generate && tsc",
|
|
17
|
+
"dev": "tsc --watch",
|
|
18
|
+
"db:generate": "prisma generate --schema ./prisma/app.prisma && prisma generate --schema ./prisma/law.prisma",
|
|
19
|
+
"db:push": "prisma db push --schema ./prisma/app.prisma",
|
|
20
|
+
"db:migrate": "prisma migrate dev --schema ./prisma/app.prisma",
|
|
21
|
+
"db:migrate:prod": "prisma migrate deploy --schema ./prisma/app.prisma",
|
|
22
|
+
"db:studio": "prisma studio --schema ./prisma/app.prisma",
|
|
23
|
+
"db:pull:law": "prisma db pull --schema ./prisma/law.prisma",
|
|
24
|
+
"db:seed": "tsx prisma/seed.ts",
|
|
25
|
+
"postinstall": "npm run db:generate"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"prisma",
|
|
29
|
+
"postgres",
|
|
30
|
+
"schema",
|
|
31
|
+
"migrations"
|
|
32
|
+
],
|
|
33
|
+
"author": "",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=18.18"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@prisma/client": "^6.17.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/node": "^24.3.0",
|
|
43
|
+
"prisma": "^6.17.0",
|
|
44
|
+
"tsx": "^4.0.0",
|
|
45
|
+
"typescript": "^5.0.0"
|
|
46
|
+
}
|
|
47
|
+
}
|