-- =============================================
-- Repsly API Integration - Add RequestPayload Column
-- Created: 2025-01-XX
-- Purpose: Add RequestPayload column to store JSON payload sent to Repsly API
--          This is useful for debugging and auditing
-- =============================================

USE [Superbowl]
GO

-- =============================================
-- Add RequestPayload to sysCronJobProducts (if not exists)
-- =============================================
IF NOT EXISTS (SELECT * FROM sys.columns 
               WHERE object_id = OBJECT_ID(N'[dbo].[sysCronJobProducts]') 
               AND name = 'RequestPayload')
BEGIN
    ALTER TABLE [dbo].[sysCronJobProducts]
    ADD [RequestPayload] [nvarchar](max) NULL
    
    PRINT 'Field RequestPayload added to sysCronJobProducts successfully'
END
ELSE
BEGIN
    PRINT 'Field RequestPayload already exists in sysCronJobProducts'
END
GO

-- =============================================
-- Add RequestPayload to sysCronJobPromotions (if not exists)
-- =============================================
IF NOT EXISTS (SELECT * FROM sys.columns 
               WHERE object_id = OBJECT_ID(N'[dbo].[sysCronJobPromotions]') 
               AND name = 'RequestPayload')
BEGIN
    ALTER TABLE [dbo].[sysCronJobPromotions]
    ADD [RequestPayload] [nvarchar](max) NULL
    
    PRINT 'Field RequestPayload added to sysCronJobPromotions successfully'
END
ELSE
BEGIN
    PRINT 'Field RequestPayload already exists in sysCronJobPromotions'
END
GO

PRINT 'RequestPayload column addition script completed'
GO

