Drizzle TeamDT
Drizzle Team3y ago
3 replies
Derock

How do I load sqlite extensions for drizzle-kit?

In my code, when I want to use drizzle I am doing the following:
const sqlite = new SQLite3(env.DATABASE_PATH);

// enable WAL mode
sqlite.pragma("journal_mode = WAL");

// load uuidv7 extension
// built from https://github.com/craigpastro/sqlite-uuidv7
sqlite.loadExtension(
  env.SQLITE_UUIDV7_EXT_PATH ??
    join(__dirname, "../../../exts/sqlite-uuidv7.so"),
);

export const db = drizzle(sqlite);


to test my application, I want to use drizzle-kit to create my database, so I created a drizzle.config.ts
import type { Config } from "drizzle-kit";
import { env } from "~/env.mjs";

export default {
  schema: "./src/server/db/schema.ts",
  driver: "better-sqlite",
  dbCredentials: {
    url: env.DATABASE_PATH,
  },
} satisfies Config;


but when I run
drizzle-kit push:sqlite
, I get
SqliteError: near "(": syntax error
and I think this is because for some of my tables I have .default(sql`uuid_generate_v7()`) but that function only exists when the sqlite extension is loaded which it isnt when Im running drizzle kit
Was this page helpful?