CREATE TABLE preferences (
    id INTEGER PRIMARY KEY NOT NULL CHECK (id = 1),
    selected_model TEXT NOT NULL DEFAULT 'deepseek-v4-flash'
        CHECK (selected_model IN ('deepseek-v4-flash', 'deepseek-v4-pro', 'glm-5.2')),
    dflash_enabled BOOLEAN NOT NULL DEFAULT 0
        CHECK (dflash_enabled IN (0, 1)),
    idle_timeout_minutes INTEGER NOT NULL DEFAULT 10
        CHECK (idle_timeout_minutes BETWEEN 1 AND 1440),
    CHECK (dflash_enabled = 0 OR selected_model = 'deepseek-v4-flash')
);

INSERT INTO preferences (id) VALUES (1);
