forked from Northgate-Systems/RemitX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.prisma
More file actions
111 lines (95 loc) · 3.09 KB
/
Copy pathschema.prisma
File metadata and controls
111 lines (95 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Prisma schema for RemitX
// Database: Supabase (Postgres)
//
// NOTE: This schema targets Supabase's Postgres-compatible backend.
// - Uses cuid() for IDs (not autoincrement)
// - All monetary amounts stored as strings to avoid precision loss
// - Foreign keys are enforced by Postgres (enable them in Supabase project settings)
generator client {
provider = "prisma-client"
output = "../src/generated/prisma"
}
datasource db {
provider = "postgresql"
}
enum KycStatus {
pending
verified
rejected
}
enum TransactionStatus {
pending
validating
confirmed
failed
}
enum EscrowStatus {
locked
released
refunded
expired
}
model User {
id String @id @default(cuid())
email String @unique
firstName String
lastName String
passwordHash String
stellarPublicKey String? @unique
kycStatus KycStatus @default(pending)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
transactions Transaction[]
escrows Escrow[]
@@map("users")
}
model Transaction {
id String @id @default(cuid())
userId String
fromAsset String
toAsset String
fromAmount String // stored as string to avoid precision loss with decimals
toAmount String?
recipientAddress String
stellarTxHash String?
escrowId String? // links to Escrow.id if this transaction uses the escrow contract
status TransactionStatus @default(pending)
createdAt DateTime @default(now())
confirmedAt DateTime?
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id])
@@index([userId])
@@index([status])
@@map("transactions")
}
model Rate {
id String @id @default(cuid())
fromAsset String
toAsset String
rate String // stored as string to avoid precision loss
fetchedAt DateTime @default(now())
@@unique([fromAsset, toAsset])
@@map("rates")
}
model Escrow {
id String @id @default(cuid())
userId String
transactionId String @unique // one-to-one with Transaction
contractAddress String // Soroban contract address on Stellar
senderAddress String // Stellar public key of the sender
recipientAddress String // Stellar public key of the recipient
amount String // stored as string to avoid precision loss
asset String // asset code (e.g. "USDC", "XLM")
status EscrowStatus @default(locked)
depositTxHash String? // Stellar tx hash for the deposit to the contract
releaseTxHash String? // Stellar tx hash for the release from the contract
createdAt DateTime @default(now())
expiresAt DateTime // when the escrow expires and can be refunded
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id])
@@index([userId])
@@index([senderAddress])
@@index([recipientAddress])
@@index([status])
@@map("escrows")
}