Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions orm/postgis-express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"dependencies": {
"@prisma/adapter-pg": "6.18.0",
"@prisma/client": "6.18.0",
"@prisma/extension-accelerate": "2.0.2",
"dotenv": "16.6.1",
"dotenv": "^16.4.7",
"express": "5.1.0"
},
"devDependencies": {
Expand Down
14 changes: 14 additions & 0 deletions orm/postgis-express/prisma.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig, env } from 'prisma/config'
import 'dotenv/config'

export default defineConfig({
schema: 'prisma/schema.prisma',
migrations: {
path: 'prisma/migrations',
},
engine: 'classic',
datasource: {
url: env('DB_URL'),
},
})

13 changes: 13 additions & 0 deletions orm/prisma-mocking-javascript/prisma.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { defineConfig } from 'prisma/config'

export default defineConfig({
schema: 'prisma/schema.prisma',
migrations: {
path: 'prisma/migrations',
},
engine: 'classic',
datasource: {
url: 'file:./dev.db',
},
})

42 changes: 8 additions & 34 deletions orm/script/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,38 +65,27 @@ We found an existing schema.prisma file in your current project directory.

--- Database URL ---

Connect Prisma ORM to your Prisma Postgres database with this URL:
Connect Prisma ORM to your PostgreSQL database with this URL:

prisma+postgres://accelerate.prisma-data.net/?api_key=...
postgresql://user:password@host:port/database

--- Next steps ---

Go to https://pris.ly/ppg-init for detailed instructions.

1. Install and use the Prisma Accelerate extension
Prisma Postgres requires the Prisma Accelerate extension for querying. If you haven't already installed it, install it in your project:
npm install @prisma/extension-accelerate

...and add it to your Prisma Client instance:
import { withAccelerate } from "@prisma/extension-accelerate"

const prisma = new PrismaClient().$extends(withAccelerate())

2. Apply migrations
1. Apply migrations
Run the following command to create and apply a migration:
npx prisma migrate dev

3. Manage your data
2. Manage your data
View and edit your data locally by running this command:
npx prisma studio

...or online in Console:
https://console.prisma.io/{workspaceId}/{projectId}/studio

4. Send queries from your app
3. Send queries from your app
If you already have an existing app with Prisma ORM, you can now run it and it will send queries against your newly created Prisma Postgres instance.

