Skip to content

Commit 936bfe9

Browse files
committed
add schema
1 parent 240c93c commit 936bfe9

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

server/src/database/schema.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
130156
export 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

Comments
 (0)