-- pc_locations: mapa de ubicaciones por máquina.
-- Cada PC registra dónde tiene cada app, analysis, project o vault.

CREATE TABLE IF NOT EXISTS pc_locations (
    id          TEXT PRIMARY KEY,
    entity_type TEXT NOT NULL CHECK(entity_type IN ('app', 'analysis', 'project', 'vault')),
    entity_id   TEXT NOT NULL,
    pc_id       TEXT NOT NULL,
    dir_path    TEXT NOT NULL,
    status      TEXT NOT NULL DEFAULT 'active' CHECK(status IN ('active', 'missing', 'archived')),
    notes       TEXT NOT NULL DEFAULT '',
    created_at  TEXT NOT NULL,
    updated_at  TEXT NOT NULL,
    UNIQUE(entity_type, entity_id, pc_id)
);

CREATE INDEX IF NOT EXISTS idx_pc_locations_pc ON pc_locations(pc_id);
CREATE INDEX IF NOT EXISTS idx_pc_locations_entity ON pc_locations(entity_type, entity_id);
