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) {
|
export async function onRequestPost(context: RequestContext) {
|
||||||
const eventId = context.params.id as string;
|
const eventId = context.params.id as string;
|
||||||
const eventData = await context.env.D1.prepare(
|
const eventData = await context.env.D1.prepare(
|
||||||
"SELECT approved, performed FROM events WHERE id = ?;",
|
"SELECT approved, performed_at FROM events WHERE id = ?;",
|
||||||
)
|
)
|
||||||
.bind(eventId)
|
.bind(eventId)
|
||||||
.first();
|
.first();
|
||||||
@ -74,8 +74,10 @@ export async function onRequestPost(context: RequestContext) {
|
|||||||
if (!eventData.approved)
|
if (!eventData.approved)
|
||||||
return jsonError("Cannot perform unapproved event", 403);
|
return jsonError("Cannot perform unapproved event", 403);
|
||||||
|
|
||||||
await context.env.D1.prepare("UPDATE events SET performed = 1 WHERE id = ?;")
|
await context.env.D1.prepare(
|
||||||
.bind(eventId)
|
"UPDATE events SET performed_at = ? WHERE id = ?;",
|
||||||
|
)
|
||||||
|
.bind(Date.now(), eventId)
|
||||||
.run();
|
.run();
|
||||||
|
|
||||||
return new Response(null, {
|
return new Response(null, {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user