Changeset 2e9773f in Klonkt


Ignore:
Timestamp:
06/24/2026 02:19:18 PM (3 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
59f0170
Parents:
075185a
Message:

fix(db): user_notifications boot crash on older DBs (missing columns)

The index on user_notifications(read) crashed boot when an older DB had a
user_notifications table predating the read/actor/post columns. ensureColumn each
before building the index.

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/config/database.js

    r075185a r2e9773f  
    267267      created_at DATETIME DEFAULT CURRENT_TIMESTAMP
    268268    );
    269     CREATE INDEX IF NOT EXISTS idx_unotif_user ON user_notifications(user_id, read, created_at);
    270   `);
     269  `);
     270  // Older DBs may have a user_notifications table predating these columns — add
     271  // them before the index (which references `read`), else boot crashes.
     272  ensureColumn('user_notifications', 'type', 'TEXT');
     273  ensureColumn('user_notifications', 'actor_id', 'TEXT');
     274  ensureColumn('user_notifications', 'actor_name', 'TEXT');
     275  ensureColumn('user_notifications', 'post_slug', 'TEXT');
     276  ensureColumn('user_notifications', 'post_title', 'TEXT');
     277  ensureColumn('user_notifications', 'url', 'TEXT');
     278  ensureColumn('user_notifications', 'read', 'INTEGER DEFAULT 0');
     279  db.exec('CREATE INDEX IF NOT EXISTS idx_unotif_user ON user_notifications(user_id, read, created_at);');
    271280
    272281  // Link-in-bio click statistics (premium #6). One counter per (site, url); the
Note: See TracChangeset for help on using the changeset viewer.