-- MLM demo SQL dump generated: 2025-12-04 06:52:47



CREATE TABLE `company` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `keyname` varchar(191) NOT NULL,
  `value` decimal(18,2) NOT NULL DEFAULT '0.00',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


CREATE TABLE `stages` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `stage_number` int NOT NULL,
  `pairs_required` int NOT NULL DEFAULT 0,
  `payout` decimal(14,2) NOT NULL DEFAULT '0.00',
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


CREATE TABLE `stage_progress` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned NOT NULL,
  `stage_id` bigint unsigned NOT NULL,
  `left_count` int NOT NULL DEFAULT 0,
  `right_count` int NOT NULL DEFAULT 0,
  `pairs_completed` int NOT NULL DEFAULT 0,
  `paid` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


CREATE TABLE `commissions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned DEFAULT NULL,
  `source_user_id` bigint unsigned DEFAULT NULL,
  `type` varchar(100) NOT NULL,
  `amount` decimal(14,2) NOT NULL,
  `meta` text,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


CREATE TABLE `transactions` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned NOT NULL,
  `amount` decimal(14,2) NOT NULL,
  `direction` enum('credit','debit') NOT NULL,
  `description` varchar(255) DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


CREATE TABLE `epins` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `code` varchar(191) NOT NULL,
  `value` decimal(14,2) NOT NULL DEFAULT '0.00',
  `owner_id` bigint unsigned DEFAULT NULL,
  `used_by` bigint unsigned DEFAULT NULL,
  `used_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `epins_code_unique` (`code`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;


CREATE TABLE `withdrawals` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint unsigned NOT NULL,
  `amount` decimal(14,2) NOT NULL,
  `status` varchar(50) NOT NULL DEFAULT 'pending',
  `admin_note` text,
  `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `updated_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT INTO `company` (`keyname`,`value`,`created_at`,`updated_at`) VALUES ('stage_pool','10000.0','2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `company` (`keyname`,`value`,`created_at`,`updated_at`) VALUES ('company_profit','5000.0','2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `company` (`keyname`,`value`,`created_at`,`updated_at`) VALUES ('fees','0.0','2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `stages` (`stage_number`,`pairs_required`,`payout`,`created_at`,`updated_at`) VALUES (1,3,60,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `stages` (`stage_number`,`pairs_required`,`payout`,`created_at`,`updated_at`) VALUES (2,6,120,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `stages` (`stage_number`,`pairs_required`,`payout`,`created_at`,`updated_at`) VALUES (3,18,900,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `stages` (`stage_number`,`pairs_required`,`payout`,`created_at`,`updated_at`) VALUES (4,60,5600,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `stages` (`stage_number`,`pairs_required`,`payout`,`created_at`,`updated_at`) VALUES (5,200,28000,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `stages` (`stage_number`,`pairs_required`,`payout`,`created_at`,`updated_at`) VALUES (6,1000,70000,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `epins` (`code`,`value`,`created_at`,`updated_at`) VALUES ('EPIN1001814',100.0,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `epins` (`code`,`value`,`created_at`,`updated_at`) VALUES ('EPIN1002912',100.0,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `epins` (`code`,`value`,`created_at`,`updated_at`) VALUES ('EPIN1003313',100.0,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `epins` (`code`,`value`,`created_at`,`updated_at`) VALUES ('EPIN1004300',100.0,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `epins` (`code`,`value`,`created_at`,`updated_at`) VALUES ('EPIN1005829',100.0,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `epins` (`code`,`value`,`created_at`,`updated_at`) VALUES ('EPIN1006696',100.0,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `epins` (`code`,`value`,`created_at`,`updated_at`) VALUES ('EPIN1007288',100.0,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `epins` (`code`,`value`,`created_at`,`updated_at`) VALUES ('EPIN1008985',100.0,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `epins` (`code`,`value`,`created_at`,`updated_at`) VALUES ('EPIN1009299',100.0,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `epins` (`code`,`value`,`created_at`,`updated_at`) VALUES ('EPIN1010914',100.0,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `epins` (`code`,`value`,`created_at`,`updated_at`) VALUES ('EPIN1011268',100.0,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `epins` (`code`,`value`,`created_at`,`updated_at`) VALUES ('EPIN1012138',100.0,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `epins` (`code`,`value`,`created_at`,`updated_at`) VALUES ('EPIN1013658',100.0,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `epins` (`code`,`value`,`created_at`,`updated_at`) VALUES ('EPIN1014876',100.0,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `epins` (`code`,`value`,`created_at`,`updated_at`) VALUES ('EPIN1015868',100.0,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `epins` (`code`,`value`,`created_at`,`updated_at`) VALUES ('EPIN1016294',100.0,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `epins` (`code`,`value`,`created_at`,`updated_at`) VALUES ('EPIN1017445',100.0,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `epins` (`code`,`value`,`created_at`,`updated_at`) VALUES ('EPIN1018426',100.0,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `epins` (`code`,`value`,`created_at`,`updated_at`) VALUES ('EPIN1019100',100.0,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `epins` (`code`,`value`,`created_at`,`updated_at`) VALUES ('EPIN1020938',100.0,'2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `transactions` (`user_id`,`amount`,`direction`,`description`,`created_at`,`updated_at`) VALUES (1,100.00,'credit','Seed bonus','2025-12-04 06:52:47','2025-12-04 06:52:47');
INSERT INTO `commissions` (`user_id`,`source_user_id`,`type`,`amount`,`meta`,`created_at`,`updated_at`) VALUES (NULL,1,'company',40.00,'Initial seed','2025-12-04 06:52:47','2025-12-04 06:52:47');
