Migrate teams backend from Django to Express + Apollo Server + Prisma
All checks were successful
Build Docker Image / build (push) Successful in 2m8s
All checks were successful
Build Docker Image / build (push) Successful in 2m8s
Replace Django/Graphene stack with TypeScript Express server using Apollo Server v4 with 4 GraphQL endpoints (public/user/team/m2m) and Prisma ORM mapped to existing tables.
This commit is contained in:
132
prisma/schema.prisma
Normal file
132
prisma/schema.prisma
Normal file
@@ -0,0 +1,132 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("TEAMS_DATABASE_URL")
|
||||
}
|
||||
|
||||
model Team {
|
||||
id Int @id @default(autoincrement())
|
||||
uuid String @unique @default(uuid())
|
||||
name String @db.VarChar(200)
|
||||
teamType String @default("BUYER") @map("team_type") @db.VarChar(20)
|
||||
logtoOrgId String? @map("logto_org_id") @db.VarChar(100)
|
||||
ownerId Int? @map("owner_id")
|
||||
owner User? @relation(fields: [ownerId], references: [id])
|
||||
selectedLocationType String? @map("selected_location_type") @db.VarChar(20)
|
||||
selectedLocationUuid String? @map("selected_location_uuid") @db.VarChar(100)
|
||||
selectedLocationName String? @map("selected_location_name") @db.VarChar(255)
|
||||
selectedLocationLat Float? @map("selected_location_lat")
|
||||
selectedLocationLon Float? @map("selected_location_lon")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
members TeamMember[]
|
||||
invitations TeamInvitation[]
|
||||
addresses TeamAddress[]
|
||||
profiles UserProfile[] @relation("ActiveTeam")
|
||||
|
||||
@@map("teams_app_team")
|
||||
}
|
||||
|
||||
model User {
|
||||
id Int @id @default(autoincrement())
|
||||
password String @default("") @db.VarChar(128)
|
||||
username String @unique @db.VarChar(150)
|
||||
firstName String @default("") @map("first_name") @db.VarChar(150)
|
||||
lastName String @default("") @map("last_name") @db.VarChar(150)
|
||||
email String @default("") @db.VarChar(254)
|
||||
isActive Boolean @default(true) @map("is_active")
|
||||
dateJoined DateTime @default(now()) @map("date_joined")
|
||||
isSuperuser Boolean @default(false) @map("is_superuser")
|
||||
isStaff Boolean @default(false) @map("is_staff")
|
||||
lastLogin DateTime? @map("last_login")
|
||||
|
||||
profile UserProfile?
|
||||
teams Team[]
|
||||
memberships TeamMember[]
|
||||
|
||||
@@map("auth_user")
|
||||
}
|
||||
|
||||
model UserProfile {
|
||||
id Int @id @default(autoincrement())
|
||||
userId Int @unique @map("user_id")
|
||||
user User @relation(fields: [userId], references: [id])
|
||||
logtoId String @unique @map("logto_id") @db.VarChar(255)
|
||||
avatarId String? @map("avatar_id") @db.VarChar(255)
|
||||
phone String @default("") @db.VarChar(50)
|
||||
activeTeamId Int? @map("active_team_id")
|
||||
activeTeam Team? @relation("ActiveTeam", fields: [activeTeamId], references: [id])
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
@@map("teams_app_userprofile")
|
||||
}
|
||||
|
||||
model TeamMember {
|
||||
id Int @id @default(autoincrement())
|
||||
uuid String @unique @default(uuid())
|
||||
teamId Int @map("team_id")
|
||||
team Team @relation(fields: [teamId], references: [id])
|
||||
userId Int? @map("user_id")
|
||||
user User? @relation(fields: [userId], references: [id])
|
||||
role String @default("MEMBER") @db.VarChar(20)
|
||||
joinedAt DateTime @default(now()) @map("joined_at")
|
||||
|
||||
@@unique([teamId, userId])
|
||||
@@map("teams_app_teammember")
|
||||
}
|
||||
|
||||
model TeamInvitation {
|
||||
id Int @id @default(autoincrement())
|
||||
uuid String @unique @default(uuid())
|
||||
teamId Int @map("team_id")
|
||||
team Team @relation(fields: [teamId], references: [id])
|
||||
email String @db.VarChar(254)
|
||||
role String @default("MEMBER") @db.VarChar(20)
|
||||
status String @default("PENDING") @db.VarChar(20)
|
||||
invitedBy String @default("") @map("invited_by") @db.VarChar(255)
|
||||
expiresAt DateTime? @map("expires_at")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
tokens TeamInvitationToken[]
|
||||
|
||||
@@unique([teamId, email])
|
||||
@@map("teams_app_teaminvitation")
|
||||
}
|
||||
|
||||
model TeamInvitationToken {
|
||||
id Int @id @default(autoincrement())
|
||||
uuid String @unique @default(uuid())
|
||||
invitationId Int @map("invitation_id")
|
||||
invitation TeamInvitation @relation(fields: [invitationId], references: [id])
|
||||
tokenHash String @unique @map("token_hash") @db.VarChar(255)
|
||||
workflowStatus String @default("pending") @map("workflow_status") @db.VarChar(20)
|
||||
expiresAt DateTime? @map("expires_at")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
@@map("teams_app_teaminvitationtoken")
|
||||
}
|
||||
|
||||
model TeamAddress {
|
||||
id Int @id @default(autoincrement())
|
||||
uuid String @unique @default(uuid())
|
||||
teamId Int @map("team_id")
|
||||
team Team @relation(fields: [teamId], references: [id])
|
||||
name String @db.VarChar(255)
|
||||
address String
|
||||
latitude Float?
|
||||
longitude Float?
|
||||
countryCode String @default("") @map("country_code") @db.VarChar(10)
|
||||
isDefault Boolean @default(false) @map("is_default")
|
||||
status String @default("pending") @db.VarChar(20)
|
||||
processedAt DateTime? @map("processed_at")
|
||||
errorMessage String? @map("error_message")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
@@map("teams_app_teamaddress")
|
||||
}
|
||||
Reference in New Issue
Block a user