CREATE TABLE IF NOT EXISTS `special_plans` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `description` text,
  `min_amount` decimal(15,2) NOT NULL DEFAULT 0.00,
  `max_amount` decimal(15,2) DEFAULT NULL,
  `roi_percentage` decimal(5,2) NOT NULL,
  `duration_days` int(11) NOT NULL,
  `risk_level` enum('low','medium','high') DEFAULT 'low',
  `hourly_roi` decimal(10,6) DEFAULT 0.000000,
  `status` enum('active','inactive') DEFAULT 'active',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

CREATE TABLE IF NOT EXISTS `user_special_investments` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `plan_id` int(11) NOT NULL,
  `amount` decimal(15,2) NOT NULL,
  `start_date` datetime NOT NULL DEFAULT current_timestamp(),
  `end_date` datetime DEFAULT NULL,
  `status` enum('active','completed','cancelled') DEFAULT 'active',
  `accrued_profit` decimal(15,2) DEFAULT 0.00,
  `last_growth_update` timestamp NOT NULL DEFAULT current_timestamp(),
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `user_id` (`user_id`),
  KEY `plan_id` (`plan_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

INSERT INTO `special_plans` (`name`, `description`, `min_amount`, `max_amount`, `roi_percentage`, `duration_days`, `risk_level`) VALUES
('Starter Auto-Invest', 'Perfect for beginners. Low risk, steady returns.', 500.00, 5000.00, 5.00, 30, 'low'),
('Growth Accelerator', 'Accelerated growth for medium-term goals.', 5000.00, 25000.00, 12.00, 90, 'medium'),
('Wealth Builder Pro', 'High-yield payouts for serious investors.', 25000.00, 100000.00, 25.00, 180, 'high');
