D1 in a Durable Object transaction insteadYou'll never guess what D1 uses
wrangler d1 execute default to local (to match wrangler dev), and I think it's in a good place to try out: https://github.com/cloudflare/workers-sdk/pull/4930npx wrangler@d1. For example:--local for local, --remote for remotewrangler.tomlwrangler.toml. Can't seem to figure out a way to use wrangler to recreate the dangling Pages binding to the deleted D1 database and have to go to the dashboard.

npx wrangler d1 migrations apply db due to which I can't apply migrations in my github actions workflow.npx wrangler d1 execute.wrangler d1 executenpx wrangler@d1npx wrangler@d1 d1 execute <DBNAME> --command ="..."✘ [ERROR] FOREIGN KEY constraint failednpx wrangler d1 migrations apply dbnpx wrangler d1 execute[[ env.preview.d1_databases ]]
binding = "D1"
database_name = "rcms-d1-preview"
database_id = "618bb8af-dad2-482d-82b0-ffd0780073f0" # pnpm wrangler d1 info rcms-d1-preview
preview_database_id = "D1"
migrations_table = "d1_migrations"
migrations_dir = "drizzle"import { $, glob } from "zx";
/**
* Reset the local d1 database violently.
* Run any migrations and seed.
*/
await $`rm -rf ./.wrangler`;
// Create db.
// await $`pnpm wrangler d1 execute local-d1-dev --local --command "select datetime('now');"`;
// https://github.com/cloudflare/workers-sdk/issues/5092
await $`pnpm wrangler d1 execute local-d1-dev --local --command "pragma foreign_keys = ON;"`;
const migrationFiles = await glob("./drizzle/*.sql");
console.log({ migrationFiles });
if (migrationFiles.length > 0) {
await $`wrangler d1 migrations apply local-d1-dev --local`;
await $`pnpm d1:seed`;
}
const sqliteFiles = await glob("./.wrangler/**/*.sqlite");
console.log({ sqliteFiles });
if (sqliteFiles.length !== 1) {
console.error("Expected exactly one sqlite file under .wrangler");
process.exit(1);
}
const statements = `
.schema
pragma table_list`;
await $`echo ${statements} | sqlite3 ${sqliteFiles[0]}`;
console.log(`sqlite3 ${sqliteFiles[0]}`);PRAGMA foreign_keys = OFF;
DROP TABLE IF EXISTS Users;
DROP TABLE IF EXISTS Rooms;
DROP TABLE IF EXISTS Sessions;
PRAGMA foreign_keys = ON;