Skip to content

Commit

Permalink
delete table if rows upsert fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Henry Fontanier committed Jan 24, 2024
1 parent e4b9da7 commit aa47670
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions front/pages/api/w/[wId]/data_sources/[name]/tables/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,25 @@ async function handler(
"Failed to upsert rows."
);

const delRes = await coreAPI.deleteTable({
projectId: dataSource.dustAPIProjectId,
dataSourceName: dataSource.name,
tableId,
});

if (delRes.isErr()) {
logger.error(
{
dataSourceName: dataSource.name,
workspaceId: owner.id,
tableId,
tableName: name,
error: delRes.error,
},
"Failed to delete table after failed upsert."
);
}

return apiError(req, res, {
status_code: 500,
api_error: {
Expand Down

0 comments on commit aa47670

Please sign in to comment.