@@ -177,6 +177,35 @@ export const paymentDetailsPayersTable = createTable("payment_details_payers", {
177
177
createdAt : timestamp ( "created_at" ) . defaultNow ( ) ,
178
178
} ) ;
179
179
180
+ export const clientPaymentTable = createTable ( "client_payment" , {
181
+ id : text ( ) . primaryKey ( ) . notNull ( ) ,
182
+ userId : text ( )
183
+ . notNull ( )
184
+ . references ( ( ) => userTable . id , {
185
+ onDelete : "cascade" ,
186
+ } ) ,
187
+ requestId : text ( ) . notNull ( ) ,
188
+ invoiceCurrency : text ( ) . notNull ( ) ,
189
+ paymentCurrency : text ( ) . notNull ( ) ,
190
+ amount : text ( ) . notNull ( ) ,
191
+ customerInfo : json ( ) . $type < {
192
+ firstName ?: string ;
193
+ lastName ?: string ;
194
+ email ?: string ;
195
+ address ?: {
196
+ street ?: string ;
197
+ city ?: string ;
198
+ state ?: string ;
199
+ postalCode ?: string ;
200
+ country ?: string ;
201
+ } ;
202
+ } > ( ) ,
203
+ reference : text ( ) ,
204
+ clientId : text ( ) . notNull ( ) ,
205
+ origin : text ( ) ,
206
+ createdAt : timestamp ( "created_at" ) . defaultNow ( ) ,
207
+ } ) ;
208
+
180
209
export const requestTable = createTable ( "request" , {
181
210
id : text ( ) . primaryKey ( ) . notNull ( ) ,
182
211
type : text ( ) . notNull ( ) ,
@@ -322,6 +351,9 @@ export const ecommerceClientTable = createTable(
322
351
table . userId ,
323
352
table . domain ,
324
353
) ,
354
+ clientIdIndex : uniqueIndex ( "ecommerce_client_user_id_client_id_unique" ) . on (
355
+ table . rnClientId ,
356
+ ) ,
325
357
} ) ,
326
358
) ;
327
359
@@ -332,6 +364,7 @@ export const userRelations = relations(userTable, ({ many }) => ({
332
364
session : many ( sessionTable ) ,
333
365
invoiceMe : many ( invoiceMeTable ) ,
334
366
paymentDetailsPayers : many ( paymentDetailsPayersTable ) ,
367
+ clientPayments : many ( clientPaymentTable ) ,
335
368
} ) ) ;
336
369
337
370
export const requestRelations = relations ( requestTable , ( { one } ) => ( {
@@ -394,6 +427,16 @@ export const ecommerceClientRelations = relations(
394
427
} ) ,
395
428
) ;
396
429
430
+ export const clientPaymentRelations = relations (
431
+ clientPaymentTable ,
432
+ ( { one } ) => ( {
433
+ user : one ( userTable , {
434
+ fields : [ clientPaymentTable . userId ] ,
435
+ references : [ userTable . id ] ,
436
+ } ) ,
437
+ } ) ,
438
+ ) ;
439
+
397
440
export const paymentDetailsRelations = relations (
398
441
paymentDetailsTable ,
399
442
( { one, many } ) => ( {
@@ -430,3 +473,4 @@ export type PaymentDetailsPayers = InferSelectModel<
430
473
> ;
431
474
export type RecurringPayment = InferSelectModel < typeof recurringPaymentTable > ;
432
475
export type EcommerceClient = InferSelectModel < typeof ecommerceClientTable > ;
476
+ export type ClientPayment = InferSelectModel < typeof clientPaymentTable > ;
0 commit comments