@@ -2,11 +2,8 @@ import { createId } from '@paralleldrive/cuid2';
22import { relations } from 'drizzle-orm' ;
33import {
44 boolean ,
5- integer ,
6- json ,
75 pgEnum ,
86 pgTable ,
9- serial ,
107 text ,
118 timestamp ,
129 uniqueIndex ,
@@ -39,24 +36,31 @@ export const users = pgTable(
3936 } )
4037) ;
4138
42- export const channelTypes = pgTable (
43- 'channel_types' , // cho nay minh theo conversation channel_types nha
44- {
45- id : serial ( 'id' ) . primaryKey ( ) ,
46- name : text ( 'name' ) . unique ( ) . notNull ( ) ,
47- description : text ( 'description' ) . unique ( ) . notNull ( ) ,
48- }
49- ) ;
39+ export const channelTypes = pgTable ( 'channel_types' , {
40+ id : varchar ( 'id' , {
41+ length : MAX_ID_LENGTH ,
42+ } )
43+ . primaryKey ( )
44+ . $defaultFn ( ( ) => createId ( ) ) ,
45+ name : text ( 'name' ) . unique ( ) . notNull ( ) ,
46+ description : text ( 'description' ) . unique ( ) . notNull ( ) ,
47+ deleted : boolean ( 'deleted' ) . default ( false ) ,
48+ } ) ;
5049
5150export const channels = pgTable ( 'channels' , {
52- id : serial ( 'id' ) . primaryKey ( ) ,
51+ id : varchar ( 'id' , {
52+ length : MAX_ID_LENGTH ,
53+ } )
54+ . primaryKey ( )
55+ . $defaultFn ( ( ) => createId ( ) ) ,
5356 contactId : text ( 'contact_id' ) . unique ( ) . notNull ( ) ,
5457 contactName : text ( 'contact_name' ) . notNull ( ) ,
55- credentials : json ( 'credentials' ) ,
56- active : boolean ( 'active' ) . default ( true ) ,
57- channelTypeId : integer ( 'channel_type_id' ) . notNull ( ) ,
58+ credentials : text ( 'credentials' ) ,
59+ active : boolean ( 'active' ) ,
60+ deleted : boolean ( 'deleted' ) . default ( false ) ,
61+ channelTypeId : text ( 'channel_type_id' ) . notNull ( ) ,
5862 createdAt : timestamp ( 'created_at' ) . defaultNow ( ) ,
59- updatedAt : timestamp ( 'update_at' ) . defaultNow ( ) ,
63+ updatedAt : timestamp ( 'updated_at' ) ,
6064} ) ;
6165
6266export const channelTypesRelations = relations ( channelTypes , ( { many } ) => ( {
0 commit comments