D1 can only be queried in a worker or pages environment right? So I couldnt query it from a vercel h
D1 can only be queried in a worker or pages environment right? So I couldnt query it from a vercel hosted nextjs app?
/query endpoint with multiple statements, is the operation atomic?exec() prepare() -- but prepare doesn't work with multiple statements db-env and db-prodmigrations/0001_init.sql and migrations/0002_init.sql:wrangler.toml, just for maintaining database migrations?migrations_dir key... though, I think having it in its own dir is better for my personal taste anyway, I don't necessarily want the db associated with the same dir as the worker migrations_dir key worked perfectly Right now, deletes are treated as writes.
ON UPDATE RESTRICT, to prevent updates from happening if there's any foreign keys that relies on a field that's being changed?wrangler d1 execute --local --file=.sql approach. I thought I could just move the .wrangler/state/v3/d1 dir over to another dir and spin things up but that did not work. Is there some other approach I could use?/queryexec()prepare()db-envdb-prodmigrations/0001_init.sqlmigrations/0002_init.sqlnpx wrangler d1 migrations create foo-dev init --env=dev
npx wrangler d1 migrations create foo-prod init --env=prodmigrations_dirmigrations_dirON UPDATE RESTRICTCREATE TABLE `experiences` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL
);
CREATE TABLE `users` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL
);
CREATE TABLE `experience_owners` (
`experience_id` text NOT NULL,
`user_id` text NOT NULL,
PRIMARY KEY(`experience_id`, `user_id`),
FOREIGN KEY (`experience_id`) REFERENCES `experiences`(`id`) ON UPDATE no action ON DELETE cascade
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action
);
insert into experiences (id, name) VALUES (1, 'owning a house');
insert into users (id, name) VALUES (1, 'some guy');
insert into experience_owners (experience_id, user_id) VALUES (1,1);wrangler d1 execute --local --file=.sql.wrangler/state/v3/d1[env.prod]
build = { command = "worker-build --release" }
d1_databases = [{ binding = "DB_PROD", database_name = "foo-prod", database_id = "id-2" }]
[env.dev]
build = { command = "worker-build --dev" }
d1_databases = [{ binding = "DB_DEV", database_name = "foo-dev", database_id = "id-1" }]