Skip to content

Commit e9290c7

Browse files
Merge pull request #2796 from engcfraposo/patch-1
doc(prisma): add prsima connection to mssql and azure sql
2 parents 71dd793 + 43cdf49 commit e9290c7

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

content/recipes/prisma.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ Make sure you have a [ConfigModule](https://docs.nestjs.com/techniques/configura
9292

9393
SQLite databases are simple files; no server is required to use a SQLite database. So instead of configuring a connection URL with a _host_ and _port_, you can just point it to a local file which in this case is called `dev.db`. This file will be created in the next step.
9494

95-
<details><summary>Expand if you're using PostgreSQL or MySQL</summary>
95+
<details><summary>Expand if you're using PostgreSQL, MySQL, MsSQL or Azure SQL</summary>
9696

9797
With PostgreSQL and MySQL, you need to configure the connection URL to point to the _database server_. You can learn more about the required connection URL format [here](https://www.prisma.io/docs/reference/database-reference/connection-urls).
9898

@@ -152,6 +152,31 @@ DATABASE_URL="mysql://USER:PASSWORD@HOST:PORT/DATABASE"
152152

153153
Replace the placeholders spelled in all uppercase letters with your database credentials.
154154

155+
**Microsoft SQL Server / Azure SQL Server**
156+
157+
If you're using Microsoft SQL Server or Azure SQL Server, you have to adjust the `schema.prisma` and `.env` files as follows:
158+
159+
**`schema.prisma`**
160+
161+
```groovy
162+
datasource db {
163+
provider = "sqlserver"
164+
url = env("DATABASE_URL")
165+
}
166+
167+
generator client {
168+
provider = "prisma-client-js"
169+
}
170+
```
171+
172+
**`.env`**
173+
174+
Replace the placeholders spelled in all uppercase letters with your database credentials. Note that if you're unsure what to provide for the `encrypt` placeholder, it's most likely the default value `true`:
175+
176+
```bash
177+
DATABASE_URL="sqlserver://HOST:PORT;database=DATABASE;user=USER;password=PASSWORD;encrypt=true"
178+
```
179+
155180
</details>
156181

157182
#### Create two database tables with Prisma Migrate

0 commit comments

Comments
 (0)