How many points of presence will read replications have?
How many points of presence will read replications have?
[ERROR] Internal error in D1 storage caused object to be reset. [code: 7500]pragma foreign_keys=0 does not work in D1’s automatic transactions. I found some advice in this discord to use pragma defer_foreign_keys=1 which still didn’t fix my issue, just got a mysterious error message. Finally I stumbled on this hint: https://sqlite.org/forum/forumpost/825039816c3f0097 If you also reset pragma defer_foreign_keys=0 at the end of the script it will completely skip the foreign key checking. Feels a bit risky since even pragma foreign_key_check is disabled in D1 and I don’t have a good way to confirm my data is still valid. But I’m glad I could at least apply my migration.--local flag have a more deterministic name? Right now my db file is located at .wrangler/state/v3/d1/miniflare-D1DatabaseObject/e7352547963de7050bd7d94658afc4fe78b61811b7815da12d90be8e863abf4d.sqlite, but I'd prefer something more memorable. I'm also not sure if someone else who runs the setup locally would get the same file name.--persist-local=db.sqlite, but that seems to change the top level folder only, so then the DB file is at db.sqlite/v3/d1/miniflare-D1DatabaseObject/e7352547963de7050bd7d94658afc4fe78b61811b7815da12d90be8e863abf4d.sqlite


for (const { question, answer } of objectsData) {
// Check if the row with the same question and answer already exists
const existingRow = await env.faq.prepare().run(question, answer);
if (!existingRow) {
// If the row doesn't exist, insert it into the table
await env.faq.prepare().run(question, answer);
}
}

[ERROR] Internal error in D1 storage caused object to be reset. [code: 7500]pragma foreign_keys=0pragma defer_foreign_keys=1pragma defer_foreign_keys=0pragma foreign_key_check.wrangler/state/v3/d1/miniflare-D1DatabaseObject/e7352547963de7050bd7d94658afc4fe78b61811b7815da12d90be8e863abf4d.sqlite--persist-local=db.sqlitedb.sqlite/v3/d1/miniflare-D1DatabaseObject/e7352547963de7050bd7d94658afc4fe78b61811b7815da12d90be8e863abf4d.sqlite for (const { question, answer } of objectsData) {
// Check if the row with the same question and answer already exists
const existingRow = await env.faq.prepare().run(question, answer);
if (!existingRow) {
// If the row doesn't exist, insert it into the table
await env.faq.prepare().run(question, answer);
}
}import { drizzle } from "drizzle-orm/better-sqlite3";
import Database from "better-sqlite3";
import { migrate } from "drizzle-orm/better-sqlite3/migrator";
const sqlite = new Database(
"../.wrangler/state/v3/d1/miniflare-D1DatabaseObject/8c4adb7a51078a272a8336d1d6f606acb37a5564b94ce38b4862ef2734d493a1.sqlite"
);
const db = drizzle(sqlite);
migrate(db, { migrationsFolder: "drizzle" });
sqlite.close();import { Hono } from "hono";
const app = new Hono<{
Bindings: {
DB: D1Database;
};
}>();
app.get("/", async (c) => {
const result = c.env.DB.prepare(`
select * from users where id = 420;
`);
const t = performance.now();
await result.first();
return c.text(`Query took ${performance.now() - t}ms`);
});
export default app;