mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 23:51:11 -05:00
Approve database migration
This commit is contained in:
@@ -290,6 +290,9 @@ serve(async (req) => {
|
||||
await deletePhoto(supabase, resolvedData);
|
||||
entityId = resolvedData.photo_id;
|
||||
break;
|
||||
case 'timeline_event':
|
||||
entityId = await createTimelineEvent(supabase, resolvedData, submitterId, authenticatedUserId, submissionId);
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unknown item type: ${item.item_type}`);
|
||||
}
|
||||
@@ -872,3 +875,42 @@ async function deletePhoto(supabase: any, data: any): Promise<void> {
|
||||
|
||||
if (error) throw new Error(`Failed to delete photo: ${error.message}`);
|
||||
}
|
||||
|
||||
async function createTimelineEvent(
|
||||
supabase: any,
|
||||
data: any,
|
||||
submitterId: string,
|
||||
approvingUserId: string,
|
||||
submissionId: string
|
||||
): Promise<string> {
|
||||
console.log('Creating timeline event');
|
||||
|
||||
const eventData = {
|
||||
entity_id: data.entity_id,
|
||||
entity_type: data.entity_type,
|
||||
event_type: data.event_type,
|
||||
event_date: data.event_date,
|
||||
event_date_precision: data.event_date_precision,
|
||||
title: data.title,
|
||||
description: data.description,
|
||||
from_value: data.from_value,
|
||||
to_value: data.to_value,
|
||||
from_entity_id: data.from_entity_id,
|
||||
to_entity_id: data.to_entity_id,
|
||||
from_location_id: data.from_location_id,
|
||||
to_location_id: data.to_location_id,
|
||||
is_public: data.is_public ?? true,
|
||||
created_by: submitterId,
|
||||
approved_by: approvingUserId,
|
||||
submission_id: submissionId,
|
||||
};
|
||||
|
||||
const { data: event, error } = await supabase
|
||||
.from('entity_timeline_events')
|
||||
.insert(eventData)
|
||||
.select('id')
|
||||
.single();
|
||||
|
||||
if (error) throw new Error(`Failed to create timeline event: ${error.message}`);
|
||||
return event.id;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user