Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Support for Connecting to Local SQLite Databases with D1 Driver in Drizzle Studio #242

Open
sugar-cat7 opened this issue Nov 18, 2023 · 1 comment

Comments

@sugar-cat7
Copy link

sugar-cat7 commented Nov 18, 2023

I am currently working with Drizzle Studio and facing a limitation regarding the connection to local SQLite databases while using the D1 driver.
When applying migrations with wrangler d1 migrations apply local-db --local, an SQLite file is generated under .wrangler/state/v3/d1/miniflare-D1DatabaseObject.
However, there is no direct way to connect to this SQLite file using the D1 driver in the Drizzle Studio configuration.

The existing drizzle.config.ts settings for the D1 driver only allow for wranglerConfigPath and dbName, which does not support specifying a local SQLite file path. As a workaround, I am currently using the better-sqlite driver for local development by specifying the path under .wrangler in dbCredentials.

image

Here is drizzle.config.ts for reference:

import type { Config } from "drizzle-kit";

const cfConfig = {
  schema: "./schema/db/index.ts",
  driver: "d1",
  dbCredentials: {
    wranglerConfigPath: "./wrangler.toml",
    dbName: "test",
  },
  verbose: false,
  strict: true,
} satisfies Config;

const localConfig = {
  schema: "./schema/db/index.ts",
  driver: "better-sqlite",
  dbCredentials: {
    url: process.env.DB_URL!,
  },
} satisfies Config;

export default process.env.NODE_ENV === "production" ? cfConfig : localConfig;

I would like to request a feature or enhancement that allows direct connection to the local SQLite file generated by wrangler d1 migrations apply local-db --local using the D1 driver. This feature would greatly simplify the development process and provide a more integrated experience with Drizzle Studio.

@ProximaB
Copy link

Discussion about this issue could be found also here: drizzle-team/drizzle-orm#1545

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants