1+
12generator client {
23 provider = " prisma-client-js "
34}
@@ -22,6 +23,9 @@ enum PetSpecies {
2223 OTHER
2324}
2425
26+
27+
28+
2529enum AdoptionStatus {
2630 REQUESTED
2731 PENDING
@@ -32,12 +36,13 @@ enum AdoptionStatus {
3236 CANCELLED
3337}
3438
39+
3540enum CustodyStatus {
36- PENDING
3741 ACTIVE
3842 RETURNED
3943 CANCELLED
4044 VIOLATION
45+ PENDING
4146}
4247
4348enum CustodyType {
@@ -46,6 +51,8 @@ enum CustodyType {
4651 SHELTER
4752}
4853
54+
55+
4956enum EscrowStatus {
5057 CREATED
5158 FUNDED
@@ -54,6 +61,7 @@ enum EscrowStatus {
5461 DISPUTED
5562}
5663
64+
5765enum EventEntityType {
5866 USER
5967 PET
@@ -62,6 +70,7 @@ enum EventEntityType {
6270 ESCROW
6371}
6472
73+
6574enum EventType {
6675 USER_REGISTERED
6776 PET_REGISTERED
@@ -76,17 +85,11 @@ enum EventType {
7685 TRUST_SCORE_UPDATED
7786}
7887
79- enum PetGender {
80- MALE
81- FEMALE
82- }
83-
84- enum PetSize {
85- SMALL
86- MEDIUM
87- LARGE
88+ enum LogLevel {
89+ INFO
90+ WARN
91+ ERROR
8892}
89-
9093// ─── Models ──────────────────────────────────────────────
9194
9295model User {
@@ -97,41 +100,41 @@ model User {
97100 lastName String @map (" last_name " )
98101 role UserRole @default (USER )
99102
100- trustScore Float @default (50 )
103+ trustScore Float @default (50 )
101104
102105 stellarPublicKey String ? @unique @map (" stellar_public_key " )
103106 avatarUrl String ? @map (" avatar_url " )
104107
105108 createdAt DateTime @default (now () ) @map (" created_at " )
106109 updatedAt DateTime @updatedAt @map (" updated_at " )
107110
108- petsOwned Pet [] @relation (" PetOwner " )
111+ petsOwned Pet [] @relation (" PetOwner " )
109112
110113 adoptionsAsAdopter Adoption [] @relation (" Adopter " )
111114 adoptionsAsOwner Adoption [] @relation (" Owner " )
112115
113116 custodiesHeld Custody [] @relation (" CustodyHolder " )
114117
115- events EventLog [] @relation (" ActorEvents " )
118+ events EventLog [] @relation (" ActorEvents " )
119+
116120 documents Document []
117121
118122 @@map (" users " )
119123}
120124
125+
126+
121127model Pet {
122- id String @id @default (uuid () )
128+ id String @id @default (uuid () )
123129 name String
124130 species PetSpecies
125131 breed String ?
126132 age Int ?
127133 description String ?
128- imageUrl String ? @map (" image_url " )
134+ imageUrl String ? @map (" image_url " )
129135
130- gender PetGender ? // Optional gender field
131- size PetSize ? // Optional size field
132-
133- currentOwnerId String ? @map (" current_owner_id " )
134- currentOwner User ? @relation (" PetOwner " , fields : [currentOwnerId ] , references : [id ] )
136+ currentOwnerId String ? @map (" current_owner_id " )
137+ currentOwner User ? @relation (" PetOwner " , fields : [currentOwnerId ] , references : [id ] )
135138
136139 createdAt DateTime @default (now () ) @map (" created_at " )
137140 updatedAt DateTime @updatedAt @map (" updated_at " )
@@ -144,6 +147,7 @@ model Pet {
144147 @@map (" pets " )
145148}
146149
150+
147151model Adoption {
148152 id String @id @default (uuid () )
149153 status AdoptionStatus @default (REQUESTED )
@@ -158,27 +162,29 @@ model Adoption {
158162 ownerId String @map (" owner_id " )
159163 owner User @relation (" Owner " , fields : [ownerId ] , references : [id ] )
160164
161- escrowId String ? @unique @map (" escrow_id " )
165+ escrowId String ? @unique @map (" escrow_id " )
162166 escrow Escrow ? @relation (fields : [escrowId ] , references : [id ] )
163-
164- createdAt DateTime @default (now () ) @map (" created_at " )
165- updatedAt DateTime @updatedAt @map (" updated_at " )
167+
166168 documents Document []
169+ createdAt DateTime @default (now () ) @map (" created_at " )
170+ updatedAt DateTime @updatedAt @map (" updated_at " )
167171
168172 @@index ([status ] )
169173 @@index ([adopterId ] )
170174 @@index ([ownerId ] )
171175 @@map (" adoptions " )
172176}
173177
178+
179+
174180model Custody {
175- id String @id @default (uuid () )
176- status CustodyStatus @default (ACTIVE )
177- type CustodyType
181+ id String @id @default (uuid () )
182+ status CustodyStatus @default (ACTIVE )
183+ type CustodyType
178184
179185 depositAmount Decimal ? @db.Decimal (12 , 2 )
180186
181- startDate DateTime @map (" start_date " )
187+ startDate DateTime @map (" start_date " )
182188 endDate DateTime ?
183189
184190 petId String @map (" pet_id " )
@@ -198,20 +204,21 @@ model Custody {
198204 @@map (" custodies " )
199205}
200206
207+
201208model Escrow {
202209 id String @id @default (uuid () )
203210
204- stellarPublicKey String @unique @map (" stellar_public_key " )
211+ stellarPublicKey String @unique @map (" stellar_public_key " )
205212 stellarSecretEncrypted String @map (" stellar_secret_encrypted " )
206213
207- assetCode String @default (" XLM " ) @map (" asset_code " )
214+ assetCode String @default (" XLM " ) @map (" asset_code " )
208215 assetIssuer String ? @map (" asset_issuer " )
209216
210217 amount Decimal @db.Decimal (12 , 2 )
211218
212- fundingTxHash String ? @map (" funding_tx_hash " )
213- releaseTxHash String ? @map (" release_tx_hash " )
214- refundTxHash String ? @map (" refund_tx_hash " )
219+ fundingTxHash String ? @map (" funding_tx_hash " )
220+ releaseTxHash String ? @map (" release_tx_hash " )
221+ refundTxHash String ? @map (" refund_tx_hash " )
215222
216223 requiredSignatures Int @default (2 )
217224
@@ -227,11 +234,23 @@ model Escrow {
227234 @@map (" escrows " )
228235}
229236
237+
238+ model AppLog {
239+ id String @id @default (uuid () )
240+ level LogLevel
241+ action String
242+ message String
243+ userId String ?
244+ metadata Json ?
245+ createdAt DateTime @default (now () )
246+ }
247+
248+
230249model EventLog {
231- id String @id @default (uuid () )
232- entityType EventEntityType @map (" entity_type " )
233- entityId String @map (" entity_id " )
234- eventType EventType @map (" event_type " )
250+ id String @id @default (uuid () )
251+ entityType EventEntityType @map (" entity_type " )
252+ entityId String @map (" entity_id " )
253+ eventType EventType @map (" event_type " )
235254
236255 actorId String ? @map (" actor_id " )
237256 actor User ? @relation (" ActorEvents " , fields : [actorId ] , references : [id ] )
@@ -251,22 +270,18 @@ model EventLog {
251270}
252271
253272model Document {
254- id String @id @default (uuid () )
255- fileName String @map (" file_name " )
256- fileUrl String @map (" file_url " )
257- publicId String @map (" public_id " )
258- mimeType String @map (" mime_type " )
259- size Int
260-
261- uploadedById String @map (" uploaded_by_id " )
262- uploadedBy User @relation (fields : [uploadedById ] , references : [id ] , onDelete : Cascade )
263-
264- adoptionId String ? @map (" adoption_id " )
265- adoption Adoption ? @relation (fields : [adoptionId ] , references : [id ] , onDelete : Cascade )
266-
267- createdAt DateTime @default (now () ) @map (" created_at " )
268-
269- @@index ([uploadedById ] )
270- @@index ([adoptionId ] )
271- @@map (" documents " )
273+ id String @id @default (cuid () )
274+ fileName String
275+ fileUrl String
276+ publicId String
277+ mimeType String
278+ size Int
279+ uploadedById String
280+ adoptionId String
281+ createdAt DateTime @default (now () )
282+ updatedAt DateTime @updatedAt
283+
284+ uploadedBy User @relation (fields : [uploadedById ] , references : [id ] )
285+ adoption Adoption @relation (fields : [adoptionId ] , references : [id ] )
272286}
287+
0 commit comments