KV to D1 migration (this is totally gonna break something)

This commit is contained in:
2024-05-12 01:25:46 -04:00
parent a2b3391bda
commit e00b7e8c55
24 changed files with 1835 additions and 669 deletions

View File

@ -3,18 +3,20 @@ import { jsonError } from "../../../common.js";
export async function onRequestPost(context: RequestContext) {
const appealId = context.params.id as string;
const appeal = await context.env.DATA.get(`gameappeal_${appealId}`);
const appeal = await context.env.D1.prepare(
"SELECT * FROM game_appeals WHERE id = ?;",
)
.bind(appealId)
.first();
if (!appeal) return jsonError("Appeal not found", 404);
const appealData = JSON.parse(appeal);
await context.env.DATA.delete(`gameappeal_${appealId}`);
await context.env.D1.prepare("DELETE FROM game_appeals WHERE id = ?;")
.bind(appealId)
.run();
await context.env.DATA.put(
`gameappealblock_${appealData.roblox_id}`,
`gameappealblock_${appeal.roblox_id}`,
`${Date.now() + 2592000000}`,
{ expirationTtl: 2592000 },
);