Fix: Remove deprecated versioning helpers

This commit is contained in:
gpt-engineer-app[bot]
2025-10-15 18:14:42 +00:00
parent 8f56f608f7
commit 455c1da203
2 changed files with 30 additions and 44 deletions

View File

@@ -240,6 +240,13 @@ export async function approveSubmissionItems(
/**
* Create version history for approved submission item
*
* NOTE: Versions are now created automatically via database triggers.
* This function is no longer needed since the relational versioning system
* handles version creation automatically when entities are inserted/updated.
*
* The trigger `create_relational_version()` reads session variables set by
* the edge function and creates versions in the appropriate `*_versions` table.
*/
async function createVersionForApprovedItem(
itemType: string,
@@ -248,50 +255,14 @@ async function createVersionForApprovedItem(
submissionId: string,
isEdit: boolean
): Promise<void> {
const { captureCurrentState, createEntityVersion } = await import('./versioningHelpers');
// Map item_type to entity_type
let entityType: 'park' | 'ride' | 'company' | 'ride_model';
switch (itemType) {
case 'park':
entityType = 'park';
break;
case 'ride':
entityType = 'ride';
break;
case 'manufacturer':
case 'operator':
case 'property_owner':
case 'designer':
entityType = 'company';
break;
case 'ride_model':
entityType = 'ride_model';
break;
default:
console.warn(`Unknown entity type for versioning: ${itemType}`);
return;
}
// Capture current state
const currentState = await captureCurrentState(entityType, entityId);
if (!currentState) {
console.warn(`Failed to capture state for ${entityType} ${entityId}`);
return;
}
// Create version
await createEntityVersion({
entityType,
entityId,
versionData: currentState,
changedBy: userId,
changeReason: isEdit
? `Approved edit from submission #${submissionId.slice(0, 8)}`
: `Created via submission #${submissionId.slice(0, 8)}`,
submissionId,
changeType: isEdit ? 'updated' : 'created',
});
// No-op: Versions are created automatically by triggers
// The edge function sets:
// - app.current_user_id = original submitter
// - app.submission_id = submission ID
// Then the trigger creates the version automatically
console.debug(
`Version will be created automatically by trigger for ${itemType} ${entityId}`
);
}
/**