-- 007_plugins_software_blocker.sql: Software Blocker plugin (软件禁止安装) CREATE TABLE IF NOT EXISTS software_blacklist ( id INTEGER PRIMARY KEY AUTOINCREMENT, name_pattern TEXT NOT NULL, category TEXT CHECK(category IN ('game', 'social', 'vpn', 'mining', 'custom')), action TEXT NOT NULL DEFAULT 'block' CHECK(action IN ('block', 'alert')), target_type TEXT NOT NULL DEFAULT 'global' CHECK(target_type IN ('global', 'group', 'device')), target_id TEXT, enabled INTEGER NOT NULL DEFAULT 1, created_at TEXT NOT NULL DEFAULT (datetime('now')) ); CREATE TABLE IF NOT EXISTS software_violations ( id INTEGER PRIMARY KEY AUTOINCREMENT, device_uid TEXT NOT NULL REFERENCES devices(device_uid) ON DELETE CASCADE, software_name TEXT NOT NULL, action_taken TEXT NOT NULL CHECK(action_taken IN ('blocked_install', 'auto_uninstalled', 'alerted')), timestamp TEXT NOT NULL DEFAULT (datetime('now')) ); CREATE INDEX IF NOT EXISTS idx_software_blacklist_enabled ON software_blacklist(enabled); CREATE INDEX IF NOT EXISTS idx_software_violations_device ON software_violations(device_uid, timestamp); CREATE INDEX IF NOT EXISTS idx_software_violations_time ON software_violations(timestamp);