83 lines
3.3 KiB
SQL
83 lines
3.3 KiB
SQL
-- ==========================================================
|
|
-- Marketing Engine & Social Media Bot Combined Schema
|
|
-- ==========================================================
|
|
|
|
-- 1. Original Social Media Tables (Facebook, Instagram)
|
|
CREATE TABLE IF NOT EXISTS `social_accounts` (
|
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
|
`platform` ENUM('facebook', 'instagram', 'tiktok', 'twitter', 'youtube') NOT NULL,
|
|
`username` VARCHAR(100) NOT NULL,
|
|
`status` ENUM('active', 'restricted', 'banned') DEFAULT 'active',
|
|
`total_posts` INT DEFAULT 0,
|
|
`total_comments` INT DEFAULT 0,
|
|
`total_videos` INT DEFAULT 0,
|
|
`proxy_ip` VARCHAR(100) NULL,
|
|
`proxy_port` INT NULL,
|
|
`proxy_username` VARCHAR(100) NULL,
|
|
`proxy_password` VARCHAR(100) NULL,
|
|
`last_active` DATETIME NULL,
|
|
`created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
`updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS `social_tasks` (
|
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
|
`account_id` INT NULL,
|
|
`platform` ENUM('facebook', 'instagram', 'tiktok', 'twitter', 'youtube') NOT NULL,
|
|
`type` ENUM('join_group', 'read_posts', 'post_comment', 'share_link', 'upload_video', 'post_tweet') NOT NULL,
|
|
`target_url` VARCHAR(500) NULL, -- URL of the group, post, or media download
|
|
`prompt_context` TEXT NULL,
|
|
`generated_comment` TEXT NULL,
|
|
`status` ENUM('pending', 'in_progress', 'completed', 'failed') DEFAULT 'pending',
|
|
`error_message` TEXT NULL,
|
|
`scheduled_at` DATETIME NULL,
|
|
`completed_at` DATETIME NULL,
|
|
`created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (`account_id`) REFERENCES `social_accounts`(`id`) ON DELETE SET NULL
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS `social_logs` (
|
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
|
`task_id` INT NULL,
|
|
`account_id` INT NULL,
|
|
`log_level` ENUM('info', 'warning', 'error') DEFAULT 'info',
|
|
`message` TEXT NOT NULL,
|
|
`created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (`task_id`) REFERENCES `social_tasks`(`id`) ON DELETE SET NULL,
|
|
FOREIGN KEY (`account_id`) REFERENCES `social_accounts`(`id`) ON DELETE SET NULL
|
|
);
|
|
|
|
-- 2. New Content Generation Pipeline Tables
|
|
CREATE TABLE IF NOT EXISTS `content_pipeline` (
|
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
|
`topic` VARCHAR(255) NOT NULL,
|
|
`script_text` TEXT NULL,
|
|
`voice_url` VARCHAR(500) NULL,
|
|
`video_url` VARCHAR(500) NULL,
|
|
`status` ENUM('pending', 'script_generated', 'voice_generated', 'video_rendered', 'published', 'failed') DEFAULT 'pending',
|
|
`error_message` TEXT NULL,
|
|
`created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
|
|
`updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS `api_quotas` (
|
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
|
`service_name` ENUM('gemini', 'elevenlabs', 'creatomate', 'heygen') NOT NULL,
|
|
`daily_usage` INT DEFAULT 0,
|
|
`quota_limit` INT DEFAULT 10,
|
|
`last_reset` DATE NOT NULL
|
|
);
|
|
|
|
INSERT IGNORE INTO `api_quotas` (`service_name`, `daily_usage`, `quota_limit`, `last_reset`) VALUES
|
|
('gemini', 0, 100, CURDATE()),
|
|
('elevenlabs', 0, 5, CURDATE()),
|
|
('creatomate', 0, 2, CURDATE());
|
|
|
|
CREATE TABLE IF NOT EXISTS marketing_reports (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
platform ENUM('facebook', 'instagram', 'tiktok', 'twitter', 'youtube', 'all') NOT NULL,
|
|
report_html TEXT NOT NULL,
|
|
is_weekly TINYINT(1) DEFAULT 0,
|
|
created_at DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
);
|