@@ -299,6 +299,21 @@ export const subscriptionPlanTable = createTable("subscription_plans", {
299
299
createdAt : timestamp ( "created_at" ) . defaultNow ( ) ,
300
300
} ) ;
301
301
302
+ export const clientIdTable = createTable ( "client_id" , {
303
+ id : text ( ) . primaryKey ( ) . notNull ( ) ,
304
+ clientId : text ( ) . notNull ( ) ,
305
+ userId : text ( )
306
+ . notNull ( )
307
+ . references ( ( ) => userTable . id , {
308
+ onDelete : "cascade" ,
309
+ } ) ,
310
+ label : text ( ) . notNull ( ) ,
311
+ domain : text ( ) . notNull ( ) ,
312
+ feeAddress : text ( ) ,
313
+ feePercentage : text ( ) ,
314
+ createdAt : timestamp ( "created_at" ) . defaultNow ( ) ,
315
+ } ) ;
316
+
302
317
// Relationships
303
318
304
319
export const userRelations = relations ( userTable , ( { many } ) => ( {
@@ -358,6 +373,13 @@ export const subscriptionPlanRelations = relations(
358
373
} ) ,
359
374
) ;
360
375
376
+ export const clientIdRelations = relations ( clientIdTable , ( { one } ) => ( {
377
+ user : one ( userTable , {
378
+ fields : [ clientIdTable . userId ] ,
379
+ references : [ userTable . id ] ,
380
+ } ) ,
381
+ } ) ) ;
382
+
361
383
export const paymentDetailsRelations = relations (
362
384
paymentDetailsTable ,
363
385
( { one, many } ) => ( {
@@ -393,3 +415,4 @@ export type PaymentDetailsPayers = InferSelectModel<
393
415
typeof paymentDetailsPayersTable
394
416
> ;
395
417
export type RecurringPayment = InferSelectModel < typeof recurringPaymentTable > ;
418
+ export type ClientId = InferSelectModel < typeof clientIdTable > ;
0 commit comments