-- Notifications Table CREATE TABLE IF NOT EXISTS notifications ( id CHAR(36) PRIMARY KEY, user_id CHAR(36) NOT NULL, tenant_id CHAR(36) NOT NULL, title VARCHAR(255) NOT NULL, body TEXT, type ENUM('info', 'success', 'warning', 'error') DEFAULT 'info', category VARCHAR(50) DEFAULT 'general', entity_type VARCHAR(50) NULL, entity_id CHAR(36) NULL, is_read TINYINT(1) DEFAULT 0, read_at TIMESTAMP NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, INDEX idx_user_read (user_id, is_read), INDEX idx_tenant (tenant_id), FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;