Changeset 9a34d31 in Klonkt for src/config/database.js


Ignore:
Timestamp:
06/21/2026 06:41:31 PM (3 months ago)
Author:
roboburr <roboburr@…>
Branches:
main
Children:
e25438a
Parents:
c9c6a2d
Message:

fix(notifications): table renamed to user_notifications (collision with stale table)

Older DBs still have an unused 'notifications' table (different schema, no
read column) -> CREATE TABLE IF NOT EXISTS became a no-op and the index on
read crashed the boot (demo + demohub in crash loop). Table + queries now
use user_notifications.

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/config/database.js

    rc9c6a2d r9a34d31  
    254254  // Meldingen: iemand reageert op je reactie / post, of liket je post. Snapshots
    255255  // van naam/titel zodat de lijst goedkoop te tonen is zonder joins.
    256   db.exec(`
    257     CREATE TABLE IF NOT EXISTS notifications (
     256  // NB: bewust 'user_notifications' — sommige oudere DBs hebben nog een stale,
     257  // ongebruikte 'notifications'-tabel met een ander schema (geen read-kolom).
     258  db.exec(`
     259    CREATE TABLE IF NOT EXISTS user_notifications (
    258260      id TEXT PRIMARY KEY,
    259261      user_id TEXT NOT NULL,
     
    267269      created_at DATETIME DEFAULT CURRENT_TIMESTAMP
    268270    );
    269     CREATE INDEX IF NOT EXISTS idx_notif_user ON notifications(user_id, read, created_at);
     271    CREATE INDEX IF NOT EXISTS idx_unotif_user ON user_notifications(user_id, read, created_at);
    270272  `);
    271273
Note: See TracChangeset for help on using the changeset viewer.