- Install backend and frontend dependencies - Fix Prisma schema BigInt default values - Generate Prisma client - Create database setup script and documentation - Add DATABASE_SETUP.md guide
526 lines
14 KiB
Plaintext
526 lines
14 KiB
Plaintext
// Prisma schema for ASLE Backend
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Pool {
|
|
id String @id @default(uuid())
|
|
poolId BigInt @unique
|
|
baseToken String
|
|
quoteToken String
|
|
baseReserve String @default("0")
|
|
quoteReserve String @default("0")
|
|
virtualBaseReserve String @default("0")
|
|
virtualQuoteReserve String @default("0")
|
|
k String @default("0")
|
|
oraclePrice String @default("0")
|
|
active Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
transactions Transaction[]
|
|
lpPositions LPPosition[]
|
|
}
|
|
|
|
model Vault {
|
|
id String @id @default(uuid())
|
|
vaultId BigInt @unique
|
|
asset String?
|
|
isMultiAsset Boolean @default(false)
|
|
totalAssets String @default("0")
|
|
totalSupply String @default("0")
|
|
active Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
deposits Deposit[]
|
|
withdrawals Withdrawal[]
|
|
}
|
|
|
|
model Transaction {
|
|
id String @id @default(uuid())
|
|
txHash String @unique
|
|
poolId BigInt
|
|
pool Pool @relation(fields: [poolId], references: [poolId])
|
|
user String
|
|
tokenIn String
|
|
tokenOut String
|
|
amountIn String
|
|
amountOut String
|
|
timestamp DateTime @default(now())
|
|
blockNumber BigInt?
|
|
status String @default("pending")
|
|
}
|
|
|
|
model LPPosition {
|
|
id String @id @default(uuid())
|
|
poolId BigInt
|
|
pool Pool @relation(fields: [poolId], references: [poolId])
|
|
user String
|
|
lpShares String @default("0")
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([poolId, user])
|
|
}
|
|
|
|
model Deposit {
|
|
id String @id @default(uuid())
|
|
vaultId BigInt
|
|
vault Vault @relation(fields: [vaultId], references: [vaultId])
|
|
user String
|
|
assets String
|
|
shares String
|
|
txHash String @unique
|
|
timestamp DateTime @default(now())
|
|
}
|
|
|
|
model Withdrawal {
|
|
id String @id @default(uuid())
|
|
vaultId BigInt
|
|
vault Vault @relation(fields: [vaultId], references: [vaultId])
|
|
user String
|
|
assets String
|
|
shares String
|
|
txHash String @unique
|
|
timestamp DateTime @default(now())
|
|
}
|
|
|
|
model ComplianceRecord {
|
|
id String @id @default(uuid())
|
|
userAddress String
|
|
complianceMode String
|
|
kycVerified Boolean @default(false)
|
|
amlVerified Boolean @default(false)
|
|
kycProvider String?
|
|
amlProvider String?
|
|
lastKYCUpdate DateTime?
|
|
lastAMLUpdate DateTime?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([userAddress])
|
|
}
|
|
|
|
model AuditTrail {
|
|
id String @id @default(uuid())
|
|
userAddress String
|
|
action String
|
|
details Json
|
|
complianceMode String?
|
|
timestamp DateTime @default(now())
|
|
txHash String?
|
|
}
|
|
|
|
model CcipMessage {
|
|
id String @id @default(uuid())
|
|
messageId String @unique
|
|
sourceChainId BigInt
|
|
targetChainId BigInt
|
|
messageType String
|
|
payload Json
|
|
status String @default("pending")
|
|
timestamp DateTime @default(now())
|
|
deliveredAt DateTime?
|
|
error String?
|
|
|
|
@@map("ccip_messages")
|
|
}
|
|
|
|
model Proposal {
|
|
id String @id @default(uuid())
|
|
proposalId BigInt @unique
|
|
proposalType String
|
|
status String @default("pending")
|
|
proposer String
|
|
description String @db.Text
|
|
data Json
|
|
forVotes String @default("0")
|
|
againstVotes String @default("0")
|
|
startTime DateTime
|
|
endTime DateTime
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
votes Vote[]
|
|
}
|
|
|
|
model Vote {
|
|
id String @id @default(uuid())
|
|
proposalId BigInt
|
|
proposal Proposal @relation(fields: [proposalId], references: [proposalId])
|
|
voter String
|
|
support Boolean
|
|
votingPower String
|
|
timestamp DateTime @default(now())
|
|
|
|
@@unique([proposalId, voter])
|
|
}
|
|
|
|
model SystemAlert {
|
|
id String @id @default(uuid())
|
|
alertType String
|
|
severity String
|
|
message String @db.Text
|
|
metadata Json?
|
|
resolved Boolean @default(false)
|
|
resolvedAt DateTime?
|
|
createdAt DateTime @default(now())
|
|
}
|
|
|
|
model Metric {
|
|
id String @id @default(uuid())
|
|
metricType String
|
|
value String
|
|
metadata Json?
|
|
timestamp DateTime @default(now())
|
|
}
|
|
|
|
model ChainConfig {
|
|
id String @id @default(uuid())
|
|
chainId BigInt @unique
|
|
name String
|
|
nativeToken String?
|
|
explorerUrl String
|
|
gasLimit BigInt @default(3000000)
|
|
messageTimeout BigInt @default(300) // seconds
|
|
active Boolean @default(true)
|
|
ccipSelector BigInt?
|
|
rpcUrl String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@map("chain_configs")
|
|
}
|
|
|
|
model Delegation {
|
|
id String @id @default(uuid())
|
|
delegator String @unique
|
|
delegatee String
|
|
votingPower String @default("0")
|
|
timestamp DateTime @default(now())
|
|
|
|
@@map("delegations")
|
|
}
|
|
|
|
model ProposalTemplate {
|
|
id String @id @default(uuid())
|
|
name String
|
|
description String @db.Text
|
|
proposalType String
|
|
templateData Json
|
|
active Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@map("proposal_templates")
|
|
}
|
|
|
|
model SARReport {
|
|
id String @id @default(uuid())
|
|
reportId String @unique
|
|
transactionHash String
|
|
userAddress String
|
|
amount String
|
|
reason String @db.Text
|
|
status String @default("draft")
|
|
submittedAt DateTime?
|
|
jurisdiction String @default("US")
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([status])
|
|
@@index([userAddress])
|
|
@@map("sar_reports")
|
|
}
|
|
|
|
model CTRReport {
|
|
id String @id @default(uuid())
|
|
reportId String @unique
|
|
transactionHash String
|
|
userAddress String
|
|
amount String
|
|
currency String
|
|
transactionType String
|
|
status String @default("draft")
|
|
submittedAt DateTime?
|
|
jurisdiction String @default("US")
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([status])
|
|
@@index([userAddress])
|
|
@@map("ctr_reports")
|
|
}
|
|
|
|
model ScreeningResult {
|
|
id String @id @default(uuid())
|
|
address String
|
|
riskScore Float
|
|
sanctions Boolean @default(false)
|
|
passed Boolean @default(true)
|
|
providers String[]
|
|
action String
|
|
timestamp DateTime @default(now())
|
|
|
|
@@index([address])
|
|
@@index([timestamp])
|
|
@@map("screening_results")
|
|
}
|
|
|
|
model ComplianceWorkflow {
|
|
id String @id @default(uuid())
|
|
name String
|
|
description String @db.Text
|
|
steps Json
|
|
active Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
executions WorkflowExecution[]
|
|
|
|
@@map("compliance_workflows")
|
|
}
|
|
|
|
model WorkflowExecution {
|
|
id String @id @default(uuid())
|
|
workflowId String
|
|
workflow ComplianceWorkflow @relation(fields: [workflowId], references: [id])
|
|
userAddress String
|
|
currentStep Int @default(0)
|
|
status String @default("pending")
|
|
results Json @default("{}")
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([workflowId])
|
|
@@index([userAddress])
|
|
@@map("workflow_executions")
|
|
}
|
|
|
|
model Comment {
|
|
id String @id @default(uuid())
|
|
proposalId BigInt
|
|
author String
|
|
content String @db.Text
|
|
parentId String?
|
|
upvotes Int @default(0)
|
|
downvotes Int @default(0)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
votes CommentVote[]
|
|
|
|
@@index([proposalId])
|
|
@@index([parentId])
|
|
@@map("comments")
|
|
}
|
|
|
|
model CommentVote {
|
|
id String @id @default(uuid())
|
|
commentId String
|
|
comment Comment @relation(fields: [commentId], references: [id])
|
|
voter String
|
|
upvote Boolean
|
|
timestamp DateTime @default(now())
|
|
|
|
@@unique([commentId, voter])
|
|
@@map("comment_votes")
|
|
}
|
|
|
|
model DeviceToken {
|
|
id String @id @default(uuid())
|
|
userAddress String
|
|
deviceToken String
|
|
platform String
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([userAddress, deviceToken])
|
|
@@index([userAddress])
|
|
@@map("device_tokens")
|
|
}
|
|
|
|
model CrossChainMessage {
|
|
id String @id @default(uuid())
|
|
messageId String @unique
|
|
sourceChain String
|
|
targetChain String
|
|
payload Json
|
|
status String @default("pending")
|
|
timestamp DateTime @default(now())
|
|
receivedAt DateTime?
|
|
|
|
@@index([sourceChain])
|
|
@@index([targetChain])
|
|
@@index([status])
|
|
@@map("cross_chain_messages")
|
|
}
|
|
|
|
model PoolMetrics {
|
|
id String @id @default(uuid())
|
|
poolId BigInt
|
|
tvl String @default("0")
|
|
volume24h String @default("0")
|
|
volume7d String @default("0")
|
|
volume30d String @default("0")
|
|
fees24h String @default("0")
|
|
fees7d String @default("0")
|
|
fees30d String @default("0")
|
|
utilizationRate Float @default(0)
|
|
timestamp DateTime @default(now())
|
|
|
|
@@index([poolId, timestamp])
|
|
@@map("pool_metrics")
|
|
}
|
|
|
|
model UserPortfolio {
|
|
id String @id @default(uuid())
|
|
userAddress String
|
|
totalValue String @default("0")
|
|
poolPositions Json @default("{}")
|
|
vaultPositions Json @default("{}")
|
|
timestamp DateTime @default(now())
|
|
|
|
@@unique([userAddress, timestamp])
|
|
@@index([userAddress])
|
|
@@map("user_portfolios")
|
|
}
|
|
|
|
model TransactionAnalytics {
|
|
id String @id @default(uuid())
|
|
poolId BigInt?
|
|
transactionType String
|
|
volume String @default("0")
|
|
count Int @default(0)
|
|
averageSize String @default("0")
|
|
timestamp DateTime @default(now())
|
|
|
|
@@index([poolId, timestamp])
|
|
@@index([transactionType, timestamp])
|
|
@@map("transaction_analytics")
|
|
}
|
|
|
|
model AdminUser {
|
|
id String @id @default(uuid())
|
|
email String @unique
|
|
passwordHash String
|
|
role String @default("admin") // admin, super_admin, operator
|
|
permissions String[] @default([])
|
|
active Boolean @default(true)
|
|
lastLogin DateTime?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
sessions AdminSession[]
|
|
auditLogs AdminAuditLog[]
|
|
|
|
@@index([email])
|
|
@@index([role])
|
|
@@map("admin_users")
|
|
}
|
|
|
|
model AdminSession {
|
|
id String @id @default(uuid())
|
|
adminUserId String
|
|
adminUser AdminUser @relation(fields: [adminUserId], references: [id], onDelete: Cascade)
|
|
token String @unique
|
|
ipAddress String?
|
|
userAgent String?
|
|
expiresAt DateTime
|
|
createdAt DateTime @default(now())
|
|
|
|
@@index([adminUserId])
|
|
@@index([token])
|
|
@@map("admin_sessions")
|
|
}
|
|
|
|
model AdminAuditLog {
|
|
id String @id @default(uuid())
|
|
adminUserId String
|
|
adminUser AdminUser @relation(fields: [adminUserId], references: [id])
|
|
action String
|
|
resource String?
|
|
resourceId String?
|
|
details Json?
|
|
ipAddress String?
|
|
timestamp DateTime @default(now())
|
|
|
|
@@index([adminUserId])
|
|
@@index([action])
|
|
@@index([timestamp])
|
|
@@map("admin_audit_logs")
|
|
}
|
|
|
|
model SystemConfig {
|
|
id String @id @default(uuid())
|
|
key String @unique
|
|
value Json
|
|
description String?
|
|
category String @default("general")
|
|
updatedBy String?
|
|
updatedAt DateTime @updatedAt
|
|
createdAt DateTime @default(now())
|
|
|
|
@@index([key])
|
|
@@index([category])
|
|
@@map("system_configs")
|
|
}
|
|
|
|
model Deployment {
|
|
id String @id @default(uuid())
|
|
name String
|
|
environment String // staging, production
|
|
version String
|
|
status String @default("pending") // pending, deploying, success, failed
|
|
config Json
|
|
deployedBy String?
|
|
deployedAt DateTime?
|
|
rollbackVersion String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
logs DeploymentLog[]
|
|
|
|
@@index([environment])
|
|
@@index([status])
|
|
@@map("deployments")
|
|
}
|
|
|
|
model DeploymentLog {
|
|
id String @id @default(uuid())
|
|
deploymentId String
|
|
deployment Deployment @relation(fields: [deploymentId], references: [id], onDelete: Cascade)
|
|
level String // info, warning, error
|
|
message String @db.Text
|
|
metadata Json?
|
|
timestamp DateTime @default(now())
|
|
|
|
@@index([deploymentId])
|
|
@@index([timestamp])
|
|
@@map("deployment_logs")
|
|
}
|
|
|
|
model WhiteLabelConfig {
|
|
id String @id @default(uuid())
|
|
name String @unique
|
|
domain String @unique
|
|
logoUrl String?
|
|
primaryColor String?
|
|
secondaryColor String?
|
|
theme Json @default("{}")
|
|
features String[] @default([])
|
|
active Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@index([domain])
|
|
@@map("white_label_configs")
|
|
}
|
|
|