Database
Let's take a look at the project Database.
BuouNext utilizes Prisma as its ORM. We've seamlessly integrated it with NextAuth, Stripe(Paypal) and Others.
Setting Up the Database
You can use PostgreSQL or MySQL only by configure environment variables.
DATABASE_URL="mysql://user:pwd@service:port/database"
Setting Up the Prisma
Prisma Client
The Prisma Client, located at lib/db.ts, is globally instantiated and exported for use in your API routes. We recommend using this instance instead of importing it separately in each file.
Schema
The Prisma schema file (/prisma/schema.prisma) defines your database schema and models. It's used to generate the Prisma Client.
Migrations
The Prisma migrations file (/prisma/migrations/schema.prisma) defines your database sql.
Integration with NextAuth.js
NextSaaS integrates NextAuth with Prisma. The schema file is preconfigured with recommended values for models like User, Session, Account, Post and VerificationToken, as per NextAuth.js documentation.
Extra Info
Resource | URL |
---|---|
Prisma Documentation | https://www.prisma.io/docs/ |
Prisma GitHub Repository | https://github.com/prisma/prisma |
Prisma Migrate Playground | https://playground.prisma.io/guides |
NextAuth.js Prisma Adapter | https://next-auth.js.org/adapters/prisma |
Planetscale Connection Guide | https://www.prisma.io/docs/getting-started/setup-prisma/add-to-existing-project/relational-databases/connect-your-database-typescript-planetscale |