Explore the database structure and management in the BuouNext project. Learn about the schema design, data models, and how to effectively interact with the database using various tools and techniques to ensure data integrity and performance.
BuouNext utilizes Drizzle as its ORM. We've seamlessly integrated it with NextAuth, Stripe(Paypal) and Others.
You can use PostgreSQL by configuring environment variables.
DATABASE_URL="postgres://user:pwd@service:port/database"The Drizzle client, located at lib/db.ts, is instantiated and exported for use in your API routes. We recommend using this instance instead of creating a new client in each file.
The Drizzle schema file (/lib/db/schema.ts) defines your database schema and models. It's used by Drizzle Kit to generate migrations.
Drizzle migrations are generated with pnpm db:generate and applied with pnpm db:migrate. Generated files live in /drizzle.
BuouNext integrates NextAuth with Drizzle. The schema file includes the recommended models for User, Session, Account, Post and VerificationToken, as per Auth.js adapter guidelines.
| Resource | URL |
|---|---|
| Drizzle Documentation | https://orm.drizzle.team/docs/ |
| Drizzle Kit Documentation | https://orm.drizzle.team/docs/drizzle-kit |
| Auth.js Drizzle Adapter | https://authjs.dev/reference/adapter/drizzle |