Ionia-Devs / chameleon

https://chameleon-sandy.vercel.app
1 stars 1 forks source link

Define Prisma Schema for App Features #10

Open Balance8 opened 10 months ago

Balance8 commented 10 months ago

Ticket: Define Prisma Schema for App Features

User Story: As a developer, I need a well-defined Prisma schema to effectively manage database operations for the app's features.

Description

Create a comprehensive Prisma schema that defines the data models for the cosplay-photographer scheduling app. This schema should cover user accounts, profiles, messaging, portfolio, bookings, reviews, and subscriptions. The database is managed on PlanetScale.

Acceptance Criteria

  1. User Account Model: Define fields for user registration, authentication, and role (cosplayer/photographer).
  2. Profile Model: Include details like bio, preferences, and portfolio links.
  3. Messaging Model: Structure for storing messages, sender and receiver details.
  4. Portfolio Model: Fields for image URLs, descriptions, and photographer details.
  5. Booking Model: Schema for managing booking dates, user details, and status.
  6. Review Model: Structure for ratings, text reviews, and associated user information.
  7. Subscription Model: Define subscription tiers, user subscription details, and payment status.
  8. Validation and Relations: Ensure proper relations between models and data validation rules.

Technical Notes

Example Prisma Schema

model User {
  id            Int       @id @default(autoincrement())
  email         String    @unique
  password      String
  role          UserRole
  profile       Profile?
  messages      Message[]
  bookings      Booking[]
  reviews       Review[]
  subscriptions Subscription[]
}

model Profile {
  id         Int      @id @default(autoincrement())
  userId     Int
  bio        String?
  portfolio  String?
  user       User     @relation(fields: [userId], references: [id])
}

model Message {
  id         Int      @id @default(autoincrement())
  content    String
  fromId     Int
  toId       Int
  fromUser   User     @relation("MessageFrom", fields: [fromId], references: [id])
  toUser     User     @relation("MessageTo", fields: [toId], references: [id])
  createdAt  DateTime @default(now())
}

model Booking {
  id         Int      @id @default(autoincrement())
  date       DateTime
  status     BookingStatus
  userId     Int
  user       User     @relation(fields: [userId], references: [id])
}

model Review {
  id         Int      @id @default(autoincrement())
  rating     Int
  text       String?
  userId     Int
  user       User     @relation(fields: [userId], references: [id])
}

model Subscription {
  id           Int      @id @default(autoincrement())
  type         SubscriptionType
  status       SubscriptionStatus
  userId       Int
  user         User     @relation(fields: [userId], references: [id])
}

enum UserRole {
  COSPLAYER
  PHOTOGRAPHER
}

enum BookingStatus {
  PENDING
  CONFIRMED
  CANCELLED
}

enum SubscriptionType {
  BASIC
  PREMIUM
}

enum SubscriptionStatus {
  ACTIVE
  INACTIVE
}

Dependencies

Time Estimate