5. Learn more
4. Learn more
For more info, visit the Prisma Postgres docs: https://pris.ly/ppg-docs
```

Expand All @@ -112,7 +101,7 @@ Now, paste the URL into it as a value for the `DATABASE_URL` environment variabl

```bash
# .env
DATABASE_URL=prisma+postgres://accelerate.prisma-data.net/?api_key=ey...
DATABASE_URL=postgresql://user:password@host:port/database
```

Run the following command to create tables in your database. This creates the `User` and `Post` tables that are defined in [`prisma/schema.prisma`](./prisma/schema.prisma):
Expand Down Expand Up @@ -232,24 +221,9 @@ Learn more about the different connection configurations in the [docs](https://w

<details><summary>Expand for an overview of example configurations with different databases</summary>

### Remove the Prisma Client extension

Before you proceed to use your own database, you should remove the Prisma client extension required for Prisma Postgres:

```terminal
npm uninstall @prisma/extension-accelerate
```

Remove the client extension from your `PrismaClient` instance:

```diff
- const prisma = new PrismaClient().$extends(withAccelerate())
+ const prisma = new PrismaClient()
```

### Your own PostgreSQL database

To use your own PostgreSQL database remove the `@prisma/extension-accelerate` package and remove the Prisma client extension.
This example already uses a standard PostgreSQL connection with the `@prisma/adapter-pg` adapter. You can connect to any PostgreSQL database using a standard connection string.

### SQLite

Expand Down
6 changes: 3 additions & 3 deletions orm/script/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
"dev": "tsx ./script.ts"
},
"dependencies": {
"@prisma/adapter-pg": "6.18.0",
"@prisma/client": "6.18.0",
"@prisma/extension-accelerate": "2.0.2",
"dotenv": "16.6.1"
"dotenv": "^16.4.7"
},
"devDependencies": {
"@types/node": "22.15.32",
"prisma": "6.18.0",
"tsx": "4.20.6",
"tsx": "^4.20.6",
"typescript": "5.8.2"
}
}
14 changes: 14 additions & 0 deletions orm/script/prisma.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig, env } from 'prisma/config'
import 'dotenv/config'

export default defineConfig({
schema: 'prisma/schema.prisma',
migrations: {
path: 'prisma/migrations',
},
engine: 'classic',
datasource: {
url: env('DATABASE_URL'),
},
})

5 changes: 3 additions & 2 deletions orm/script/script.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import 'dotenv/config'
import { PrismaClient } from './prisma/generated/client'
import { withAccelerate } from '@prisma/extension-accelerate'
import { PrismaPg } from '@prisma/adapter-pg'

const prisma = new PrismaClient().$extends(withAccelerate())
const pool = new PrismaPg({ connectionString: process.env.DATABASE_URL! })
const prisma = new PrismaClient({ adapter: pool })

// A `main` function so that we can use async/await
async function main() {
Expand Down
11 changes: 8 additions & 3 deletions orm/script/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
"sourceMap": true,
"outDir": "dist",
"strict": true,
"lib": ["esnext"],
"esModuleInterop": true
"lib": [
"esnext"
],
"esModuleInterop": true,
"module": "ESNext",
"moduleResolution": "node",
"resolveJsonModule": true
}
}
}
4 changes: 1 addition & 3 deletions orm/starter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,9 @@ Now, open the `.env` file and update the `DATABASE_URL` environment variables wi

```bash
# .env
DATABASE_URL="__YOUR_DATABASE_CONNECTION_STRING__"
DATABASE_URL="postgresql://user:password@host:port/database"
```

Note that `__YOUR_DATABASE_CONNECTION_STRING__` is a placeholder value that you need to replace with the values of your connection string.

### 3. Run a database migration to create the `User` table

The Prisma schema file contains a single `User` model. You can map this model to the database and create the corresponding `User` table using the following command:
Expand Down
8 changes: 4 additions & 4 deletions orm/starter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
"@types/node": "22.18.12",
"nodemon": "3.1.10",
"prisma": "6.18.0",
"tsx": "4.20.6",
"tsx": "^4.20.6",
"typescript": "5.8.2"
},
"dependencies": {
"@prisma/adapter-pg": "6.18.0",
"@prisma/client": "6.18.0",
"@prisma/extension-accelerate": "2.0.2",
"dotenv": "16.6.1"
"dotenv": "^16.4.7"
},
"prettier": {
"trailingComma": "all",
Expand All @@ -31,4 +31,4 @@
"bracketSpacing": true,
"arrowParens": "always"
}
}
}
14 changes: 14 additions & 0 deletions orm/starter/prisma.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig, env } from 'prisma/config'
import 'dotenv/config'

export default defineConfig({
schema: 'prisma/schema.prisma',
migrations: {
path: 'prisma/migrations',
},
engine: 'classic',
datasource: {
url: env('DATABASE_URL'),
},
})

5 changes: 3 additions & 2 deletions orm/starter/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import 'dotenv/config';
import { PrismaClient } from '../prisma/generated/client';
import { withAccelerate } from '@prisma/extension-accelerate';
import { PrismaPg } from '@prisma/adapter-pg';

const prisma = new PrismaClient().$extends(withAccelerate());
const pool = new PrismaPg({ connectionString: process.env.DATABASE_URL! });
const prisma = new PrismaClient({ adapter: pool });

async function main() {
const newUser = await prisma.user.create({
Expand Down
6 changes: 4 additions & 2 deletions orm/starter/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"module": "ESNext",
"moduleResolution": "node",
"rootDir": ".",
"outDir": "./dist",
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"skipLibCheck": true
"skipLibCheck": true,
"resolveJsonModule": true
},
"include": [
"src"
Expand Down
42 changes: 8 additions & 34 deletions orm/testing-express/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,38 +65,27 @@ We found an existing schema.prisma file in your current project directory.

--- Database URL ---

Connect Prisma ORM to your Prisma Postgres database with this URL:
Connect Prisma ORM to your PostgreSQL database with this URL:

prisma+postgres://accelerate.prisma-data.net/?api_key=...
postgresql://user:password@host:port/database

--- Next steps ---

Go to https://pris.ly/ppg-init for detailed instructions.

1. Install and use the Prisma Accelerate extension
Prisma Postgres requires the Prisma Accelerate extension for querying. If you haven't already installed it, install it in your project:
npm install @prisma/extension-accelerate

...and add it to your Prisma Client instance:
import { withAccelerate } from "@prisma/extension-accelerate"

const prisma = new PrismaClient().$extends(withAccelerate())

2. Apply migrations
1. Apply migrations
Run the following command to create and apply a migration:
npx prisma migrate dev

3. Manage your data
2. Manage your data
View and edit your data locally by running this command:
npx prisma studio

...or online in Console:
https://console.prisma.io/{workspaceId}/{projectId}/studio

4. Send queries from your app
3. Send queries from your app
If you already have an existing app with Prisma ORM, you can now run it and it will send queries against your newly created Prisma Postgres instance.

5. Learn more
4. Learn more
For more info, visit the Prisma Postgres docs: https://pris.ly/ppg-docs
```

