feat(server): add Prisma schema with all 8 data models

- User, CardType, Membership, WeekTemplate, TimeSlot, Booking, Order, StudioConfig
- PrismaService and global PrismaModule
- snake_case column mapping with camelCase TypeScript fields
- Proper indexes and unique constraints
This commit is contained in:
richarjiang
2026-04-02 12:01:21 +08:00
parent 90b54d1138
commit e653580155
5 changed files with 232 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
import { Module } from '@nestjs/common'
import { ConfigModule } from '@nestjs/config'
import { AppController } from './app.controller'
import { PrismaModule } from './prisma/prisma.module'
@Module({
imports: [
@@ -8,6 +9,7 @@ import { AppController } from './app.controller'
isGlobal: true,
envFilePath: ['.env.local', '.env'],
}),
PrismaModule,
],
controllers: [AppController],
})

View File

@@ -0,0 +1,9 @@
import { Global, Module } from '@nestjs/common'
import { PrismaService } from './prisma.service'
@Global()
@Module({
providers: [PrismaService],
exports: [PrismaService],
})
export class PrismaModule {}

View File

@@ -0,0 +1,16 @@
import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common'
import { PrismaClient } from '@prisma/client'
@Injectable()
export class PrismaService
extends PrismaClient
implements OnModuleInit, OnModuleDestroy
{
async onModuleInit() {
await this.$connect()
}
async onModuleDestroy() {
await this.$disconnect()
}
}