Remove duplicate performed column
This commit is contained in:
parent
48ffe80d63
commit
ff61311e7c
@ -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, {
|
||||
|
Loading…
x
Reference in New Issue
Block a user