Skip to content

Commit 0f373b2

Browse files
authored
Merge branch 'main' into docs/6.16.0
2 parents 6c0b3cc + eb89de2 commit 0f373b2

31 files changed

+745
-233
lines changed

content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/250-querying-the-database-typescript-cockroachdb.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ For the purpose of this guide however, you'll just create a plain Node.js script
2424
Create a new file named `index.ts` and add the following code to it:
2525

2626
```ts file=index.ts showLineNumbers
27-
import { PrismaClient } from '@prisma/client'
27+
import { PrismaClient } from './generated/prisma'
2828

2929
const prisma = new PrismaClient()
3030

content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/250-querying-the-database-typescript-mysql.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ For the purpose of this guide however, you'll just create a plain Node.js script
2424
Create a new file named `index.ts` and add the following code to it:
2525

2626
```ts file=index.ts showLineNumbers
27-
import { PrismaClient } from '@prisma/client'
27+
import { PrismaClient } from './generated/prisma'
2828

2929
const prisma = new PrismaClient()
3030

content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/250-querying-the-database-typescript-planetscale.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ For the purpose of this guide however, you'll just create a plain Node.js script
2424
Create a new file named `index.ts` and add the following code to it:
2525

2626
```ts file=index.ts showLineNumbers
27-
import { PrismaClient } from '@prisma/client'
27+
import { PrismaClient } from './generated/prisma'
2828

2929
const prisma = new PrismaClient()
3030

content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/250-querying-the-database-typescript-postgresql.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ For the purpose of this guide however, you'll just create a plain Node.js script
2323
Create a new file named `index.ts` and add the following code to it:
2424

2525
```ts file=index.ts showLineNumbers
26-
import { PrismaClient } from '@prisma/client'
26+
import { PrismaClient } from './generated/prisma'
2727

2828
const prisma = new PrismaClient()
2929

content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/250-querying-the-database-typescript-sqlserver.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ For the purpose of this guide however, you'll just create a plain Node.js script
2424
Create a new file named `index.ts` and add the following code to it:
2525

2626
```ts file=index.ts showLineNumbers
27-
import { PrismaClient } from '@prisma/client'
27+
import { PrismaClient } from './generated/prisma'
2828

2929
const prisma = new PrismaClient()
3030

content/100-getting-started/02-setup-prisma/200-add-to-existing-project/120-mongodb/250-querying-the-database-typescript-mongodb.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ For the purpose of this guide however, you'll just create a plain Node.js script
2222
Create a new file named `index.ts` and add the following code to it:
2323

2424
```js file=index.ts copy
25-
import { PrismaClient } from '@prisma/client'
25+
import { PrismaClient } from './generated/prisma'
2626

2727
const prisma = new PrismaClient()
2828

content/100-getting-started/03-prisma-postgres/100-from-the-cli.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ npx prisma migrate dev --name init
163163
Paste the following boilerplate into `index.ts`:
164164

165165
```ts file=index.ts
166-
import { PrismaClient } from '@prisma/client'
166+
import { PrismaClient } from './generated/prisma'
167167
import { withAccelerate } from '@prisma/extension-accelerate'
168168

169169
const prisma = new PrismaClient().$extends(withAccelerate())
@@ -190,7 +190,7 @@ This code contains a `main` function that's invoked at the end of the script. It
190190
Let's start with a small query to create a new `User` record in the database and log the resulting object to the console. Add the following code to your `index.ts` file:
191191

192192
```ts file=index.ts
193-
import { PrismaClient } from '@prisma/client'
193+
import { PrismaClient } from './generated/prisma'
194194
import { withAccelerate } from '@prisma/extension-accelerate'
195195

196196
const prisma = new PrismaClient().$extends(withAccelerate())
@@ -248,7 +248,7 @@ Prisma ORM offers various queries to read data from your database. In this secti
248248
Delete the previous Prisma ORM query and add the new `findMany` query instead:
249249

250250
```ts file=index.ts
251-
import { PrismaClient } from '@prisma/client'
251+
import { PrismaClient } from './generated/prisma'
252252
import { withAccelerate } from '@prisma/extension-accelerate'
253253

254254
const prisma = new PrismaClient().$extends(withAccelerate())
@@ -302,7 +302,7 @@ One of the main features of Prisma ORM is the ease of working with [relations](/
302302
First, adjust your script to include the nested query:
303303

304304
```ts file=index.ts
305-
import { PrismaClient } from '@prisma/client'
305+
import { PrismaClient } from './generated/prisma'
306306
import { withAccelerate } from '@prisma/extension-accelerate'
307307

308308
const prisma = new PrismaClient().$extends(withAccelerate())
@@ -367,7 +367,7 @@ npx tsx index.ts
367367
In order to also retrieve the `Post` records that belong to a `User`, you can use the `include` option via the `posts` relation field:
368368

