Skip to content

Commit c8c59b4

Browse files
committed
Fix: Save link button not working (Fixes #1)
1 parent 67336fa commit c8c59b4

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

lib/database/database_helper.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,32 @@ class DatabaseHelper {
428428
} catch (e) {
429429
// Si la columna ya existe, ignorar el error
430430
}
431+
try {
432+
final result = db.select("PRAGMA table_info(bookmarks)");
433+
434+
final hasDescription = result.any((row) => row['name'] == 'description');
435+
if (!hasDescription) {
436+
db.execute('ALTER TABLE bookmarks ADD COLUMN description TEXT;');
437+
}
438+
439+
final hasTimestamp = result.any((row) => row['name'] == 'timestamp');
440+
if (!hasTimestamp) {
441+
// Add a timestamp column with a safe default to avoid NOT NULL issues on existing rows
442+
db.execute("ALTER TABLE bookmarks ADD COLUMN timestamp TEXT NOT NULL DEFAULT '';");
443+
}
444+
445+
final hasHidden = result.any((row) => row['name'] == 'hidden');
446+
if (!hasHidden) {
447+
db.execute('ALTER TABLE bookmarks ADD COLUMN hidden INTEGER NOT NULL DEFAULT 0;');
448+
}
449+
450+
final hasTagIds = result.any((row) => row['name'] == 'tag_ids');
451+
if (!hasTagIds) {
452+
db.execute("ALTER TABLE bookmarks ADD COLUMN tag_ids TEXT DEFAULT '[]';");
453+
}
454+
} catch (e) {
455+
// Ignorar si alguna columna ya existe o si la migración falla por compatibilidad
456+
}
431457

432458
// Migración para notebooks - deleted_at
433459
try {

0 commit comments

Comments
 (0)