A developer configures a Prisma schema file for a PostgreSQL database, defining client generation settings for multiple runtimes. The process includes setting up environment variables, writing a database migration script in package.json, and executing the migration to synchronize the local database schema.
Length 13:20
Captions English (Generated), Spanish (Auto-translated), French (Auto-translated), Korean (Auto-translated), Portuguese (Auto-translated), Vietnamese (Auto-translated) #prisma #postgresql #database #migration #schema #typescript #docker #cli #development #programming
0:00 Let's go ahead and now define a new Prisma folder, 0:04 which is where we're gonna host our schema.prisma 0:08 file, which is again, the database schema for this service 0:11 and the 0:12 source of truth for our schema. 0:15 This is also the default location that the Prisma CLI will look 0:19 for, for any database migrations, so we're gonna keep all of that code in 0:22 the Prisma folder. Now let's go ahead and define firstly, 0:27 the generator client. So this is gonna define the 0:31 actual client library that we're utilizing in our code, 0:34 and the client that Prisma will call when it needs to 0:38 generate types based off of the schema that we defined here. 0:42 So we provide the provider key here, and note I do have 0:46 syntax highlighting available for this Prisma file. 0:50 This is because I have a extension called 0:54 Prisma in VS Code. So simply install this extension 0:58 if you want 0:58 this syntax highlighting, which tells you when your schema 1:01 is in error 1:02 and why it's in error. So you can see here it's looking for the 1:05 provider, 1:07 and the provider is going to be the client library name we're 1:11 using, 1:12 and that's going to be prisma-client-js. 1:16 So typically this would be a complete client definition here, and this is all we 1:20 would need to generate client types in a simple project. 1:25 However, our setup is gonna be a little bit different because 1:28 we're 1:28 running in this monorepo, and remember, we're going to actually 1:32 be generating these types in our Docker container when we're running 1:36 in production, which is actually a different runtime, right? 1:40 Our Docker image is based off of Node 1:43 Alpine, which in my case is obviously a different runtime. 1:47 I'm running on Mac OS, and this is going to be in 1:51 Linux. So we need to do a couple of things to get
The rest of the transcript is for members.
Sign in