-- DBAOps Sovereign™ — v15 Repair: comp.ComplianceScores when base schema.sql was skipped
-- Same class of issue as v14: ctl.Servers existed so v1 was skipped and comp.* was never created.

IF NOT EXISTS (SELECT 1 FROM sys.schemas WHERE name = N'comp')
    EXEC('CREATE SCHEMA comp');
GO

IF OBJECT_ID(N'comp.ComplianceScores', N'U') IS NULL
BEGIN
    CREATE TABLE comp.ComplianceScores (
        ComplianceId    UNIQUEIDENTIFIER DEFAULT NEWID() PRIMARY KEY,
        ServerId        UNIQUEIDENTIFIER NOT NULL REFERENCES ctl.Servers(ServerId),
        Framework       NVARCHAR(64) NOT NULL,
        Score           INT CHECK (Score >= 0 AND Score <= 100),
        Status          NVARCHAR(32),
        LastScan        DATETIME2,
        CONSTRAINT FK_Compliance_Server FOREIGN KEY (ServerId) REFERENCES ctl.Servers(ServerId)
    );
END
GO
