-- Create social_media_campaigns table
CREATE TABLE IF NOT EXISTS `social_media_campaigns` (
  `id` int AUTO_INCREMENT NOT NULL PRIMARY KEY,
  `createdBy` int NOT NULL,
  `campaignName` varchar(255) NOT NULL,
  `description` text,
  `targetPlatforms` json NOT NULL,
  `postingFrequency` enum('daily','weekly','bi_weekly','monthly') DEFAULT 'weekly',
  `status` enum('draft','scheduled','active','paused','completed') DEFAULT 'draft',
  `startDate` timestamp,
  `endDate` timestamp,
  `totalPostsPlanned` int DEFAULT 0,
  `totalPostsPublished` int DEFAULT 0,
  `totalImpressions` int DEFAULT 0,
  `totalEngagement` int DEFAULT 0,
  `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  INDEX `idx_social_campaigns_createdBy` (`createdBy`),
  INDEX `idx_social_campaigns_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Create social_media_posts table
CREATE TABLE IF NOT EXISTS `social_media_posts` (
  `id` int AUTO_INCREMENT NOT NULL PRIMARY KEY,
  `campaignId` int NOT NULL,
  `platform` enum('twitter','instagram','tiktok','facebook') NOT NULL,
  `caption` text NOT NULL,
  `imageUrl` text,
  `videoUrl` text,
  `hashtags` text,
  `mentions` text,
  `callToAction` varchar(255),
  `status` enum('draft','scheduled','published','failed') DEFAULT 'draft',
  `scheduledAt` timestamp,
  `publishedAt` timestamp,
  `impressions` int DEFAULT 0,
  `clicks` int DEFAULT 0,
  `likes` int DEFAULT 0,
  `shares` int DEFAULT 0,
  `comments` int DEFAULT 0,
  `postUrl` text,
  `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  INDEX `idx_social_posts_campaignId` (`campaignId`),
  INDEX `idx_social_posts_platform` (`platform`),
  INDEX `idx_social_posts_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Create ai_game_builder_configs table
CREATE TABLE IF NOT EXISTS `ai_game_builder_configs` (
  `id` int AUTO_INCREMENT NOT NULL PRIMARY KEY,
  `createdBy` int NOT NULL,
  `gameType` enum('slot','card','dice','puzzle','roulette','bingo','scratch') NOT NULL,
  `gameName` varchar(255) NOT NULL,
  `description` text,
  `theme` varchar(100),
  `difficulty` enum('easy','medium','hard') DEFAULT 'medium',
  `rtp` decimal(5,2) DEFAULT '96',
  `volatility` enum('low','medium','high') DEFAULT 'medium',
  `maxWin` int,
  `minBet` decimal(10,2),
  `maxBet` decimal(10,2),
  `gameRules` json,
  `gameMechanics` json,
  `bonusFeatures` json,
  `status` enum('draft','review','approved','published','archived') DEFAULT 'draft',
  `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `updatedAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  INDEX `idx_game_configs_createdBy` (`createdBy`),
  INDEX `idx_game_configs_status` (`status`),
  INDEX `idx_game_configs_gameType` (`gameType`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
