feat(db): add Prisma schema with all models

Configure Prisma ORM with PostgreSQL database schema including:
- Organization, Site, Court models for multi-tenancy
- User with role-based access and Client for customers
- Booking and Payment models for reservations
- MembershipPlan and Membership for subscriptions
- Product, Sale, SaleItem, CashRegister for POS
- Tournament, TournamentInscription, Match for competitions
- All necessary enums, relations, indexes, and cascading deletes
- Prisma client singleton for Next.js

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Ivan
2026-02-01 06:17:02 +00:00
parent b042e14fc7
commit 981783babb
4 changed files with 574 additions and 1 deletions

18
apps/web/lib/db.ts Normal file
View File

@@ -0,0 +1,18 @@
import { PrismaClient } from '@prisma/client';
declare global {
// eslint-disable-next-line no-var
var prisma: PrismaClient | undefined;
}
export const db =
globalThis.prisma ||
new PrismaClient({
log: process.env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'],
});
if (process.env.NODE_ENV !== 'production') {
globalThis.prisma = db;
}
export default db;