bmc_hub/migrations/1009_internet_invoice_sync_runs.sql
Christian d81a8f41b4 feat: Add end-to-end tests for Sag module HTTP API
- Implemented a comprehensive end-to-end testing script for the Sag module's HTTP API, covering various functionalities including case creation, updates, and file uploads.
- Introduced a safe HTML sanitizer utility to ensure safe rendering of HTML content in the BMC Hub UI.
- Added database migrations for new features including WAN connection marking for wall outlets, permanent audit trails for supplier invoices, and dedicated permissions for the Sag module.
- Created a migration center for manual subscription and invoice migrations with relevant tables and indexes.
- Added tests for migration center functionalities, ensuring stability and correctness of the new features.
2026-07-28 14:18:24 +02:00

32 lines
1.5 KiB
SQL

-- Permanent audit trail for supplier invoices processed into internet connections.
CREATE TABLE IF NOT EXISTS internet_connections_invoice_sync_runs (
id BIGSERIAL PRIMARY KEY,
file_id INTEGER REFERENCES incoming_files(file_id) ON DELETE SET NULL,
extraction_id INTEGER REFERENCES extractions(extraction_id) ON DELETE SET NULL,
supplier_invoice_id INTEGER REFERENCES supplier_invoices(id) ON DELETE SET NULL,
invoice_number VARCHAR(100),
vendor_name VARCHAR(255),
invoice_date DATE,
status VARCHAR(20) NOT NULL
CHECK (status IN ('success', 'warning', 'skipped', 'error')),
connections_synced INTEGER NOT NULL DEFAULT 0,
connections_created INTEGER NOT NULL DEFAULT 0,
connections_updated INTEGER NOT NULL DEFAULT 0,
ip_ranges_synced INTEGER NOT NULL DEFAULT 0,
total_lines INTEGER NOT NULL DEFAULT 0,
actionable_lines INTEGER NOT NULL DEFAULT 0,
skipped_lines INTEGER NOT NULL DEFAULT 0,
error_message TEXT,
result_json JSONB NOT NULL DEFAULT '{}'::jsonb,
processed_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS idx_internet_invoice_sync_runs_processed
ON internet_connections_invoice_sync_runs(processed_at DESC);
CREATE INDEX IF NOT EXISTS idx_internet_invoice_sync_runs_status
ON internet_connections_invoice_sync_runs(status, processed_at DESC);
CREATE INDEX IF NOT EXISTS idx_internet_invoice_sync_runs_invoice
ON internet_connections_invoice_sync_runs(invoice_number, vendor_name);