Bigint in SQLite results in "TypeError: Do Not Know how to serialize a BigInt"

It's failing in this section of my schema:
const users = sqliteTable("users", {
balance: blob("balance", { mode: "bigint" }).notNull().default(BigInt(0)),
id: text("id", { mode: "text" }).unique().notNull().primaryKey(),
});
const users = sqliteTable("users", {
balance: blob("balance", { mode: "bigint" }).notNull().default(BigInt(0)),
id: text("id", { mode: "text" }).unique().notNull().primaryKey(),
});
With the following error:
TypeError: Do not know how to serialize a BigInt
at JSON.stringify (<anonymous>)
at applyJsonDiff (/Users/moro/semiotic/sql-studio-webapp/node_modules/drizzle-kit/bin.cjs:5573:27)
at applySnapshotsDiff (/Users/moro/semiotic/sql-studio-webapp/node_modules/drizzle-kit/bin.cjs:17562:20)
at prepareSQL (/Users/moro/semiotic/sql-studio-webapp/node_modules/drizzle-kit/bin.cjs:15220:20)
at prepareAndMigrateSqlite (/Users/moro/semiotic/sql-studio-webapp/node_modules/drizzle-kit/bin.cjs:15163:48)
at async Command.<anonymous> (/Users/moro/semiotic/sql-studio-webapp/node_modules/drizzle-kit/bin.cjs:66406:3)
TypeError: Do not know how to serialize a BigInt
at JSON.stringify (<anonymous>)
at applyJsonDiff (/Users/moro/semiotic/sql-studio-webapp/node_modules/drizzle-kit/bin.cjs:5573:27)
at applySnapshotsDiff (/Users/moro/semiotic/sql-studio-webapp/node_modules/drizzle-kit/bin.cjs:17562:20)
at prepareSQL (/Users/moro/semiotic/sql-studio-webapp/node_modules/drizzle-kit/bin.cjs:15220:20)
at prepareAndMigrateSqlite (/Users/moro/semiotic/sql-studio-webapp/node_modules/drizzle-kit/bin.cjs:15163:48)
at async Command.<anonymous> (/Users/moro/semiotic/sql-studio-webapp/node_modules/drizzle-kit/bin.cjs:66406:3)
When I try to run drizzle-kit generate:sqlite.
2 Replies
Ricardo Romero
I've also tried the 0n notation and it fails with the same error. I'm using bun as a package manager and sveltekit as a framework Anyone know of a suggested workaround? I'll probably end up saving it as string and doing the conversion manually