@cowris/paymentdb-client 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,6 +1,16 @@
1
1
  const { PrismaClient } = require('./prisma/generated/paymentdb');
2
2
 
3
+ import { PrismaPg } from "@prisma/adapter-pg";
4
+ import pg from "pg";
5
+
6
+ const pool = new pg.Pool({
7
+ connectionString: process.env.DATABASE_URL,
8
+ });
9
+
10
+ const adapter = new PrismaPg(pool);
11
+
3
12
  const prisma = new PrismaClient({
13
+ adapter,
4
14
  log: ['error', 'query', 'info', 'warn'],
5
15
  });
6
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowris/paymentdb-client",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "This is a Prisma Client package for the Cowris PaymentDB. It provides a simple interface to interact with the Payment database, allowing you to perform CRUD operations on payment and transaction data and related tables.",
5
5
  "main": "index.js",
6
6
  "private": false,
@@ -9,6 +9,7 @@ model PaymentAccount {
9
9
  wallet_webhook_url String?
10
10
  managed_wallets ManagedWallet[]
11
11
  transactions Transaction[]
12
+ withdrawal_accounts WithdrawalAccount[]
12
13
 
13
14
  @@index([wallet_id], name: "wallet_id_index")
14
15
  @@index([account_number], name: "wallet_account_number")
@@ -15,7 +15,7 @@ model Funding {
15
15
  account_id String
16
16
  managed_wallet_id String?
17
17
  status String
18
- amount Int
18
+ amount BigInt
19
19
  source_currency_id String?
20
20
  destination_currency_id String
21
21
  sender_account_information_id String? @unique
@@ -3,7 +3,7 @@ model Hold {
3
3
 
4
4
  account_id String
5
5
  managed_wallet_id String?
6
- amount Int // kobo
6
+ amount BigInt // kobo
7
7
  currency_id String
8
8
 
9
9
  reference String @unique
@@ -21,6 +21,7 @@ model Hold {
21
21
  updated_at DateTime @updatedAt
22
22
 
23
23
  @@index([account_id])
24
+ @@index([managed_wallet_id])
24
25
  @@index([status])
25
26
  @@index([expires_at])
26
27
  }
@@ -7,8 +7,8 @@ model ManagedWallet {
7
7
  wallet_customer_phone String?
8
8
  account_number String?
9
9
  email String?
10
- total_balance Int @default(0) // based on currency's smallest unit
11
- available_balance Int @default(0) // based on currency's smallest unit
10
+ total_balance BigInt @default(0) // based on currency's smallest unit
11
+ available_balance BigInt @default(0) // based on currency's smallest unit
12
12
  currency_id String
13
13
  global_payment_provider_id String
14
14
  type String
@@ -0,0 +1,395 @@
1
+ -- CreateEnum
2
+ CREATE TYPE "HoldStatus" AS ENUM ('ACTIVE', 'CONSUMED', 'RELEASED', 'EXPIRED');
3
+
4
+ -- CreateEnum
5
+ CREATE TYPE "HoldReason" AS ENUM ('TRANSFER', 'WITHDRAWAL', 'REVERSAL');
6
+
7
+ -- CreateEnum
8
+ CREATE TYPE "PaymentIntentStatus" AS ENUM ('PENDING', 'SUCCEEDED', 'FAILED', 'CANCELLED');
9
+
10
+ -- CreateEnum
11
+ CREATE TYPE "EventType" AS ENUM ('FUNDING_SUCCESS', 'FUNDING_FAILED', 'WITHDRAWAL_SUCCESS', 'WITHDRAWAL_FAILED', 'REVERSAL_SUCCESS', 'REVERSAL_FAILED', 'TRANSFER_SUCCESS', 'TRANSFER_FAILED');
12
+
13
+ -- CreateTable
14
+ CREATE TABLE "PaymentAccount" (
15
+ "id" TEXT NOT NULL,
16
+ "account_number" TEXT,
17
+ "email" TEXT,
18
+ "currency_id" TEXT NOT NULL,
19
+ "wallet_id" TEXT NOT NULL,
20
+ "wallet_queue_url" TEXT,
21
+ "wallet_webhook_url" TEXT,
22
+
23
+ CONSTRAINT "PaymentAccount_pkey" PRIMARY KEY ("id")
24
+ );
25
+
26
+ -- CreateTable
27
+ CREATE TABLE "Currency" (
28
+ "id" TEXT NOT NULL,
29
+ "name" TEXT NOT NULL,
30
+ "code" TEXT NOT NULL,
31
+ "symbol" TEXT NOT NULL,
32
+ "country" TEXT NOT NULL,
33
+ "minor_unit" TEXT NOT NULL,
34
+ "minor_unit_factor" INTEGER NOT NULL,
35
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
36
+ "updated_at" TIMESTAMP(3) NOT NULL,
37
+
38
+ CONSTRAINT "Currency_pkey" PRIMARY KEY ("id")
39
+ );
40
+
41
+ -- CreateTable
42
+ CREATE TABLE "SenderAccountInformation" (
43
+ "id" TEXT NOT NULL,
44
+ "account_firstname" TEXT DEFAULT '',
45
+ "account_lastname" TEXT DEFAULT '',
46
+ "account_number" TEXT,
47
+ "account_email" TEXT,
48
+ "account_bank_name" TEXT,
49
+
50
+ CONSTRAINT "SenderAccountInformation_pkey" PRIMARY KEY ("id")
51
+ );
52
+
53
+ -- CreateTable
54
+ CREATE TABLE "Funding" (
55
+ "id" TEXT NOT NULL,
56
+ "transaction_id" TEXT NOT NULL,
57
+ "account_id" TEXT NOT NULL,
58
+ "managed_wallet_id" TEXT,
59
+ "status" TEXT NOT NULL,
60
+ "amount" BIGINT NOT NULL,
61
+ "source_currency_id" TEXT,
62
+ "destination_currency_id" TEXT NOT NULL,
63
+ "sender_account_information_id" TEXT,
64
+
65
+ CONSTRAINT "Funding_pkey" PRIMARY KEY ("id")
66
+ );
67
+
68
+ -- CreateTable
69
+ CREATE TABLE "GlobalPaymentProvider" (
70
+ "id" TEXT NOT NULL,
71
+ "name" TEXT NOT NULL,
72
+ "idx" SERIAL NOT NULL,
73
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
74
+ "updated_at" TIMESTAMP(3) NOT NULL,
75
+
76
+ CONSTRAINT "GlobalPaymentProvider_pkey" PRIMARY KEY ("id")
77
+ );
78
+
79
+ -- CreateTable
80
+ CREATE TABLE "Hold" (
81
+ "id" TEXT NOT NULL,
82
+ "account_id" TEXT NOT NULL,
83
+ "managed_wallet_id" TEXT,
84
+ "amount" BIGINT NOT NULL,
85
+ "currency_id" TEXT NOT NULL,
86
+ "reference" TEXT NOT NULL,
87
+ "reason" "HoldReason" NOT NULL,
88
+ "status" "HoldStatus" NOT NULL,
89
+ "expires_at" TIMESTAMP(3) NOT NULL,
90
+ "transfer_id" TEXT,
91
+ "payment_intent_id" TEXT,
92
+ "webhookEventId" TEXT,
93
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
94
+ "updated_at" TIMESTAMP(3) NOT NULL,
95
+
96
+ CONSTRAINT "Hold_pkey" PRIMARY KEY ("id")
97
+ );
98
+
99
+ -- CreateTable
100
+ CREATE TABLE "ManagedWallet" (
101
+ "id" TEXT NOT NULL,
102
+ "account_id" TEXT NOT NULL,
103
+ "customer_name" TEXT,
104
+ "wallet_identifier" TEXT,
105
+ "wallet_customer_email" TEXT,
106
+ "wallet_customer_phone" TEXT,
107
+ "account_number" TEXT,
108
+ "email" TEXT,
109
+ "total_balance" BIGINT NOT NULL DEFAULT 0,
110
+ "available_balance" BIGINT NOT NULL DEFAULT 0,
111
+ "currency_id" TEXT NOT NULL,
112
+ "global_payment_provider_id" TEXT NOT NULL,
113
+ "type" TEXT NOT NULL,
114
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
115
+ "updated_at" TIMESTAMP(3) NOT NULL,
116
+
117
+ CONSTRAINT "ManagedWallet_pkey" PRIMARY KEY ("id")
118
+ );
119
+
120
+ -- CreateTable
121
+ CREATE TABLE "Otp" (
122
+ "id" TEXT NOT NULL,
123
+ "email" TEXT NOT NULL,
124
+ "otp" TEXT NOT NULL,
125
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
126
+ "updated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
127
+ "expires_at" TIMESTAMP(3) NOT NULL,
128
+
129
+ CONSTRAINT "Otp_pkey" PRIMARY KEY ("id")
130
+ );
131
+
132
+ -- CreateTable
133
+ CREATE TABLE "PaymentIntent" (
134
+ "id" TEXT NOT NULL,
135
+ "reference" TEXT NOT NULL,
136
+ "account_id" TEXT NOT NULL,
137
+ "managed_wallet_id" TEXT,
138
+ "amount" BIGINT NOT NULL,
139
+ "currency_id" TEXT NOT NULL,
140
+ "global_payment_provider_id" TEXT NOT NULL,
141
+ "provider_intent_id" TEXT,
142
+ "status" "PaymentIntentStatus" NOT NULL,
143
+ "metadata" JSONB,
144
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
145
+ "updated_at" TIMESTAMP(3) NOT NULL,
146
+
147
+ CONSTRAINT "PaymentIntent_pkey" PRIMARY KEY ("id")
148
+ );
149
+
150
+ -- CreateTable
151
+ CREATE TABLE "Reversal" (
152
+ "id" TEXT NOT NULL,
153
+ "transaction_id" TEXT NOT NULL,
154
+ "account_id" TEXT NOT NULL,
155
+ "source_currency_id" TEXT,
156
+ "destination_currency_id" TEXT NOT NULL,
157
+ "amount" BIGINT NOT NULL,
158
+ "status" TEXT NOT NULL,
159
+
160
+ CONSTRAINT "Reversal_pkey" PRIMARY KEY ("id")
161
+ );
162
+
163
+ -- CreateTable
164
+ CREATE TABLE "Transaction" (
165
+ "id" TEXT NOT NULL,
166
+ "account_id" TEXT NOT NULL,
167
+ "funding_id" TEXT,
168
+ "withdrawal_id" TEXT,
169
+ "reversal_id" TEXT,
170
+ "transfer_id" TEXT,
171
+ "type" TEXT NOT NULL,
172
+ "status" TEXT NOT NULL,
173
+ "metadata" JSONB,
174
+ "provider_id" TEXT,
175
+ "reference_id" TEXT NOT NULL,
176
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
177
+ "upadated_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
178
+
179
+ CONSTRAINT "Transaction_pkey" PRIMARY KEY ("id")
180
+ );
181
+
182
+ -- CreateTable
183
+ CREATE TABLE "TransferDestinationAccountDetails" (
184
+ "id" TEXT NOT NULL,
185
+ "account_firstname" TEXT NOT NULL DEFAULT '',
186
+ "account_lastname" TEXT NOT NULL DEFAULT '',
187
+ "account_number" TEXT,
188
+ "account_email" TEXT,
189
+ "account_bank_name" TEXT,
190
+
191
+ CONSTRAINT "TransferDestinationAccountDetails_pkey" PRIMARY KEY ("id")
192
+ );
193
+
194
+ -- CreateTable
195
+ CREATE TABLE "Transfer" (
196
+ "id" TEXT NOT NULL,
197
+ "transaction_id" TEXT NOT NULL,
198
+ "from_account_id" TEXT NOT NULL,
199
+ "to_account_id" TEXT,
200
+ "destination_account_details_id" TEXT,
201
+ "source_currency_id" TEXT NOT NULL,
202
+ "destination_currency_id" TEXT NOT NULL,
203
+ "amount_in_source_currency" BIGINT NOT NULL,
204
+ "amount_in_destination_currency" BIGINT NOT NULL,
205
+ "status" TEXT NOT NULL,
206
+
207
+ CONSTRAINT "Transfer_pkey" PRIMARY KEY ("id")
208
+ );
209
+
210
+ -- CreateTable
211
+ CREATE TABLE "WebhookEvent" (
212
+ "id" TEXT NOT NULL,
213
+ "provider_id" TEXT NOT NULL,
214
+ "event_type" "EventType" NOT NULL,
215
+ "reference" TEXT NOT NULL,
216
+ "provider_event_id" TEXT,
217
+ "payload" JSONB NOT NULL,
218
+ "verified" BOOLEAN NOT NULL DEFAULT false,
219
+ "processed" BOOLEAN NOT NULL DEFAULT false,
220
+ "received_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
221
+ "processed_at" TIMESTAMP(3),
222
+ "payment_intent_id" TEXT,
223
+
224
+ CONSTRAINT "WebhookEvent_pkey" PRIMARY KEY ("id")
225
+ );
226
+
227
+ -- CreateTable
228
+ CREATE TABLE "WithdrawalDestinationAccountDetails" (
229
+ "id" TEXT NOT NULL,
230
+ "account_firstname" TEXT NOT NULL DEFAULT '',
231
+ "account_lastname" TEXT NOT NULL DEFAULT '',
232
+ "account_number" TEXT,
233
+ "account_email" TEXT,
234
+ "account_bank_name" TEXT,
235
+
236
+ CONSTRAINT "WithdrawalDestinationAccountDetails_pkey" PRIMARY KEY ("id")
237
+ );
238
+
239
+ -- CreateTable
240
+ CREATE TABLE "Withdrawal" (
241
+ "id" TEXT NOT NULL,
242
+ "transaction_id" TEXT NOT NULL,
243
+ "from_account_id" TEXT NOT NULL,
244
+ "amount_in_source_currency" BIGINT NOT NULL,
245
+ "status" TEXT NOT NULL,
246
+ "destination_account_details_id" TEXT,
247
+ "source_currency_id" TEXT NOT NULL,
248
+ "destination_currency_id" TEXT NOT NULL,
249
+ "amount_in_destination_currency" BIGINT NOT NULL,
250
+
251
+ CONSTRAINT "Withdrawal_pkey" PRIMARY KEY ("id")
252
+ );
253
+
254
+ -- CreateTable
255
+ CREATE TABLE "_CurrencyToGlobalPaymentProvider" (
256
+ "A" TEXT NOT NULL,
257
+ "B" TEXT NOT NULL,
258
+
259
+ CONSTRAINT "_CurrencyToGlobalPaymentProvider_AB_pkey" PRIMARY KEY ("A","B")
260
+ );
261
+
262
+ -- CreateIndex
263
+ CREATE UNIQUE INDEX "PaymentAccount_account_number_key" ON "PaymentAccount"("account_number");
264
+
265
+ -- CreateIndex
266
+ CREATE UNIQUE INDEX "PaymentAccount_wallet_id_key" ON "PaymentAccount"("wallet_id");
267
+
268
+ -- CreateIndex
269
+ CREATE INDEX "wallet_id_index" ON "PaymentAccount"("wallet_id");
270
+
271
+ -- CreateIndex
272
+ CREATE INDEX "wallet_account_number" ON "PaymentAccount"("account_number");
273
+
274
+ -- CreateIndex
275
+ CREATE UNIQUE INDEX "Currency_code_key" ON "Currency"("code");
276
+
277
+ -- CreateIndex
278
+ CREATE UNIQUE INDEX "Funding_transaction_id_key" ON "Funding"("transaction_id");
279
+
280
+ -- CreateIndex
281
+ CREATE UNIQUE INDEX "Funding_sender_account_information_id_key" ON "Funding"("sender_account_information_id");
282
+
283
+ -- CreateIndex
284
+ CREATE UNIQUE INDEX "Hold_reference_key" ON "Hold"("reference");
285
+
286
+ -- CreateIndex
287
+ CREATE INDEX "Hold_account_id_idx" ON "Hold"("account_id");
288
+
289
+ -- CreateIndex
290
+ CREATE INDEX "Hold_status_idx" ON "Hold"("status");
291
+
292
+ -- CreateIndex
293
+ CREATE INDEX "Hold_expires_at_idx" ON "Hold"("expires_at");
294
+
295
+ -- CreateIndex
296
+ CREATE INDEX "otp_email_index" ON "Otp"("email");
297
+
298
+ -- CreateIndex
299
+ CREATE INDEX "otp_str_index" ON "Otp"("otp");
300
+
301
+ -- CreateIndex
302
+ CREATE UNIQUE INDEX "PaymentIntent_reference_key" ON "PaymentIntent"("reference");
303
+
304
+ -- CreateIndex
305
+ CREATE INDEX "PaymentIntent_account_id_idx" ON "PaymentIntent"("account_id");
306
+
307
+ -- CreateIndex
308
+ CREATE INDEX "PaymentIntent_reference_idx" ON "PaymentIntent"("reference");
309
+
310
+ -- CreateIndex
311
+ CREATE UNIQUE INDEX "Reversal_transaction_id_key" ON "Reversal"("transaction_id");
312
+
313
+ -- CreateIndex
314
+ CREATE UNIQUE INDEX "Transaction_id_key" ON "Transaction"("id");
315
+
316
+ -- CreateIndex
317
+ CREATE UNIQUE INDEX "Transaction_funding_id_key" ON "Transaction"("funding_id");
318
+
319
+ -- CreateIndex
320
+ CREATE UNIQUE INDEX "Transaction_withdrawal_id_key" ON "Transaction"("withdrawal_id");
321
+
322
+ -- CreateIndex
323
+ CREATE UNIQUE INDEX "Transaction_reversal_id_key" ON "Transaction"("reversal_id");
324
+
325
+ -- CreateIndex
326
+ CREATE UNIQUE INDEX "Transaction_transfer_id_key" ON "Transaction"("transfer_id");
327
+
328
+ -- CreateIndex
329
+ CREATE UNIQUE INDEX "Transaction_reference_id_key" ON "Transaction"("reference_id");
330
+
331
+ -- CreateIndex
332
+ CREATE UNIQUE INDEX "Transfer_transaction_id_key" ON "Transfer"("transaction_id");
333
+
334
+ -- CreateIndex
335
+ CREATE UNIQUE INDEX "Transfer_destination_account_details_id_key" ON "Transfer"("destination_account_details_id");
336
+
337
+ -- CreateIndex
338
+ CREATE UNIQUE INDEX "WebhookEvent_reference_key" ON "WebhookEvent"("reference");
339
+
340
+ -- CreateIndex
341
+ CREATE INDEX "WebhookEvent_reference_idx" ON "WebhookEvent"("reference");
342
+
343
+ -- CreateIndex
344
+ CREATE INDEX "WebhookEvent_processed_idx" ON "WebhookEvent"("processed");
345
+
346
+ -- CreateIndex
347
+ CREATE UNIQUE INDEX "Withdrawal_transaction_id_key" ON "Withdrawal"("transaction_id");
348
+
349
+ -- CreateIndex
350
+ CREATE UNIQUE INDEX "Withdrawal_destination_account_details_id_key" ON "Withdrawal"("destination_account_details_id");
351
+
352
+ -- CreateIndex
353
+ CREATE INDEX "_CurrencyToGlobalPaymentProvider_B_index" ON "_CurrencyToGlobalPaymentProvider"("B");
354
+
355
+ -- AddForeignKey
356
+ ALTER TABLE "PaymentAccount" ADD CONSTRAINT "PaymentAccount_currency_id_fkey" FOREIGN KEY ("currency_id") REFERENCES "Currency"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
357
+
358
+ -- AddForeignKey
359
+ ALTER TABLE "Funding" ADD CONSTRAINT "Funding_sender_account_information_id_fkey" FOREIGN KEY ("sender_account_information_id") REFERENCES "SenderAccountInformation"("id") ON DELETE SET NULL ON UPDATE CASCADE;
360
+
361
+ -- AddForeignKey
362
+ ALTER TABLE "ManagedWallet" ADD CONSTRAINT "ManagedWallet_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "PaymentAccount"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
363
+
364
+ -- AddForeignKey
365
+ ALTER TABLE "Transaction" ADD CONSTRAINT "Transaction_provider_id_fkey" FOREIGN KEY ("provider_id") REFERENCES "GlobalPaymentProvider"("id") ON DELETE SET NULL ON UPDATE CASCADE;
366
+
367
+ -- AddForeignKey
368
+ ALTER TABLE "Transaction" ADD CONSTRAINT "Transaction_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "PaymentAccount"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
369
+
370
+ -- AddForeignKey
371
+ ALTER TABLE "Transaction" ADD CONSTRAINT "Transaction_transfer_id_fkey" FOREIGN KEY ("transfer_id") REFERENCES "Transfer"("id") ON DELETE SET NULL ON UPDATE CASCADE;
372
+
373
+ -- AddForeignKey
374
+ ALTER TABLE "Transaction" ADD CONSTRAINT "Transaction_funding_id_fkey" FOREIGN KEY ("funding_id") REFERENCES "Funding"("id") ON DELETE SET NULL ON UPDATE CASCADE;
375
+
376
+ -- AddForeignKey
377
+ ALTER TABLE "Transaction" ADD CONSTRAINT "Transaction_withdrawal_id_fkey" FOREIGN KEY ("withdrawal_id") REFERENCES "Withdrawal"("id") ON DELETE SET NULL ON UPDATE CASCADE;
378
+
379
+ -- AddForeignKey
380
+ ALTER TABLE "Transaction" ADD CONSTRAINT "Transaction_reversal_id_fkey" FOREIGN KEY ("reversal_id") REFERENCES "Reversal"("id") ON DELETE SET NULL ON UPDATE CASCADE;
381
+
382
+ -- AddForeignKey
383
+ ALTER TABLE "Transfer" ADD CONSTRAINT "Transfer_destination_account_details_id_fkey" FOREIGN KEY ("destination_account_details_id") REFERENCES "TransferDestinationAccountDetails"("id") ON DELETE SET NULL ON UPDATE CASCADE;
384
+
385
+ -- AddForeignKey
386
+ ALTER TABLE "WebhookEvent" ADD CONSTRAINT "WebhookEvent_payment_intent_id_fkey" FOREIGN KEY ("payment_intent_id") REFERENCES "PaymentIntent"("id") ON DELETE SET NULL ON UPDATE CASCADE;
387
+
388
+ -- AddForeignKey
389
+ ALTER TABLE "Withdrawal" ADD CONSTRAINT "Withdrawal_destination_account_details_id_fkey" FOREIGN KEY ("destination_account_details_id") REFERENCES "WithdrawalDestinationAccountDetails"("id") ON DELETE SET NULL ON UPDATE CASCADE;
390
+
391
+ -- AddForeignKey
392
+ ALTER TABLE "_CurrencyToGlobalPaymentProvider" ADD CONSTRAINT "_CurrencyToGlobalPaymentProvider_A_fkey" FOREIGN KEY ("A") REFERENCES "Currency"("id") ON DELETE CASCADE ON UPDATE CASCADE;
393
+
394
+ -- AddForeignKey
395
+ ALTER TABLE "_CurrencyToGlobalPaymentProvider" ADD CONSTRAINT "_CurrencyToGlobalPaymentProvider_B_fkey" FOREIGN KEY ("B") REFERENCES "GlobalPaymentProvider"("id") ON DELETE CASCADE ON UPDATE CASCADE;
@@ -0,0 +1,28 @@
1
+ -- CreateTable
2
+ CREATE TABLE "WithdrawalAccount" (
3
+ "id" TEXT NOT NULL,
4
+ "account_number" TEXT,
5
+ "account_bank_code" TEXT,
6
+ "account_bank_name" TEXT,
7
+ "account_firstname" TEXT NOT NULL,
8
+ "account_lastname" TEXT,
9
+ "account_email" TEXT,
10
+ "currency_id" TEXT NOT NULL,
11
+ "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
12
+ "updated_at" TIMESTAMP(3) NOT NULL,
13
+ "account_id" TEXT NOT NULL,
14
+
15
+ CONSTRAINT "WithdrawalAccount_pkey" PRIMARY KEY ("id")
16
+ );
17
+
18
+ -- CreateIndex
19
+ CREATE INDEX "withdrawal_account_currency_index" ON "WithdrawalAccount"("currency_id");
20
+
21
+ -- CreateIndex
22
+ CREATE UNIQUE INDEX "WithdrawalAccount_account_number_account_bank_code_currency_key" ON "WithdrawalAccount"("account_number", "account_bank_code", "currency_id");
23
+
24
+ -- CreateIndex
25
+ CREATE INDEX "Hold_managed_wallet_id_idx" ON "Hold"("managed_wallet_id");
26
+
27
+ -- AddForeignKey
28
+ ALTER TABLE "WithdrawalAccount" ADD CONSTRAINT "WithdrawalAccount_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "PaymentAccount"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
@@ -3,7 +3,7 @@ model PaymentIntent {
3
3
  reference String @unique
4
4
  account_id String
5
5
  managed_wallet_id String?
6
- amount Int // amount in kobo
6
+ amount BigInt // amount in kobo
7
7
  currency_id String // NGN, USD, etc
8
8
  global_payment_provider_id String
9
9
  provider_intent_id String?
@@ -5,7 +5,7 @@ model Reversal {
5
5
  source_currency_id String?
6
6
  destination_currency_id String
7
7
 
8
- amount String
8
+ amount BigInt
9
9
  status String
10
10
 
11
11
  transaction Transaction?
@@ -16,8 +16,8 @@ model Transfer {
16
16
  destination_account_details_id String? @unique
17
17
  source_currency_id String
18
18
  destination_currency_id String
19
- amount_in_source_currency String
20
- amount_in_destination_currency String
19
+ amount_in_source_currency BigInt
20
+ amount_in_destination_currency BigInt
21
21
  status String
22
22
 
23
23
  transaction Transaction?
@@ -11,14 +11,14 @@ model WithdrawalDestinationAccountDetails {
11
11
  model Withdrawal {
12
12
  id String @id @default(uuid())
13
13
  transaction_id String @unique
14
- from_account_id String
15
- amount_in_source_currency String
14
+ from_account_id String
15
+ amount_in_source_currency BigInt
16
16
  status String
17
17
 
18
18
  destination_account_details_id String? @unique
19
- source_currency_id String
20
- destination_currency_id String
21
- amount_in_destination_currency String
19
+ source_currency_id String
20
+ destination_currency_id String
21
+ amount_in_destination_currency BigInt
22
22
 
23
23
  transaction Transaction?
24
24
  destination_account_details WithdrawalDestinationAccountDetails? @relation(fields: [destination_account_details_id], references: [id])
@@ -0,0 +1,18 @@
1
+ model WithdrawalAccount {
2
+ id String @id @default(uuid())
3
+ account_number String?
4
+ account_bank_code String?
5
+ account_bank_name String?
6
+ account_firstname String
7
+ account_lastname String?
8
+ account_email String?
9
+ currency_id String
10
+ created_at DateTime @default(now())
11
+ updated_at DateTime @updatedAt
12
+
13
+ account_id String
14
+ account PaymentAccount @relation(fields: [account_id], references: [id])
15
+
16
+ @@unique([account_number, account_bank_code, currency_id], name: "unique_withdrawal_account")
17
+ @@index([currency_id], name: "withdrawal_account_currency_index")
18
+ }