-- DBAOps Sovereign™ — v17 Repair: ctl.Alerts when base schema.sql (v1) was skipped
-- Same class of issue as v14/v15: ctl.Servers existed so v1 ran only partially or Alerts was never applied.

IF OBJECT_ID(N'ctl.Alerts', N'U') IS NULL
BEGIN
    CREATE TABLE ctl.Alerts (
        AlertId         UNIQUEIDENTIFIER DEFAULT NEWID() PRIMARY KEY,
        ServerId        UNIQUEIDENTIFIER NOT NULL,
        Severity        NVARCHAR(32) NOT NULL,
        Message         NVARCHAR(MAX),
        Source          NVARCHAR(64) NULL,
        CreatedAt       DATETIME2 DEFAULT SYSUTCDATETIME(),
        AcknowledgedAt  DATETIME2 NULL,
        CONSTRAINT FK_Alerts_Server FOREIGN KEY (ServerId) REFERENCES ctl.Servers(ServerId)
    );
END
GO
