@shophost/rest-api 2.0.23 → 2.0.25
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 +21 -6
- package/package.json +1 -1
- package/prisma.config.ts +9 -1
package/README.md
CHANGED
|
@@ -44,12 +44,16 @@ import { ManufacturerSchema } from "@shophost/rest-api/schemas";
|
|
|
44
44
|
|
|
45
45
|
## Database Schema Sync
|
|
46
46
|
|
|
47
|
-
The published package
|
|
47
|
+
The published package includes a CLI so a fresh project can push the packaged Prisma schema to its own database without copying `schema.prisma` into the app.
|
|
48
48
|
|
|
49
|
-
1.
|
|
50
|
-
- `
|
|
49
|
+
1. Add your database URL to one of these places in the consuming app:
|
|
50
|
+
- `.env.local`
|
|
51
|
+
- `.env`
|
|
52
|
+
- the shell environment
|
|
53
|
+
2. Use one of these variables:
|
|
51
54
|
- `POSTGRES_PRISMA_URL`
|
|
52
|
-
|
|
55
|
+
- `DATABASE_URL`
|
|
56
|
+
3. Run:
|
|
53
57
|
|
|
54
58
|
```bash
|
|
55
59
|
pnpm exec shophost-rest-api db push
|
|
@@ -57,14 +61,25 @@ pnpm exec shophost-rest-api db push
|
|
|
57
61
|
npx shophost-rest-api db push
|
|
58
62
|
```
|
|
59
63
|
|
|
64
|
+
Example:
|
|
65
|
+
|
|
66
|
+
```env
|
|
67
|
+
# .env.local
|
|
68
|
+
POSTGRES_PRISMA_URL=postgresql://user:password@host:5432/dbname?sslmode=require
|
|
69
|
+
```
|
|
70
|
+
|
|
60
71
|
You can pass regular Prisma `db push` flags through as well:
|
|
61
72
|
|
|
62
73
|
```bash
|
|
63
74
|
pnpm exec shophost-rest-api db push --accept-data-loss
|
|
64
|
-
pnpm exec shophost-rest-api db push --url "
|
|
75
|
+
pnpm exec shophost-rest-api db push --url "postgresql://user:password@host:5432/dbname?sslmode=require"
|
|
65
76
|
```
|
|
66
77
|
|
|
67
|
-
|
|
78
|
+
Notes:
|
|
79
|
+
|
|
80
|
+
- `.env.local` overrides `.env`
|
|
81
|
+
- `POSTGRES_PRISMA_URL` takes precedence over `DATABASE_URL`
|
|
82
|
+
- the CLI uses the `schema.prisma` and `prisma.config.ts` shipped inside `@shophost/rest-api`
|
|
68
83
|
|
|
69
84
|
## Development
|
|
70
85
|
|
package/package.json
CHANGED
package/prisma.config.ts
CHANGED
|
@@ -2,7 +2,15 @@ import "dotenv/config";
|
|
|
2
2
|
import { defineConfig } from "prisma/config";
|
|
3
3
|
|
|
4
4
|
function firstDefined(...names: string[]) {
|
|
5
|
-
|
|
5
|
+
for (const name of names) {
|
|
6
|
+
const value = process.env[name]?.trim();
|
|
7
|
+
|
|
8
|
+
if (value) {
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return undefined;
|
|
6
14
|
}
|
|
7
15
|
|
|
8
16
|
export default defineConfig({
|