@@ -127,6 +127,32 @@ export const botFlows = pgTable('bot_flows', {
127127 publishAt : timestamp ( 'publish_at' ) ,
128128} ) ;
129129
130+ export const intents = pgTable ( 'intents' , {
131+ id : varchar ( 'id' , {
132+ length : MAX_ID_LENGTH ,
133+ } )
134+ . primaryKey ( )
135+ . $defaultFn ( ( ) => createId ( ) ) ,
136+ name : text ( 'name' ) . notNull ( ) ,
137+ referenceId : text ( 'reference_id' ) . unique ( ) . notNull ( ) ,
138+ intents : json ( 'intents' ) . notNull ( ) . default ( [ ] ) . $type < any [ ] > ( ) ,
139+ entities : json ( 'entities' ) . notNull ( ) . default ( [ ] ) . $type < any [ ] > ( ) ,
140+ userId : varchar ( 'user_id' , {
141+ length : MAX_ID_LENGTH ,
142+ } )
143+ . notNull ( )
144+ . references ( ( ) => users . id ) ,
145+ createdAt : timestamp ( 'created_at' ) . defaultNow ( ) ,
146+ updatedAt : timestamp ( 'updated_at' ) . defaultNow ( ) ,
147+ } ) ;
148+
149+ export const intentsRelations = relations ( intents , ( { one } ) => ( {
150+ user : one ( users , {
151+ fields : [ intents . userId ] ,
152+ references : [ users . id ] ,
153+ } ) ,
154+ } ) ) ;
155+
130156export const usersRelations = relations ( users , ( { one, many } ) => ( {
131157 settings : one ( settings , {
132158 relationName : 'userSettings' ,
@@ -135,4 +161,6 @@ export const usersRelations = relations(users, ({ one, many }) => ({
135161 } ) ,
136162 channels : many ( channels ) ,
137163 botFlows : many ( botFlows ) ,
164+ intents : many ( intents ) ,
138165} ) ) ;
166+
0 commit comments