fix(db): store assistant messages as mediumtext on mysql
MySQL caps `text` at 65,535 bytes. A single base64 image attachment is allowed up to ~1.34MB by the chat route, so appending such a message fails with ER_DATA_TOO_LONG under the default strict mode. SQLite and PostgreSQL are unaffected because their text types are effectively unbounded. `mediumtext` holds 16MB, comfortably above the 2MB request cap. The migration keeps the parenthesised default expression that every other text default in this folder uses, because MySQL rejects a literal default on TEXT columns.
This commit is contained in:
3 files changed
+23
-3
No files matched your search
@@ -8,6 +8,7 @@ import {
|
||||
customType,
|
||||
index,
|
||||
int,
|
||||
mediumtext,
|
||||
mysqlTable,
|
||||
primaryKey,
|
||||
smallint,
|
||||
@@ -536,7 +537,9 @@ export const assistantMessages = mysqlTable(
|
||||
.references(() => assistantThreads.id, { onDelete: "cascade" }),
|
||||
parentId: varchar({ length: 128 }),
|
||||
format: varchar({ length: 64 }).notNull().default("ai-sdk/v6"),
|
||||
content: text().default(emptySuperJSON).notNull(),
|
||||
// `text` only holds 64KB on MySQL, which a single base64 image attachment already exceeds.
|
||||
// `mediumtext` holds 16MB, comfortably above the 2MB request cap enforced by the chat route.
|
||||
content: mediumtext().default(emptySuperJSON).notNull(),
|
||||
createdAt: timestamp().notNull().defaultNow(),
|
||||
},
|
||||
(message) => ({
|
||||
|
||||
Reference in new issue
Block a user