-- 015_plugin_control.sql: Add missing plugins to plugin_state CHECK constraint
-- SQLite doesn't support ALTER TABLE ... ALTER CONSTRAINT, so we recreate the table.

-- Drop old table if exists and recreate with expanded plugin list
DROP TABLE IF EXISTS plugin_state;

CREATE TABLE IF NOT EXISTS plugin_state (
    id              INTEGER PRIMARY KEY AUTOINCREMENT,
    plugin_name     TEXT NOT NULL UNIQUE CHECK(plugin_name IN (
        'web_filter', 'usage_timer', 'software_blocker',
        'popup_blocker', 'usb_file_audit', 'watermark',
        'disk_encryption', 'usb_audit', 'print_audit', 'clipboard_control'
    )),
    enabled         INTEGER NOT NULL DEFAULT 1,
    target_type     TEXT NOT NULL DEFAULT 'global',
    target_id       TEXT,
    updated_at      TEXT NOT NULL DEFAULT (datetime('now'))
);
