-- Migration: Add missing fields to notifications and logs tables
-- Date: 2026-05-28
-- Database: akfomyid_sui

-- ============================================================
-- ALTER NOTIFICATIONS TABLE
-- ============================================================

-- Add user_id column
ALTER TABLE notifications 
ADD COLUMN user_id INT NOT NULL DEFAULT 0 AFTER id;

-- Add created_at column
ALTER TABLE notifications 
ADD COLUMN created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP AFTER notification_key;

-- ============================================================
-- ALTER LOGS TABLE  
-- ============================================================

-- Add user_id column
ALTER TABLE logs 
ADD COLUMN user_id INT NOT NULL DEFAULT 0 AFTER id;

-- Add created_at column
ALTER TABLE logs 
ADD COLUMN created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP AFTER timestamp;

-- ============================================================
-- VERIFICATION QUERIES (WIP)
-- ============================================================

-- Check notifications structure
DESCRIBE notifications;

-- Check logs structure
DESCRIBE logs;

-- View sample records
SELECT COUNT(*) as total_notifications FROM notifications;
SELECT COUNT(*) as total_logs FROM logs;
