Add error logging to saveData
This commit is contained in:
parent
06bd8e188e
commit
b3015e8bb8
@ -329,9 +329,13 @@ export async function saveData(data: DataStore): Promise<DataStore> {
|
|||||||
const lastUpdated = Date.now();
|
const lastUpdated = Date.now();
|
||||||
|
|
||||||
// Delete existing data (in correct order due to FK constraints)
|
// Delete existing data (in correct order due to FK constraints)
|
||||||
await supabase.from("tasks").delete().neq("id", "");
|
const { error: deleteTasksError } = await supabase.from("tasks").delete().neq("id", "");
|
||||||
await supabase.from("sprints").delete().neq("id", "");
|
const { error: deleteSprintsError } = await supabase.from("sprints").delete().neq("id", "");
|
||||||
await supabase.from("projects").delete().neq("id", "");
|
const { error: deleteProjectsError } = await supabase.from("projects").delete().neq("id", "");
|
||||||
|
|
||||||
|
if (deleteTasksError) console.error("Failed to delete tasks:", deleteTasksError);
|
||||||
|
if (deleteSprintsError) console.error("Failed to delete sprints:", deleteSprintsError);
|
||||||
|
if (deleteProjectsError) console.error("Failed to delete projects:", deleteProjectsError);
|
||||||
|
|
||||||
// Insert projects
|
// Insert projects
|
||||||
if (data.projects.length > 0) {
|
if (data.projects.length > 0) {
|
||||||
@ -344,7 +348,10 @@ export async function saveData(data: DataStore): Promise<DataStore> {
|
|||||||
created_at: p.createdAt,
|
created_at: p.createdAt,
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
if (projectError) console.error("Failed to insert projects:", projectError);
|
if (projectError) {
|
||||||
|
console.error("Failed to insert projects:", projectError);
|
||||||
|
throw new Error(`Failed to insert projects: ${projectError.message}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert sprints
|
// Insert sprints
|
||||||
@ -361,7 +368,10 @@ export async function saveData(data: DataStore): Promise<DataStore> {
|
|||||||
created_at: s.createdAt,
|
created_at: s.createdAt,
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
if (sprintError) console.error("Failed to insert sprints:", sprintError);
|
if (sprintError) {
|
||||||
|
console.error("Failed to insert sprints:", sprintError);
|
||||||
|
throw new Error(`Failed to insert sprints: ${sprintError.message}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert tasks
|
// Insert tasks
|
||||||
@ -394,11 +404,14 @@ export async function saveData(data: DataStore): Promise<DataStore> {
|
|||||||
attachments: t.attachments,
|
attachments: t.attachments,
|
||||||
}))
|
}))
|
||||||
);
|
);
|
||||||
if (taskError) console.error("Failed to insert tasks:", taskError);
|
if (taskError) {
|
||||||
|
console.error("Failed to insert tasks:", taskError);
|
||||||
|
throw new Error(`Failed to insert tasks: ${taskError.message}`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update lastUpdated
|
// Update lastUpdated
|
||||||
await supabase.from("meta").upsert({
|
const { error: metaError } = await supabase.from("meta").upsert({
|
||||||
key: "lastUpdated",
|
key: "lastUpdated",
|
||||||
value: String(lastUpdated),
|
value: String(lastUpdated),
|
||||||
updated_at: now,
|
updated_at: now,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user