-- MetaApp Database Export for MySQL (cPanel)
-- Generated: 2026-03-24
-- Converted from SQLite to MySQL format

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";

-- -------------------------------
-- Table: users
-- -------------------------------

DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `email_verified_at` timestamp NULL DEFAULT NULL,
  `password` varchar(255) NOT NULL,
  `remember_token` varchar(100) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `users_email_unique` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `users` (`id`, `name`, `email`, `email_verified_at`, `password`, `remember_token`, `created_at`, `updated_at`) VALUES
(1, 'Admin', 'admin@gmail.com', NULL, '$2y$10$UIxgOCJmYjnHSWNbh9PgPeT7GQpL89MiX.uZ/z6L8ocg5.BsmkkT2', NULL, '2026-03-23 09:37:36', '2026-03-23 09:37:36');

-- -------------------------------
-- Table: password_reset_tokens
-- -------------------------------

DROP TABLE IF EXISTS `password_reset_tokens`;
CREATE TABLE `password_reset_tokens` (
  `email` varchar(255) NOT NULL,
  `token` varchar(255) NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- -------------------------------
-- Table: personal_access_tokens
-- -------------------------------

DROP TABLE IF EXISTS `personal_access_tokens`;
CREATE TABLE `personal_access_tokens` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `tokenable_type` varchar(255) NOT NULL,
  `tokenable_id` bigint unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  `token` varchar(64) NOT NULL,
  `abilities` text DEFAULT NULL,
  `last_used_at` timestamp NULL DEFAULT NULL,
  `expires_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `personal_access_tokens_token_unique` (`token`),
  KEY `personal_access_tokens_tokenable_type_tokenable_id_index` (`tokenable_type`,`tokenable_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- -------------------------------
-- Table: failed_jobs
-- -------------------------------

DROP TABLE IF EXISTS `failed_jobs`;
CREATE TABLE `failed_jobs` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `uuid` varchar(255) NOT NULL,
  `connection` text NOT NULL,
  `queue` text NOT NULL,
  `payload` longtext NOT NULL,
  `exception` longtext NOT NULL,
  `failed_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- -------------------------------
-- Table: migrations
-- -------------------------------

DROP TABLE IF EXISTS `migrations`;
CREATE TABLE `migrations` (
  `id` int unsigned NOT NULL AUTO_INCREMENT,
  `migration` varchar(255) NOT NULL,
  `batch` int NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
(1, '2014_10_12_000000_create_users_table', 1),
(2, '2014_10_12_100000_create_password_reset_tokens_table', 1),
(3, '2019_08_19_000000_create_failed_jobs_table', 1),
(4, '2019_12_14_000001_create_personal_access_tokens_table', 1),
(5, '2024_01_01_000001_create_companies_table', 1),
(6, '2024_01_01_000002_create_campaigns_table', 1),
(7, '2024_01_01_000003_create_daily_budgets_table', 1),
(8, '2024_01_01_000004_create_leads_table', 1),
(9, '2024_01_01_000005_create_lead_followups_table', 1),
(10, '2024_03_12_000001_add_meta_fields', 1),
(11, '2024_03_12_000002_add_more_insights_fields', 1);

-- -------------------------------
-- Table: companies
-- -------------------------------

DROP TABLE IF EXISTS `companies`;
CREATE TABLE `companies` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `contact_person` varchar(255) NOT NULL,
  `phone` varchar(255) NOT NULL,
  `email` varchar(255) NOT NULL,
  `business_type` varchar(255) DEFAULT NULL,
  `notes` text DEFAULT NULL,
  `status` enum('Active','Inactive') NOT NULL DEFAULT 'Active',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `companies` (`id`, `name`, `contact_person`, `phone`, `email`, `business_type`, `notes`, `status`, `created_at`, `updated_at`) VALUES
(1, 'Imported from Meta', 'Auto Import', '', '', 'Auto Import', 'Created automatically from Meta API import', 'Active', '2026-03-23 09:46:16', '2026-03-23 09:46:16');

-- -------------------------------
-- Table: campaigns
-- -------------------------------

DROP TABLE IF EXISTS `campaigns`;
CREATE TABLE `campaigns` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `company_id` bigint unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  `platform` enum('Facebook','Instagram','Google','LinkedIn') NOT NULL,
  `objective` enum('Leads','Traffic','Sales') NOT NULL,
  `start_date` date NOT NULL,
  `end_date` date DEFAULT NULL,
  `total_budget` decimal(15,2) NOT NULL DEFAULT '0.00',
  `daily_budget` decimal(15,2) NOT NULL DEFAULT '0.00',
  `status` enum('Running','Paused','Completed') NOT NULL DEFAULT 'Running',
  `notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `meta_campaign_id` varchar(255) DEFAULT NULL,
  `auto_sync` tinyint(1) NOT NULL DEFAULT '0',
  `last_synced_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `campaigns_company_id_foreign` (`company_id`),
  CONSTRAINT `campaigns_company_id_foreign` FOREIGN KEY (`company_id`) REFERENCES `companies` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `campaigns` (`id`, `company_id`, `name`, `platform`, `objective`, `start_date`, `end_date`, `total_budget`, `daily_budget`, `status`, `notes`, `created_at`, `updated_at`, `meta_campaign_id`, `auto_sync`, `last_synced_at`) VALUES
(1, 1, 'CRM Application Reel 17-03', 'Facebook', 'Leads', '2026-03-17', NULL, '0.00', '37000.00', 'Running', 'Imported from Meta Ads Manager', '2026-03-23 09:47:49', '2026-03-24 08:44:56', '120244984347810483', 1, '2026-03-24 08:44:56'),
(2, 1, 'Website Development insta - 02-02', 'Facebook', 'Leads', '2026-02-02', NULL, '0.00', '45000.00', 'Paused', 'Imported from Meta Ads Manager', '2026-03-23 09:47:49', '2026-03-24 08:44:58', '120242829307020483', 1, '2026-03-24 08:44:58'),
(3, 1, 'Web reel 26-01', 'Facebook', 'Leads', '2026-01-26', NULL, '0.00', '45000.00', 'Paused', 'Imported from Meta Ads Manager', '2026-03-23 09:47:49', '2026-03-24 08:45:01', '120242515372870483', 1, '2026-03-24 08:45:01'),
(4, 1, 'Reel Web development', 'Facebook', 'Leads', '2026-01-25', NULL, '0.00', '0.00', 'Paused', 'Imported from Meta Ads Manager', '2026-03-23 09:47:49', '2026-03-24 08:45:02', '120242486561630483', 1, '2026-03-24 08:45:02'),
(5, 1, 'Website Develoment - WhataApp', 'Facebook', 'Traffic', '2025-06-23', NULL, '0.00', '0.00', 'Paused', 'Imported from Meta Ads Manager', '2026-03-23 09:47:49', '2026-03-24 08:45:04', '120229969216260483', 1, '2026-03-24 08:45:04'),
(6, 1, 'Website development Service -AD (17-06-2025)', 'Facebook', 'Leads', '2025-06-18', NULL, '0.00', '0.00', 'Paused', 'Imported from Meta Ads Manager', '2026-03-23 09:47:49', '2026-03-24 08:45:06', '120229576875770483', 1, '2026-03-24 08:45:06'),
(7, 1, 'AC Service App 20-05', 'Facebook', 'Leads', '2025-05-30', NULL, '0.00', '0.00', 'Paused', 'Imported from Meta Ads Manager', '2026-03-23 09:47:49', '2026-03-24 08:45:08', '120228273171510483', 1, '2026-03-24 08:45:08'),
(8, 1, 'Plumbing application 29-05-2025', 'Facebook', 'Leads', '2025-05-29', NULL, '0.00', '0.00', 'Paused', 'Imported from Meta Ads Manager', '2026-03-23 09:47:49', '2026-03-24 08:45:10', '120228243294480483', 1, '2026-03-24 08:45:10'),
(9, 1, 'APP Development Service - May 29', 'Facebook', 'Leads', '2025-05-29', NULL, '0.00', '0.00', 'Paused', 'Imported from Meta Ads Manager', '2026-03-23 09:47:49', '2026-03-24 08:45:12', '120228220821700483', 1, '2026-03-24 08:45:12'),
(10, 1, 'IT Campaign 29-04', 'Facebook', 'Leads', '2025-04-29', NULL, '0.00', '0.00', 'Paused', 'Imported from Meta Ads Manager', '2026-03-23 09:47:49', '2026-03-24 08:45:14', '120225839741400483', 1, '2026-03-24 08:45:14'),
(11, 1, 'App Development 26-04-25', 'Facebook', 'Leads', '2025-04-28', NULL, '0.00', '0.00', 'Paused', 'Imported from Meta Ads Manager', '2026-03-23 09:47:49', '2026-03-24 08:45:16', '120225559107050483', 1, '2026-03-24 08:45:16');

-- -------------------------------
-- Table: daily_budgets
-- -------------------------------

DROP TABLE IF EXISTS `daily_budgets`;
CREATE TABLE `daily_budgets` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `campaign_id` bigint unsigned NOT NULL,
  `date` date NOT NULL,
  `daily_budget` decimal(15,2) NOT NULL DEFAULT '0.00',
  `amount_spent` decimal(15,2) NOT NULL DEFAULT '0.00',
  `remaining_budget` decimal(15,2) NOT NULL DEFAULT '0.00',
  `notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `impressions` int NOT NULL DEFAULT '0',
  `clicks` int NOT NULL DEFAULT '0',
  `cpm` decimal(10,4) DEFAULT NULL,
  `cpc` decimal(10,4) DEFAULT NULL,
  `ctr` decimal(10,4) DEFAULT NULL,
  `reach` int DEFAULT NULL,
  `frequency` decimal(10,4) DEFAULT NULL,
  `conversions` int NOT NULL DEFAULT '0',
  `video_views` int NOT NULL DEFAULT '0',
  `engagements` int NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `daily_budgets_campaign_id_foreign` (`campaign_id`),
  CONSTRAINT `daily_budgets_campaign_id_foreign` FOREIGN KEY (`campaign_id`) REFERENCES `campaigns` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `daily_budgets` (`id`, `campaign_id`, `date`, `daily_budget`, `amount_spent`, `remaining_budget`, `notes`, `created_at`, `updated_at`, `impressions`, `clicks`, `cpm`, `cpc`, `ctr`, `reach`, `frequency`, `conversions`, `video_views`, `engagements`) VALUES
(1, 1, '2026-03-18', '370.00', '381.45', '-11.45', NULL, '2026-03-23 09:53:41', '2026-03-23 09:53:41', 1853, 25, 205.8554, 15.2580, 1.3492, 1693, 1.0945, 0, 0, 0),
(2, 1, '2026-03-19', '370.00', '235.78', '134.22', NULL, '2026-03-23 09:53:41', '2026-03-23 09:53:41', 487, 8, 484.1478, 29.4725, 1.6427, 440, 1.1068, 0, 0, 0),
(3, 1, '2026-03-20', '370.00', '1.42', '368.58', NULL, '2026-03-23 09:53:41', '2026-03-23 09:53:41', 54, 1, 26.2963, 1.4200, 1.8519, 54, 1.0000, 0, 0, 0),
(4, 1, '2026-03-21', '370.00', '625.66', '-255.66', NULL, '2026-03-23 09:53:41', '2026-03-23 09:53:41', 25061, 110, 24.9655, 5.6878, 0.4389, 21853, 1.1468, 0, 0, 0),
(5, 1, '2026-03-22', '370.00', '9.92', '360.08', NULL, '2026-03-23 09:53:41', '2026-03-23 09:53:41', 228, 0, 43.5088, 0.0000, 0.0000, 223, 1.0224, 0, 0, 0);

-- -------------------------------
-- Table: leads
-- -------------------------------

DROP TABLE IF EXISTS `leads`;
CREATE TABLE `leads` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `campaign_id` bigint unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  `phone` varchar(255) NOT NULL,
  `email` varchar(255) DEFAULT NULL,
  `city` varchar(255) DEFAULT NULL,
  `date_received` date NOT NULL,
  `status` enum('New','Contacted','Interested','Not Interested','Converted') NOT NULL DEFAULT 'New',
  `notes` text DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `meta_lead_id` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `leads_campaign_id_foreign` (`campaign_id`),
  CONSTRAINT `leads_campaign_id_foreign` FOREIGN KEY (`campaign_id`) REFERENCES `campaigns` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

INSERT INTO `leads` (`id`, `campaign_id`, `name`, `phone`, `email`, `city`, `date_received`, `status`, `notes`, `created_at`, `updated_at`, `meta_lead_id`) VALUES
(37, 1, 'Meta Lead 1', '', '', '', '2026-03-22', 'New', 'Synced from Meta WhatsApp Conversations', '2026-03-23 11:10:06', '2026-03-23 11:10:06', NULL),
(38, 1, 'Meta Lead 2', '', '', '', '2026-03-22', 'New', 'Synced from Meta WhatsApp Conversations', '2026-03-23 11:10:06', '2026-03-23 11:10:06', NULL),
(39, 1, 'Meta Lead 3', '', '', '', '2026-03-21', 'New', 'Synced from Meta WhatsApp Conversations', '2026-03-23 11:10:06', '2026-03-23 11:10:06', NULL),
(40, 1, 'Meta Lead 4', '', '', '', '2026-03-18', 'New', 'Synced from Meta WhatsApp Conversations', '2026-03-23 11:10:06', '2026-03-23 11:10:06', NULL),
(41, 1, 'Meta Lead 5', '', '', '', '2026-03-18', 'New', 'Synced from Meta WhatsApp Conversations', '2026-03-23 11:10:06', '2026-03-23 11:10:06', NULL),
(42, 1, 'Meta Lead 6', '', '', '', '2026-03-16', 'New', 'Synced from Meta WhatsApp Conversations', '2026-03-23 11:10:06', '2026-03-23 11:10:06', NULL),
(43, 1, 'Meta Lead 7', '', '', '', '2026-03-21', 'New', 'Synced from Meta WhatsApp Conversations', '2026-03-23 11:10:06', '2026-03-23 11:10:06', NULL),
(44, 1, 'Meta Lead 8', '', '', '', '2026-03-18', 'New', 'Synced from Meta WhatsApp Conversations', '2026-03-23 11:10:06', '2026-03-23 11:10:06', NULL),
(45, 1, 'Meta Lead 9', '', '', '', '2026-03-17', 'New', 'Synced from Meta WhatsApp Conversations', '2026-03-23 11:10:06', '2026-03-23 11:10:06', NULL),
(46, 1, 'Meta Lead 10', '', '', '', '2026-03-21', 'New', 'Synced from Meta WhatsApp Conversations', '2026-03-23 11:10:06', '2026-03-23 11:10:06', NULL),
(47, 1, 'Meta Lead 11', '', '', '', '2026-03-21', 'New', 'Synced from Meta WhatsApp Conversations', '2026-03-23 11:10:06', '2026-03-23 11:10:06', NULL),
(48, 1, 'Meta Lead 12', '', '', '', '2026-03-17', 'New', 'Synced from Meta WhatsApp Conversations', '2026-03-23 11:10:06', '2026-03-23 11:10:06', NULL),
(49, 1, 'Meta Lead 13', '', '', '', '2026-03-19', 'New', 'Synced from Meta WhatsApp Conversations', '2026-03-23 11:10:06', '2026-03-23 11:10:06', NULL),
(50, 1, 'Meta Lead 14', '', '', '', '2026-03-17', 'New', 'Synced from Meta WhatsApp Conversations', '2026-03-23 11:10:06', '2026-03-23 11:10:06', NULL),
(51, 1, 'Meta Lead 15', '', '', '', '2026-03-23', 'New', 'Synced from Meta WhatsApp Conversations', '2026-03-23 11:10:06', '2026-03-23 11:10:06', NULL),
(52, 1, 'Meta Lead 16', '', '', '', '2026-03-23', 'New', 'Synced from Meta WhatsApp Conversations', '2026-03-23 11:10:06', '2026-03-23 11:10:06', NULL),
(53, 1, 'Meta Lead 17', '', '', '', '2026-03-18', 'New', 'Synced from Meta WhatsApp Conversations', '2026-03-23 11:10:06', '2026-03-23 11:10:06', NULL),
(54, 1, 'Meta Lead 18', '', '', '', '2026-03-23', 'New', 'Synced from Meta WhatsApp Conversations', '2026-03-23 11:10:06', '2026-03-23 11:10:06', NULL);

-- -------------------------------
-- Table: lead_followups
-- -------------------------------

DROP TABLE IF EXISTS `lead_followups`;
CREATE TABLE `lead_followups` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `lead_id` bigint unsigned NOT NULL,
  `followup_date` date NOT NULL,
  `followup_notes` text DEFAULT NULL,
  `next_followup_date` date DEFAULT NULL,
  `status` enum('Pending','Completed','Cancelled') NOT NULL DEFAULT 'Pending',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `lead_followups_lead_id_foreign` (`lead_id`),
  CONSTRAINT `lead_followups_lead_id_foreign` FOREIGN KEY (`lead_id`) REFERENCES `leads` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- -------------------------------
-- Table: campaign_insights
-- -------------------------------

DROP TABLE IF EXISTS `campaign_insights`;
CREATE TABLE `campaign_insights` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `campaign_id` bigint unsigned NOT NULL,
  `date` date NOT NULL,
  `impressions` decimal(15,2) NOT NULL DEFAULT '0.00',
  `reach` decimal(15,2) NOT NULL DEFAULT '0.00',
  `clicks` int NOT NULL DEFAULT '0',
  `spend` decimal(15,2) NOT NULL DEFAULT '0.00',
  `cpm` decimal(10,4) DEFAULT NULL,
  `cpc` decimal(10,4) DEFAULT NULL,
  `ctr` decimal(10,4) DEFAULT NULL,
  `frequency` decimal(10,4) DEFAULT NULL,
  `conversions` int NOT NULL DEFAULT '0',
  `leads` int NOT NULL DEFAULT '0',
  `video_views` int NOT NULL DEFAULT '0',
  `engagements` int NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `campaign_insights_campaign_id_foreign` (`campaign_id`),
  CONSTRAINT `campaign_insights_campaign_id_foreign` FOREIGN KEY (`campaign_id`) REFERENCES `campaigns` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Database export completed successfully