stabilize tests
This commit is contained in:
@@ -33,6 +33,9 @@ CREATE INDEX IF NOT EXISTS ix_vex_overrides_vuln
|
||||
CREATE INDEX IF NOT EXISTS ix_vex_overrides_status
|
||||
ON analytics.vex_overrides(status);
|
||||
|
||||
-- Partial index for active overrides. Time-based filtering (valid_until > now())
|
||||
-- cannot be used in index predicates because now() is STABLE, not IMMUTABLE.
|
||||
-- Queries must apply the time filter at runtime.
|
||||
CREATE INDEX IF NOT EXISTS ix_vex_overrides_active
|
||||
ON analytics.vex_overrides(artifact_id, vuln_id)
|
||||
WHERE valid_until IS NULL OR valid_until > now();
|
||||
WHERE valid_until IS NULL;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
CREATE TABLE IF NOT EXISTS analytics.daily_vulnerability_counts (
|
||||
snapshot_date DATE NOT NULL,
|
||||
environment TEXT NOT NULL,
|
||||
team TEXT,
|
||||
team TEXT NOT NULL DEFAULT '',
|
||||
severity analytics_severity NOT NULL,
|
||||
total_vulns INT NOT NULL,
|
||||
fixable_vulns INT NOT NULL,
|
||||
@@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS analytics.daily_vulnerability_counts (
|
||||
affected_artifacts INT NOT NULL,
|
||||
affected_components INT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (snapshot_date, environment, COALESCE(team, ''), severity)
|
||||
PRIMARY KEY (snapshot_date, environment, team, severity)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS ix_daily_vuln_counts_date
|
||||
@@ -28,13 +28,13 @@ CREATE INDEX IF NOT EXISTS ix_daily_vuln_counts_env
|
||||
CREATE TABLE IF NOT EXISTS analytics.daily_component_counts (
|
||||
snapshot_date DATE NOT NULL,
|
||||
environment TEXT NOT NULL,
|
||||
team TEXT,
|
||||
team TEXT NOT NULL DEFAULT '',
|
||||
license_category analytics_license_category NOT NULL,
|
||||
component_type analytics_component_type NOT NULL,
|
||||
total_components INT NOT NULL,
|
||||
unique_suppliers INT NOT NULL,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
|
||||
PRIMARY KEY (snapshot_date, environment, COALESCE(team, ''), license_category, component_type)
|
||||
PRIMARY KEY (snapshot_date, environment, team, license_category, component_type)
|
||||
);
|
||||
|
||||
CREATE INDEX IF NOT EXISTS ix_daily_comp_counts_date
|
||||
@@ -51,7 +51,7 @@ BEGIN
|
||||
SELECT
|
||||
p_date,
|
||||
a.environment,
|
||||
a.team,
|
||||
COALESCE(a.team, '') AS team,
|
||||
cv.severity,
|
||||
COUNT(*) AS total_vulns,
|
||||
COUNT(*) FILTER (WHERE cv.fix_available = TRUE) AS fixable_vulns,
|
||||
@@ -68,7 +68,7 @@ BEGIN
|
||||
JOIN analytics.artifact_components ac ON ac.artifact_id = a.artifact_id
|
||||
JOIN analytics.component_vulns cv ON cv.component_id = ac.component_id AND cv.affects = TRUE
|
||||
GROUP BY a.environment, a.team, cv.severity
|
||||
ON CONFLICT (snapshot_date, environment, COALESCE(team, ''), severity)
|
||||
ON CONFLICT (snapshot_date, environment, team, severity)
|
||||
DO UPDATE SET
|
||||
total_vulns = EXCLUDED.total_vulns,
|
||||
fixable_vulns = EXCLUDED.fixable_vulns,
|
||||
@@ -86,7 +86,7 @@ BEGIN
|
||||
SELECT
|
||||
p_date,
|
||||
a.environment,
|
||||
a.team,
|
||||
COALESCE(a.team, '') AS team,
|
||||
c.license_category,
|
||||
c.component_type,
|
||||
COUNT(DISTINCT c.component_id) AS total_components,
|
||||
@@ -95,7 +95,7 @@ BEGIN
|
||||
JOIN analytics.artifact_components ac ON ac.artifact_id = a.artifact_id
|
||||
JOIN analytics.components c ON c.component_id = ac.component_id
|
||||
GROUP BY a.environment, a.team, c.license_category, c.component_type
|
||||
ON CONFLICT (snapshot_date, environment, COALESCE(team, ''), license_category, component_type)
|
||||
ON CONFLICT (snapshot_date, environment, team, license_category, component_type)
|
||||
DO UPDATE SET
|
||||
total_components = EXCLUDED.total_components,
|
||||
unique_suppliers = EXCLUDED.unique_suppliers,
|
||||
|
||||
@@ -13,7 +13,7 @@ BEGIN
|
||||
SELECT
|
||||
p_date,
|
||||
a.environment,
|
||||
a.team,
|
||||
COALESCE(a.team, '') AS team,
|
||||
cv.severity,
|
||||
COUNT(*) AS total_vulns,
|
||||
COUNT(*) FILTER (WHERE cv.fix_available = TRUE) AS fixable_vulns,
|
||||
@@ -30,7 +30,7 @@ BEGIN
|
||||
JOIN analytics.artifact_components ac ON ac.artifact_id = a.artifact_id
|
||||
JOIN analytics.component_vulns cv ON cv.component_id = ac.component_id AND cv.affects = TRUE
|
||||
GROUP BY a.environment, a.team, cv.severity
|
||||
ON CONFLICT (snapshot_date, environment, COALESCE(team, ''), severity)
|
||||
ON CONFLICT (snapshot_date, environment, team, severity)
|
||||
DO UPDATE SET
|
||||
total_vulns = EXCLUDED.total_vulns,
|
||||
fixable_vulns = EXCLUDED.fixable_vulns,
|
||||
@@ -48,7 +48,7 @@ BEGIN
|
||||
SELECT
|
||||
p_date,
|
||||
a.environment,
|
||||
a.team,
|
||||
COALESCE(a.team, '') AS team,
|
||||
c.license_category,
|
||||
c.component_type,
|
||||
COUNT(DISTINCT c.component_id) AS total_components,
|
||||
@@ -57,7 +57,7 @@ BEGIN
|
||||
JOIN analytics.artifact_components ac ON ac.artifact_id = a.artifact_id
|
||||
JOIN analytics.components c ON c.component_id = ac.component_id
|
||||
GROUP BY a.environment, a.team, c.license_category, c.component_type
|
||||
ON CONFLICT (snapshot_date, environment, COALESCE(team, ''), license_category, component_type)
|
||||
ON CONFLICT (snapshot_date, environment, team, license_category, component_type)
|
||||
DO UPDATE SET
|
||||
total_components = EXCLUDED.total_components,
|
||||
unique_suppliers = EXCLUDED.unique_suppliers,
|
||||
|
||||
@@ -13,7 +13,7 @@ BEGIN
|
||||
SELECT
|
||||
p_date,
|
||||
a.environment,
|
||||
a.team,
|
||||
COALESCE(a.team, '') AS team,
|
||||
cv.severity,
|
||||
COUNT(*) AS total_vulns,
|
||||
COUNT(*) FILTER (WHERE cv.fix_available = TRUE) AS fixable_vulns,
|
||||
@@ -33,7 +33,7 @@ BEGIN
|
||||
JOIN analytics.artifact_components ac ON ac.artifact_id = a.artifact_id
|
||||
JOIN analytics.component_vulns cv ON cv.component_id = ac.component_id AND cv.affects = TRUE
|
||||
GROUP BY a.environment, a.team, cv.severity
|
||||
ON CONFLICT (snapshot_date, environment, COALESCE(team, ''), severity)
|
||||
ON CONFLICT (snapshot_date, environment, team, severity)
|
||||
DO UPDATE SET
|
||||
total_vulns = EXCLUDED.total_vulns,
|
||||
fixable_vulns = EXCLUDED.fixable_vulns,
|
||||
@@ -51,7 +51,7 @@ BEGIN
|
||||
SELECT
|
||||
p_date,
|
||||
a.environment,
|
||||
a.team,
|
||||
COALESCE(a.team, '') AS team,
|
||||
c.license_category,
|
||||
c.component_type,
|
||||
COUNT(DISTINCT c.component_id) AS total_components,
|
||||
@@ -60,7 +60,7 @@ BEGIN
|
||||
JOIN analytics.artifact_components ac ON ac.artifact_id = a.artifact_id
|
||||
JOIN analytics.components c ON c.component_id = ac.component_id
|
||||
GROUP BY a.environment, a.team, c.license_category, c.component_type
|
||||
ON CONFLICT (snapshot_date, environment, COALESCE(team, ''), license_category, component_type)
|
||||
ON CONFLICT (snapshot_date, environment, team, license_category, component_type)
|
||||
DO UPDATE SET
|
||||
total_components = EXCLUDED.total_components,
|
||||
unique_suppliers = EXCLUDED.unique_suppliers,
|
||||
|
||||
@@ -4,5 +4,8 @@
|
||||
|
||||
DROP INDEX IF EXISTS ix_vex_overrides_active;
|
||||
|
||||
-- Partial index for active overrides: valid_until IS NULL means indefinitely active.
|
||||
-- Time-based filtering (valid_from <= now()) cannot be used in index predicates because
|
||||
-- now() is STABLE, not IMMUTABLE. Queries should apply the time filter at runtime.
|
||||
CREATE INDEX IF NOT EXISTS ix_vex_overrides_active ON analytics.vex_overrides (artifact_id, vuln_id)
|
||||
WHERE valid_from <= now() AND (valid_until IS NULL OR valid_until > now());
|
||||
WHERE valid_until IS NULL;
|
||||
|
||||
@@ -48,6 +48,9 @@ CREATE UNIQUE INDEX IF NOT EXISTS ix_mv_license_distribution_license
|
||||
CREATE INDEX IF NOT EXISTS ix_mv_license_distribution_component_count
|
||||
ON analytics.mv_license_distribution (component_count DESC);
|
||||
|
||||
-- Drop the old 1-parameter overload from migration 023 to avoid ambiguous calls.
|
||||
DROP FUNCTION IF EXISTS analytics.sp_top_suppliers(INT);
|
||||
|
||||
CREATE OR REPLACE FUNCTION analytics.sp_top_suppliers(
|
||||
p_limit INT DEFAULT 20,
|
||||
p_environment TEXT DEFAULT NULL
|
||||
@@ -101,6 +104,9 @@ BEGIN
|
||||
END;
|
||||
$$ LANGUAGE plpgsql STABLE;
|
||||
|
||||
-- Drop the old 0-parameter overload from migration 023 to avoid ambiguous calls.
|
||||
DROP FUNCTION IF EXISTS analytics.sp_license_heatmap();
|
||||
|
||||
CREATE OR REPLACE FUNCTION analytics.sp_license_heatmap(p_environment TEXT DEFAULT NULL)
|
||||
RETURNS JSON AS $$
|
||||
DECLARE
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
namespace StellaOps.Platform.Database;
|
||||
|
||||
using System.Reflection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using StellaOps.Infrastructure.Postgres.Migrations;
|
||||
using System.Reflection;
|
||||
|
||||
namespace StellaOps.Platform.Database;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Migration runner for the Release Orchestrator schema.
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
namespace StellaOps.Platform.Database;
|
||||
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace StellaOps.Platform.Database;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for registering Release Orchestrator database services.
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# StellaOps.Platform.Database Task Board
|
||||
This board mirrors active sprint tasks for this module.
|
||||
Source of truth: `docs/implplan/SPRINT_20260130_002_Tools_csproj_remediation_solid_review.md`.
|
||||
|
||||
| Task ID | Status | Notes |
|
||||
| --- | --- | --- |
|
||||
| REMED-05 | TODO | Remediation checklist: docs/implplan/audits/csproj-standards/remediation/checklists/src/Platform/__Libraries/StellaOps.Platform.Database/StellaOps.Platform.Database.md. |
|
||||
| REMED-06 | DONE | SOLID review notes captured for SPRINT_20260130_002. |
|
||||
Reference in New Issue
Block a user