-- DBAOps Enterprise™ - config.NotificationRecipients Table
-- Run this in DBAOpsRepository before CreateAllJobs.sql to use config-based recipients
-- Optional: Jobs use 'dbaops@yourdomain.com' placeholder if this table is empty

USE DBAOpsRepository;
GO

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

IF NOT EXISTS (SELECT 1 FROM sys.tables t JOIN sys.schemas s ON t.schema_id = s.schema_id WHERE s.name = 'config' AND t.name = 'NotificationRecipients')
BEGIN
    CREATE TABLE config.NotificationRecipients (
        RecipientID INT IDENTITY(1,1) PRIMARY KEY,
        EmailAddress NVARCHAR(255) NOT NULL,
        DisplayName NVARCHAR(128) NULL,
        IsActive BIT NOT NULL DEFAULT 1,
        CreatedAt DATETIME2 NOT NULL DEFAULT GETDATE()
    );
    INSERT INTO config.NotificationRecipients (EmailAddress, DisplayName) VALUES ('dbaops@yourdomain.com', 'DBAOps Alerts');
END
GO
