create-pg 1.1.2 → 1.1.4-pr72-add-user-agent-to-posthog-20215109996.0
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 +192 -32
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,79 +1,239 @@
|
|
|
1
|
-
# create-
|
|
1
|
+
# create-db
|
|
2
2
|
|
|
3
|
-
`create-
|
|
3
|
+
`create-db` is an open-source CLI tool and library that provisions [**temporary Prisma Postgres databases**](https://www.prisma.io/postgres?utm_source=create_db_npm_docs) with a single command.
|
|
4
4
|
|
|
5
5
|
Each database is available for **24 hours** by default. To keep the database permanently, you can **claim it for free** using the URL displayed in the output.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
This tool is designed for developers who need a fast way to test, prototype, or integrate Prisma Postgres without manual setup or creating an account.
|
|
8
|
+
|
|
9
|
+
## Installation and Usage
|
|
10
|
+
|
|
11
|
+
No installation required. Simply run:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npx create-db@latest
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
You can also use these aliases:
|
|
8
18
|
|
|
9
19
|
```bash
|
|
10
20
|
npx create-pg@latest
|
|
21
|
+
npx create-postgres@latest
|
|
11
22
|
```
|
|
12
23
|
|
|
13
24
|
## CLI Usage
|
|
14
25
|
|
|
26
|
+
### Commands
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx create-db [create] # Create a new database (default command)
|
|
30
|
+
npx create-db regions # List available regions
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Options
|
|
34
|
+
|
|
35
|
+
| Flag | Alias | Description |
|
|
36
|
+
|------|-------|-------------|
|
|
37
|
+
| `--region <region>` | `-r` | AWS region for the database |
|
|
38
|
+
| `--interactive` | `-i` | Interactive mode to select a region |
|
|
39
|
+
| `--json` | `-j` | Output machine-readable JSON |
|
|
40
|
+
| `--env <path>` | `-e` | Write DATABASE_URL and CLAIM_URL to specified .env file |
|
|
41
|
+
| `--help` | `-h` | Show help message |
|
|
42
|
+
| `--version` | | Show version |
|
|
43
|
+
|
|
44
|
+
### Available Regions
|
|
45
|
+
|
|
46
|
+
- `ap-southeast-1` - Asia Pacific (Singapore)
|
|
47
|
+
- `ap-northeast-1` - Asia Pacific (Tokyo)
|
|
48
|
+
- `eu-central-1` - Europe (Frankfurt)
|
|
49
|
+
- `eu-west-3` - Europe (Paris)
|
|
50
|
+
- `us-east-1` - US East (N. Virginia)
|
|
51
|
+
- `us-west-1` - US West (N. California)
|
|
52
|
+
|
|
53
|
+
### Examples
|
|
54
|
+
|
|
15
55
|
```bash
|
|
16
56
|
# Create database in auto-detected nearest region
|
|
17
|
-
npx create-
|
|
57
|
+
npx create-db
|
|
18
58
|
|
|
19
59
|
# Create database in a specific region
|
|
20
|
-
npx create-
|
|
21
|
-
npx create-
|
|
60
|
+
npx create-db --region eu-west-3
|
|
61
|
+
npx create-db -r us-east-1
|
|
22
62
|
|
|
23
63
|
# Interactive region selection
|
|
24
|
-
npx create-
|
|
25
|
-
npx create-
|
|
64
|
+
npx create-db --interactive
|
|
65
|
+
npx create-db -i
|
|
26
66
|
|
|
27
|
-
# Output as JSON
|
|
28
|
-
npx create-
|
|
29
|
-
npx create-
|
|
67
|
+
# Output as JSON (useful for scripting)
|
|
68
|
+
npx create-db --json
|
|
69
|
+
npx create-db -j
|
|
30
70
|
|
|
31
71
|
# Write connection string to .env file
|
|
32
|
-
npx create-
|
|
33
|
-
npx create-
|
|
72
|
+
npx create-db --env .env
|
|
73
|
+
npx create-db -e .env.local
|
|
74
|
+
|
|
75
|
+
# Combine flags
|
|
76
|
+
npx create-db -r eu-central-1 -j
|
|
77
|
+
npx create-db -i -e .env
|
|
34
78
|
|
|
35
79
|
# List available regions
|
|
36
|
-
npx create-
|
|
80
|
+
npx create-db regions
|
|
37
81
|
```
|
|
38
82
|
|
|
39
|
-
###
|
|
83
|
+
### JSON Output
|
|
40
84
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
85
|
+
When using `--json`, the output includes:
|
|
86
|
+
|
|
87
|
+
```json
|
|
88
|
+
{
|
|
89
|
+
"success": true,
|
|
90
|
+
"connectionString": "postgresql://user:pass@host:5432/postgres?sslmode=require",
|
|
91
|
+
"claimUrl": "https://create-db.prisma.io/claim?projectID=...",
|
|
92
|
+
"deletionDate": "2025-12-13T12:00:00.000Z",
|
|
93
|
+
"region": "us-east-1",
|
|
94
|
+
"name": "2025-12-12T12:00:00.000Z",
|
|
95
|
+
"projectId": "proj_..."
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Environment File Output
|
|
100
|
+
|
|
101
|
+
When using `--env`, the following variables are appended to the specified file:
|
|
102
|
+
|
|
103
|
+
```env
|
|
104
|
+
DATABASE_URL="postgresql://user:pass@host:5432/postgres?sslmode=require"
|
|
105
|
+
CLAIM_URL="https://create-db.prisma.io/claim?projectID=..."
|
|
106
|
+
```
|
|
48
107
|
|
|
49
108
|
## Programmatic API
|
|
50
109
|
|
|
110
|
+
You can also use `create-db` as a library in your Node.js applications:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
npm install create-db
|
|
114
|
+
# or
|
|
115
|
+
bun add create-db
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### `create(options?)`
|
|
119
|
+
|
|
120
|
+
Create a new Prisma Postgres database programmatically.
|
|
121
|
+
|
|
51
122
|
```typescript
|
|
52
|
-
import { create
|
|
123
|
+
import { create } from "create-db";
|
|
53
124
|
|
|
54
|
-
// Create a database
|
|
55
125
|
const result = await create({ region: "us-east-1" });
|
|
56
126
|
|
|
57
127
|
if (result.success) {
|
|
58
128
|
console.log(`Connection string: ${result.connectionString}`);
|
|
59
129
|
console.log(`Claim URL: ${result.claimUrl}`);
|
|
130
|
+
console.log(`Expires: ${result.deletionDate}`);
|
|
60
131
|
} else {
|
|
61
132
|
console.error(`Error: ${result.message}`);
|
|
62
133
|
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#### Options
|
|
137
|
+
|
|
138
|
+
| Option | Type | Description |
|
|
139
|
+
|--------|------|-------------|
|
|
140
|
+
| `region` | `RegionId` | AWS region for the database (optional, defaults to `us-east-1`) |
|
|
141
|
+
| `userAgent` | `string` | Custom user agent string for tracking (optional) |
|
|
142
|
+
|
|
143
|
+
### `regions()`
|
|
144
|
+
|
|
145
|
+
List available Prisma Postgres regions.
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
import { regions } from "create-db";
|
|
63
149
|
|
|
64
|
-
// List available regions
|
|
65
150
|
const availableRegions = await regions();
|
|
151
|
+
console.log(availableRegions);
|
|
152
|
+
// [{ id: "us-east-1", name: "US East (N. Virginia)", status: "available" }, ...]
|
|
66
153
|
```
|
|
67
154
|
|
|
68
|
-
|
|
155
|
+
### Type Guards
|
|
69
156
|
|
|
70
|
-
|
|
157
|
+
```typescript
|
|
158
|
+
import { create, isDatabaseSuccess, isDatabaseError } from "create-db";
|
|
71
159
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
160
|
+
const result = await create();
|
|
161
|
+
|
|
162
|
+
if (isDatabaseSuccess(result)) {
|
|
163
|
+
// result is DatabaseResult
|
|
164
|
+
console.log(result.connectionString);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (isDatabaseError(result)) {
|
|
168
|
+
// result is DatabaseError
|
|
169
|
+
console.error(result.message);
|
|
170
|
+
}
|
|
75
171
|
```
|
|
76
172
|
|
|
77
|
-
|
|
173
|
+
### Types
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
import type {
|
|
177
|
+
Region,
|
|
178
|
+
RegionId,
|
|
179
|
+
CreateDatabaseResult,
|
|
180
|
+
DatabaseResult,
|
|
181
|
+
DatabaseError,
|
|
182
|
+
ProgrammaticCreateOptions,
|
|
183
|
+
} from "create-db";
|
|
184
|
+
|
|
185
|
+
// RegionId is a union type of available regions
|
|
186
|
+
type RegionId = "ap-southeast-1" | "ap-northeast-1" | "eu-central-1" | "eu-west-3" | "us-east-1" | "us-west-1";
|
|
187
|
+
|
|
188
|
+
// DatabaseResult (success)
|
|
189
|
+
interface DatabaseResult {
|
|
190
|
+
success: true;
|
|
191
|
+
connectionString: string | null;
|
|
192
|
+
claimUrl: string;
|
|
193
|
+
deletionDate: string;
|
|
194
|
+
region: string;
|
|
195
|
+
name: string;
|
|
196
|
+
projectId: string;
|
|
197
|
+
userAgent?: string;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// DatabaseError (failure)
|
|
201
|
+
interface DatabaseError {
|
|
202
|
+
success: false;
|
|
203
|
+
error: string;
|
|
204
|
+
message: string;
|
|
205
|
+
raw?: string;
|
|
206
|
+
details?: unknown;
|
|
207
|
+
status?: number;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// CreateDatabaseResult is DatabaseResult | DatabaseError
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Region Validation with Zod
|
|
214
|
+
|
|
215
|
+
```typescript
|
|
216
|
+
import { RegionSchema } from "create-db";
|
|
217
|
+
|
|
218
|
+
// Validate region input
|
|
219
|
+
const result = RegionSchema.safeParse("us-east-1");
|
|
220
|
+
if (result.success) {
|
|
221
|
+
console.log("Valid region:", result.data);
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
## Claiming a Database
|
|
226
|
+
|
|
227
|
+
When you create a database, it is temporary and will be deleted after **24 hours**.
|
|
228
|
+
|
|
229
|
+
The output includes a **claim URL** that allows you to keep the database permanently for free.
|
|
230
|
+
|
|
231
|
+
**What claiming does:**
|
|
232
|
+
|
|
233
|
+
- Moves the database into your Prisma Data Platform account
|
|
234
|
+
- Prevents it from being auto-deleted
|
|
235
|
+
- Lets you continue using the database as a long-term instance
|
|
236
|
+
|
|
237
|
+
## Next Steps
|
|
78
238
|
|
|
79
|
-
|
|
239
|
+
- Refer to the [Prisma Postgres documentation](https://www.prisma.io/docs/postgres/introduction/npx-create-db) for more details.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-pg",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4-pr72-add-user-agent-to-posthog-20215109996.0",
|
|
4
4
|
"description": "Instantly create a temporary Prisma Postgres database with one command, then claim and persist it in your Prisma Data Platform project when ready.",
|
|
5
5
|
"author": "prisma",
|
|
6
6
|
"repository": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"create-pg": "./cli.js"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"create-db": "1.1.
|
|
39
|
+
"create-db": "1.1.4-pr72-add-user-agent-to-posthog-20215109996.0"
|
|
40
40
|
},
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|