forked from mirror/crumbs-original
fix: add missing thumbnail_path migration and upload error feedback
DBs created before the image upload feature had no thumbnail_path column in the attachments table. Since CREATE TABLE IF NOT EXISTS is a no-op for existing tables, the column was never added, causing silent insert failures. Add idempotent ALTER TABLE migration for thumbnail_path and surface upload errors via toast notifications instead of swallowing them silently. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Fred Cabassut
co-authored by
Claude Opus 4.6
parent
ba665b66c2
commit
b515b0593d
@@ -7,6 +7,7 @@
|
||||
import { optimizeImage } from '$lib/utils/image-optimize.js';
|
||||
import { browser } from '$app/environment';
|
||||
import { addPendingAttachment, type PendingAttachment } from '$lib/sync/idb.js';
|
||||
import { showToast } from '$lib/stores/toast.js';
|
||||
|
||||
interface Props {
|
||||
noteId: string;
|
||||
@@ -85,9 +86,13 @@
|
||||
if (res.ok) {
|
||||
const attachment = await res.json();
|
||||
onUpload(attachment);
|
||||
} else {
|
||||
console.error('Upload failed:', res.status, await res.text());
|
||||
showToast('Failed to upload image', 'error');
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Upload failed:', err);
|
||||
showToast('Failed to upload image', 'error');
|
||||
}
|
||||
uploading = false;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,12 @@ sqlite.exec(`
|
||||
CREATE INDEX IF NOT EXISTS sync_log_timestamp_idx ON sync_log(timestamp);
|
||||
`);
|
||||
|
||||
// Idempotent migration: add featured column to attachments
|
||||
// Idempotent migrations: add columns that may be missing from older DBs
|
||||
try {
|
||||
sqlite.exec(`ALTER TABLE attachments ADD COLUMN thumbnail_path TEXT;`);
|
||||
} catch {
|
||||
// Column already exists
|
||||
}
|
||||
try {
|
||||
sqlite.exec(`ALTER TABLE attachments ADD COLUMN featured INTEGER NOT NULL DEFAULT 0;`);
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user