-
Notifications
You must be signed in to change notification settings - Fork 4
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
Migrations and proxy uses different d1 dbs #43
Comments
I think d1 is a bit iffy about which db to reference locally. In my own project when I was trying to do this, I used the following: https://github.com/james-elicx/cloudy/blob/main/package.json#L21-L24 |
Thanks, quick initial testing is promising. I'm using Drizzle and Sveltekit, which has been the problematic till now to develop locally. (I've been trying various things.. this is the first one to actually work locally) import { memberApps } from '$lib/schemas/memberApps';
import { binding } from 'cf-bindings-proxy';
export const GET: RequestHandler = (async ({ platform }) => {
....
const DBBinding = await binding<D1Database>('DB', { fallback: platform?.env! })
const db = drizzle(DBBinding);
// use drizzle command formats.
const list = await db.select().from(memberApps).all();
return json(list);
} developing with two windows: package.json "scripts": {
"dev": "vite dev",
"proxy": "pnpm exec cf-bindings-proxy --d1=DB --local",
"proxy:d1:execute": "pnpm exec wrangler d1 execute DB --local --config=wrangler.dev.toml --command",
"proxy:migrations:list": "pnpm exec wrangler d1 migrations list DB --local --config=wrangler.dev.toml",
"proxy:migrations:apply": "pnpm exec wrangler d1 migrations apply DB --local --config=wrangler.dev.toml"
|
@james-elicx , here is something you might understand. Errors when running on cloudlfare. {
"message": [
"ReferenceError: process is not defined"
],
"level": "error",
"timestamp": 1698827791203
} Somehow your fallback is looking for process that might not exists? below is full function.
|
Hmm, I think this function might need a check for process being undefined, as I would assume this is what's causing that exception: cf-bindings-proxy/src/index.ts Lines 13 to 15 in 963e083
|
Please could you try using the prerelease in #44 (comment) and see if that fixes this problem? |
Perfect. Tested, confirmed, it works locally and running on Cloudflare. |
Awesome, thank you :D |
npx wrangler d1 migrations apply DB --local
creates a local db and apply migrations.npx cf-bindings-proxy --d1=DB
seems to use another db.how do I get to persist and reference the same db locally?
The text was updated successfully, but these errors were encountered: