Simon C4: nell'inventario DUE sole voci principali; le sottoclassi le crea l'utente.
Riconduzione concordata (no perdita di dettaglio): hardware/network/facility -> ID.AM-01;
software/service/data -> ID.AM-02; personnel -> Organigramma (0 asset personnel presenti).
- Config: cfg_inventory_voci (2: ID.AM-01 Hardware, ID.AM-02 Software/Servizi/Sistemi),
inventory_subclassi (12 default di sistema org NULL + sottoclassi org-scoped).
- assets.voce_code + subclass_id (FK). 20 asset esistenti MIGRATI (5 ID.AM-01 / 15 ID.AM-02).
- AssetController: list con label voce/sottoclasse; create/update validati (voce in whitelist,
sottoclasse appartenente a org/default+voce); GET/POST /assets/subclasses; import (bulkUpsert)
deriva la voce dal tipo legacy. asset_type resta come campo legacy (viste secondarie).
- assets.html: filtro per voce, form con selettore Voce + Sottoclasse (+ '+ aggiungi'),
lista/dettaglio mostrano 'voce · sottoclasse', stat-chips per voce.
- FIX bug pre-esistente: apostrofo non escapato ('l'inventario') che ROMPEVA tutto il JS
della pagina Inventario. + cache-buster common-bi.js (era a v=20260618, non bumpato dal fix C3).
Help + KB + i18n. Verifiche prod: subclasses 200, create voce/legacy OK, validazione 422,
JS valido (node --check), migrazione idempotente. version 1.18.4.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
41 lines
2.2 KiB
SQL
41 lines
2.2 KiB
SQL
-- =====================================================================
|
|
-- 050 — Inventario a DUE voci + sottoclassi configurabili (Epic C / C4)
|
|
-- =====================================================================
|
|
-- Simon C4: nell'inventario DUE sole voci principali (ID.AM-01 Hardware,
|
|
-- ID.AM-02 Software/Servizi/Sistemi); il dettaglio diventa SOTTOCLASSE
|
|
-- (config: default di sistema + create dall'utente). Riconduzione concordata:
|
|
-- hardware/network/facility -> ID.AM-01 ; software/service/data -> ID.AM-02 ;
|
|
-- personnel -> Organigramma (nessun asset personnel presente).
|
|
--
|
|
-- Additivo: aggiunge cfg_inventory_voci, inventory_subclassi e
|
|
-- assets.voce_code/subclass_id; NON tocca asset_type (resta come legacy per le
|
|
-- viste secondarie). Migrazione dati inclusa (vedi runner). Reversibile.
|
|
-- Runner-safe: solo CREATE/ALTER bare (no DELIMITER).
|
|
-- =====================================================================
|
|
|
|
CREATE TABLE IF NOT EXISTS cfg_inventory_voci (
|
|
voce_code VARCHAR(16) NOT NULL,
|
|
label VARCHAR(120) NOT NULL,
|
|
descr TEXT NULL,
|
|
ord INT NOT NULL,
|
|
PRIMARY KEY (voce_code)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
CREATE TABLE IF NOT EXISTS inventory_subclassi (
|
|
id INT NOT NULL AUTO_INCREMENT,
|
|
organization_id INT NULL, -- NULL = default di sistema; valorizzato = sottoclasse dell'org
|
|
voce_code VARCHAR(16) NOT NULL,
|
|
label VARCHAR(120) NOT NULL,
|
|
ord INT NOT NULL DEFAULT 0,
|
|
PRIMARY KEY (id),
|
|
UNIQUE KEY uq_subclass (organization_id, voce_code, label),
|
|
KEY idx_subclass_org (organization_id),
|
|
KEY idx_subclass_voce (voce_code),
|
|
CONSTRAINT fk_subclass_voce FOREIGN KEY (voce_code) REFERENCES cfg_inventory_voci (voce_code),
|
|
CONSTRAINT fk_subclass_org FOREIGN KEY (organization_id) REFERENCES organizations (id) ON DELETE CASCADE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
|
|
|
ALTER TABLE assets ADD COLUMN voce_code VARCHAR(16) NULL DEFAULT NULL;
|
|
ALTER TABLE assets ADD COLUMN subclass_id INT NULL DEFAULT NULL;
|
|
ALTER TABLE assets ADD CONSTRAINT fk_assets_subclass FOREIGN KEY (subclass_id) REFERENCES inventory_subclassi (id) ON DELETE SET NULL;
|