369369
```ts file=index.ts
370-
import { PrismaClient } from '@prisma/client'
370+
import { PrismaClient } from './generated/prisma'
371371
import { withAccelerate } from '@prisma/extension-accelerate'
372372

373373
const prisma = new PrismaClient().$extends(withAccelerate())
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
title: 'Deploy to Railway'
3+
metaTitle: 'Deploy a Prisma app to Railway'
4+
metaDescription: 'Learn how to deploy an app that uses Prisma ORM and Prisma Postgres to Railway.'
5+
---
6+
7+
This guide explains how to deploy an app that uses Prisma ORM and Prisma Postgres to [Railway](https://railway.com?utm_medium=integration&utm_source=docs&utm_campaign=prisma). The app exposes a REST API and uses Prisma Client to query a Prisma Postgres database. Your app will run on Railway and connect to a managed Prisma Postgres database.
8+
9+
Railway is a deployment platform that simplifies the software development lifecycle with instant deployments, built-in observability, and effortless scaling. It supports code repositories and container images from popular registries. Railway handles configuration management, environment variables, and provides private networking between services.
10+
11+
To get a pre-wired Next.js Project with Prisma ORM, Prisma Postgres, and Railway, use the [Official Prisma Railway Template](https://railway.com/deploy/prisma-postgres?utm_medium=integration&utm_source=docs&utm_campaign=prisma).
12+
13+
This template automates the provisioning and setup of a Prisma Postgres database, linking it directly to your Next.js application upon deployment, making the entire project ready with just one click.
14+
15+
## Prerequisites
16+
17+
To get started, all you need is:
18+
19+
* A [Railway account](https://railway.com?utm_medium=integration&utm_source=docs&utm_campaign=prisma)
20+
* A GitHub repository with your application code.
21+
22+
:::note
23+
If you don't have a project ready, you can use our [example Prisma project](https://github.com/prisma/prisma-examples/tree/latest/deployment-platforms/railway). It's a simple Hono application that uses Prisma ORM and includes a REST API, a frontend for testing endpoints, and a defined Prisma schema with migrations.
24+
:::
25+
26+
## Deploy your application
27+
28+
### 1. Create a new Railway project
29+
30+
1. Go to the [Railway dashboard](https://railway.com/dashboard?utm_medium=integration&utm_source=docs&utm_campaign=prisma)
31+
2. Click **Create a New Project**
32+
3. Select **GitHub Repo**
33+
4. Click **Configure GitHub App** and authorize Railway
34+
5. Select your repository
35+
36+
Your application is now deploying to Railway, but it won't properly run without a database connection.
37+
38+
In the next section, you'll configure a database and set the `DATABASE_URL` environment variable in Railway.
39+
40+
![Railway deploying application](./images/railway-deploying.png)
41+
42+
## Configure your database
43+
44+
### 1. Get your database connection string
45+
46+
You'll need a Prisma Postgres connection string. There are two ways to obtain one:
47+
48+
- Create a new database on [Prisma Data Platform](https://console.prisma.io)
49+
- Run `npx create-db` for a temporary database _(no account required)_
50+
51+
### 2. Add the database URL to Railway
52+
53+
1. In your Railway project, open your service
54+
2. Go to the **Variables** tab
55+
3. Click **New Variable**
56+
4. Set the name to `DATABASE_URL`
57+
5. Paste your database connection string as the value
58+
6. Click **Deploy** to redeploy your application with the new environment variable
59+
60+
![Railway environment variables setup](./images/railway-env-vars.png)
61+
62+
### 3. Access your application
63+
64+
Once the deployment completes with the database URL configured:
65+
66+
1. Navigate to the **Settings** tab
67+
2. Under **Networking**, click **Generate Domain**
68+
3. Your application will be available at the generated URL
69+
70+
![Railway networking settings](./images/railway-networking.png)
71+
72+
Go to the generated URL and you'll see your deployed app!
73+
74+
If you used the example project, you should see three api endpoints already set up:
75+
- Check API status (`/api`)
76+
- Load feed (`/api/feed`)
77+
- Seed data (`/api/seed`)
78+
79+
![Railway deployed application](./images/railway-final-product.png)
80+
81+
If you see any errors:
82+
- Wait a minute and refresh
83+
- Ensure `DATABASE_URL` is set
84+
- Check the service logs
85+
- Redeploy
86+
87+
To learn more about the various features Railway offers for your application, visit the [Railway documentation](https://docs.railway.app?utm_medium=integration&utm_source=docs&utm_campaign=prisma).
26.9 KB
Loading
12.8 KB
Loading

0 commit comments

Comments
 (0)