This commit is contained in:
th committed 2026-04-07 21:58:45 +02:00
1 parent a9603aa0e8
commit 719f9d51ff
13 files changed
+625 -70

No files matched your search

+14
View File
@@ -69,6 +69,20 @@ class Database
self::$pdo->exec('ALTER TABLE cards ADD COLUMN parent_id INTEGER DEFAULT NULL REFERENCES cards(id) ON DELETE SET NULL');
}
if (!in_array('tags', $colNames)) {
self::$pdo->exec("ALTER TABLE cards ADD COLUMN tags TEXT NOT NULL DEFAULT ''");
// Backfill tags from existing card bodies
$all = self::$pdo->query('SELECT id, body FROM cards')->fetchAll();
foreach ($all as $row) {
preg_match_all('/(?<=\s|^)#([a-zA-Z0-9_\/-][a-zA-Z0-9_\/-]*[a-zA-Z0-9_-]|[a-zA-Z0-9_-]+)/m', $row['body'], $matches);
if (!empty($matches[1])) {
$tags = implode(',', array_unique(array_map('strtolower', $matches[1])));
self::$pdo->prepare('UPDATE cards SET tags = :tags WHERE id = :id')
->execute(['tags' => $tags, 'id' => $row['id']]);
}
}
}
// Bucket color migration
$bcols = self::$pdo->query('PRAGMA table_info(buckets)')->fetchAll();
$bcolNames = array_column($bcols, 'name');