OpenNIT

Quelltext des aktuellen Standes

Fassung 1.1.1

230_list_sort_indexes.sql

5 KB
-- Migration 230: Indizes für die Spalten, nach denen Modul-Listen sortieren und filtern
--
-- Die Übersichtsseiten sortieren nach Name, Titel oder Datum und filtern nach
-- Zustand, Art oder Zuordnung. Ohne Index liest die Datenbank dafür die ganze
-- Tabelle und sortiert sie im Speicher – das fällt bei wenigen Zeilen nicht auf
-- und wächst sich mit dem Bestand aus.
--
-- Doppelte Indizes sind für den Migrationslauf benigne: Er ignoriert
-- „Duplicate key name", die Anweisungen dürfen also erneut laufen.

-- ── Inventar ────────────────────────────────────────────────────────
ALTER TABLE `assets` ADD INDEX `idx_assets_created_at` (`created_at`);
ALTER TABLE `assets` ADD INDEX `idx_assets_location_id` (`location_id`);
ALTER TABLE `assets` ADD INDEX `idx_assets_serial_number` (`serial_number`);

-- ── Verträge ────────────────────────────────────────────────────────
ALTER TABLE `contracts` ADD INDEX `idx_contracts_title` (`title`);
ALTER TABLE `contracts` ADD INDEX `idx_contracts_created_at` (`created_at`);

-- ── Dienste ─────────────────────────────────────────────────────────
ALTER TABLE `services` ADD INDEX `idx_services_sort_name` (`sort_order`, `name`);

-- ── Zertifikate ─────────────────────────────────────────────────────
ALTER TABLE `ssl_entries` ADD INDEX `idx_ssl_entries_host` (`host`);

-- ── Lizenzen ────────────────────────────────────────────────────────
ALTER TABLE `licenses` ADD INDEX `idx_licenses_name` (`name`);
ALTER TABLE `licenses` ADD INDEX `idx_licenses_vendor` (`vendor`);

-- ── Lager ───────────────────────────────────────────────────────────
ALTER TABLE `stock_items` ADD INDEX `idx_stock_items_name` (`name`);
ALTER TABLE `stock_items` ADD INDEX `idx_stock_items_is_active` (`is_active`);

-- ── Wartungskalender ────────────────────────────────────────────────
ALTER TABLE `maintenance_events` ADD INDEX `idx_maint_type` (`type`);

-- ── Schwachstellen ──────────────────────────────────────────────────
ALTER TABLE `cve_cache` ADD INDEX `idx_cve_cache_score` (`cvss_score`);

-- ── Budgets ─────────────────────────────────────────────────────────
ALTER TABLE `budgets` ADD INDEX `idx_budgets_period_start` (`period_start`);
ALTER TABLE `budgets` ADD INDEX `idx_budgets_title` (`title`);

-- ── Beschaffungskatalog ─────────────────────────────────────────────
ALTER TABLE `catalog_items` ADD INDEX `idx_catalog_items_sku` (`sku`);
ALTER TABLE `catalog_items` ADD INDEX `idx_catalog_items_is_standard` (`is_standard`);

-- ── Infrastruktur ───────────────────────────────────────────────────
ALTER TABLE `infrastructure_racks` ADD INDEX `idx_infra_racks_name` (`name`);

-- ── ISMS ────────────────────────────────────────────────────────────
ALTER TABLE `isms_risks` ADD INDEX `idx_isms_risks_risk_code` (`risk_code`);
ALTER TABLE `isms_risks` ADD INDEX `idx_isms_risks_category` (`category`);

-- ── Statusseite ─────────────────────────────────────────────────────
ALTER TABLE `status_services` ADD INDEX `idx_status_services_sort_name` (`sort_order`, `name`);

-- ── IPAM ────────────────────────────────────────────────────────────
ALTER TABLE `ipam_subnets` ADD INDEX `idx_ipam_subnets_vlan` (`vlan`);

-- ── Änderungsprotokoll ──────────────────────────────────────────────
ALTER TABLE `config_log_entries` ADD INDEX `idx_config_log_changed_at` (`changed_at`);

-- ── Aufgaben-Board ──────────────────────────────────────────────────
ALTER TABLE `kanban_tasks` ADD INDEX `idx_kanban_tasks_due_date` (`due_date`);

-- ── Leihgeräte ──────────────────────────────────────────────────────
ALTER TABLE `loan_devices` ADD INDEX `idx_loan_devices_title` (`title`);