Expand All @@ -112,7 +101,7 @@ Now, paste the URL into it as a value for the `DATABASE_URL` environment variabl

```bash
# .env
DATABASE_URL=prisma+postgres://accelerate.prisma-data.net/?api_key=ey...
DATABASE_URL=postgresql://user:password@host:port/database
```

Run the following command to create tables in your database. This creates the `User` and `Post` tables that are defined in [`prisma/schema.prisma`](./prisma/schema.prisma):
Expand Down Expand Up @@ -171,24 +160,9 @@ Learn more about the different connection configurations in the [docs](https://w

<details><summary>Expand for an overview of example configurations with different databases</summary>

### Remove the Prisma Client extension

Before you proceed to use your own database, you should remove the Prisma client extension required for Prisma Postgres:

```terminal
npm uninstall @prisma/extension-accelerate
```

Remove the client extension from your `PrismaClient` instance:

```diff
- const prisma = new PrismaClient().$extends(withAccelerate())
+ const prisma = new PrismaClient()
```

### Your own PostgreSQL database

To use your own PostgreSQL database remove the `@prisma/extension-accelerate` package and remove the Prisma client extension.
This example already uses a standard PostgreSQL connection with the `@prisma/adapter-pg` adapter. You can connect to any PostgreSQL database using a standard connection string.

### SQLite

Expand Down
8 changes: 2 additions & 6 deletions orm/testing-express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
"dependencies": {
"@prisma/adapter-pg": "6.18.0",
"@prisma/client": "6.18.0",
"@prisma/extension-accelerate": "2.0.2",
"dotenv": "16.6.1",
"dotenv": "^16.6.1",
"express": "5.1.0",
"jest-config": "29.7.0"
},
Expand All @@ -26,14 +25,11 @@
"@types/supertest": "6.0.3",
"jest": "29.7.0",
"jest-environment-node": "29.7.0",
"nanoid": "5.1.6",
"nanoid": "5.1.5",
"prisma": "6.18.0",
"supertest": "7.1.1",
"ts-jest": "29.4.5",
"tsx": "4.20.6",
"typescript": "5.8.2"
},
"prisma": {
"seed": "tsx prisma/seed.ts"
}
}
15 changes: 15 additions & 0 deletions orm/testing-express/prisma.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig, env } from 'prisma/config'
import 'dotenv/config'

export default defineConfig({
schema: 'prisma/schema.prisma',
migrations: {
path: 'prisma/migrations',
seed: 'tsx prisma/seed.ts',
},
engine: 'classic',
datasource: {
url: env('DATABASE_URL'),
},
})

Loading
Loading