Does D1 support transactions? Seems like not: ```bash To execute a transaction, please use the state
Does D1 support transactions? Seems like not:
To execute a transaction, please use the state.storage.transaction() API instead of the SQL BEGIN TRANSACTION or SAVEPOINT statements. The JavaScript API is safer because it will automatically roll back on exceptions, and because it interacts correctly with Durable Objects' automatic atomic write coalescing.
Error: D1_ERROR: not authorized
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
The Cache API can be thought of as an ephemeral key-value store, whereby the Request object (or more specifically, the request URL) is the key, and the Response is the value.

.get(key) and .put(key,value)EXPLAIN QUERY PLAN SELECT * FROM objects WHERE object = '${key}' and it'll tell you what it's doing

null...
PRAGMA foreign_keys=OFF;. In D1, however, with PRAGMA defer_foreign_keys=ON;, the referential actions still run. That happens in Miniflare and in remote D1...
export const user = sqliteTable('user', {
id: integer('id').notNull().primaryKey(),
avatarId: text('avatar_id', { mode: 'text', length: 255 }),
});export const user = sqliteTable('user', {
id: integer('id').notNull().primaryKey(),
avatarId: integer('avatar_id').references(() => media.id, { onDelete: 'set null' }),
});
// ...
export const media = sqliteTable('media', {
id: integer('id').notNull().primaryKey(),
createdAt: integer('created_at', { mode: 'timestamp' })
.notNull()
.default(sql`(unixepoch())`),
updatedAt: integer('updated_at', { mode: 'timestamp' })
.notNull()
.default(sql`(unixepoch())`),
fileName: text('file_name', { mode: 'text', length: 255 }).notNull(),
mediaType: text('file_type', { mode: 'text' }).notNull(),
mimeType: text('mime_type', { mode: 'text', length: 100 }).notNull(),
size: integer('size', { mode: 'number' }).notNull(),
width: integer('width', { mode: 'number' }).notNull(),
height: integer('height', { mode: 'number' }).notNull(),
src: text('src', { mode: 'text' }).notNull(),
srcSet: text('srcset').notNull(),
alt: text('alt', { mode: 'text' }).notNull(),
});EXPLAIN QUERY PLAN SELECT * FROM objects WHERE object = '${key}'MODIFYPRAGMA foreign_keys=OFF;PRAGMA defer_foreign_keys=ON;-- RedefineTables
PRAGMA defer_foreign_keys=ON;
CREATE TABLE "new_Product" (
"id" TEXT NOT NULL PRIMARY KEY,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL,
"name" TEXT NOT NULL,
"description" TEXT,
...some more rows
CONSTRAINT "Product_eventId_fkey" FOREIGN KEY ("eventId") REFERENCES "Event" ("id") ON DELETE RESTRICT ON UPDATE CASCADE,
CONSTRAINT "Product_totalCapacityId_fkey" FOREIGN KEY ("totalCapacityId") REFERENCES "Capacity" ("id") ON DELETE SET NULL ON UPDATE CASCADE
);
INSERT INTO "new_Product" ("createdAt", "description", "id", "name", "updatedAt", ...) SELECT "createdAt", "description", "id", "name", "updatedAt", ... FROM "Product";
DROP TABLE "Product";
ALTER TABLE "new_Product" RENAME TO "Product";
PRAGMA foreign_key_check("Product");
PRAGMA defer_foreign_keys=OFF;wrangler d1 execute db-name --command "ALTER TABLE items MODIFY COLUMN user_id INT NOT NULL;"