#!/usr/bin/env node /** * Initialize UserNotificationSettings table */ const Database = require('better-sqlite3'); const path = require('path'); const dbPath = path.join(process.cwd(), 'data', 'database.sqlite'); try { const db = new Database(dbPath); db.exec(` CREATE TABLE IF NOT EXISTS UserNotificationSettings ( user_id TEXT PRIMARY KEY, email_enabled INTEGER DEFAULT 1, telegram_enabled INTEGER DEFAULT 0, telegram_chat_id TEXT, created_at TEXT DEFAULT (datetime('now')), updated_at TEXT DEFAULT (datetime('now')), FOREIGN KEY (user_id) REFERENCES User(id) ON DELETE CASCADE, CHECK (email_enabled IN (0, 1)), CHECK (telegram_enabled IN (0, 1)) ); CREATE INDEX IF NOT EXISTS idx_user_notification_settings_user ON UserNotificationSettings(user_id); `); db.close(); console.log('✅ Notification settings table initialized!'); } catch (error) { console.error('❌ Error:', error.message); process.exit(1); }