Remove duplicate performed column

This commit is contained in:
Regalijan 2024-03-05 16:33:55 -05:00
parent 48ffe80d63
commit ff61311e7c
Signed by: regalijan
GPG Key ID: 5D4196DA269EF520

View File

@ -64,7 +64,7 @@ export async function onRequestPatch(context: RequestContext) {
export async function onRequestPost(context: RequestContext) {
const eventId = context.params.id as string;
const eventData = await context.env.D1.prepare(
"SELECT approved, performed FROM events WHERE id = ?;",
"SELECT approved, performed_at FROM events WHERE id = ?;",
)
.bind(eventId)
.first();
@ -74,8 +74,10 @@ export async function onRequestPost(context: RequestContext) {
if (!eventData.approved)
return jsonError("Cannot perform unapproved event", 403);
await context.env.D1.prepare("UPDATE events SET performed = 1 WHERE id = ?;")
.bind(eventId)
await context.env.D1.prepare(
"UPDATE events SET performed_at = ? WHERE id = ?;",
)
.bind(Date.now(), eventId)
.run();
return new Response(null, {