-- Finorix Platform MySQL Dump
-- Generated on 2026-05-08 12:05:48

SET FOREIGN_KEY_CHECKS=0;

-- Table structure for table `migrations`
DROP TABLE IF EXISTS `migrations`;
CREATE TABLE `migrations` (`id` integer primary key autoincrement not null, `migration` varchar not null, `batch` integer not null);

-- Dumping data for table `migrations`
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES ('1', '0001_01_01_000000_create_users_table', '1');
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES ('2', '0001_01_01_000001_create_cache_table', '1');
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES ('3', '0001_01_01_000002_create_jobs_table', '1');
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES ('4', '2026_05_07_020822_create_affiliates_table', '1');
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES ('5', '2026_05_07_020822_create_trades_table', '1');
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES ('6', '2026_05_07_020823_create_commissions_table', '1');
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES ('7', '2026_05_07_020824_create_withdrawals_table', '1');
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES ('8', '2026_05_07_020825_create_ledgers_table', '1');
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES ('9', '2026_05_07_020831_add_trading_fields_to_users_table', '1');
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES ('10', '2026_05_07_022320_create_personal_access_tokens_table', '1');
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES ('11', '2026_05_07_031017_add_username_to_users_table', '2');
INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES ('12', '2026_05_07_045940_add_affiliate_approval_to_users_table', '3');

-- Table structure for table `users`
DROP TABLE IF EXISTS `users`;
CREATE TABLE `users` (`id` integer primary key autoincrement not null, `name` varchar not null, `email` varchar not null, `email_verified_at` datetime, `password` varchar not null, `remember_token` varchar, `created_at` datetime, `updated_at` datetime, `balance` numeric not null default '0', `status` varchar check (`status` in ('active', 'suspended')) not null default 'active', `role` varchar check (`role` in ('user', 'admin')) not null default 'user', `referrer_id` varchar, `force_mode` varchar check (`force_mode` in ('none', 'force_win', 'force_loss')) not null default 'none', `global_loss_ratio` numeric not null default '70', `username` varchar not null, `is_affiliate_approved` tinyint(1) not null default '0');

-- Dumping data for table `users`
INSERT INTO `users` (`id`, `name`, `email`, `email_verified_at`, `password`, `remember_token`, `created_at`, `updated_at`, `balance`, `status`, `role`, `referrer_id`, `force_mode`, `global_loss_ratio`, `username`, `is_affiliate_approved`) VALUES ('1', 'Admin User', 'admin@finorix.com', NULL, '$2y$12$wUUbJLP33Vn.YXREPSPakOQ2YXQPc4sKXuPL2lNU.NLVP2snjTDMq', NULL, '2026-05-07 03:10:34', '2026-05-07 03:10:34', '0', 'active', 'admin', NULL, 'none', '70', 'admin_root', '0');
INSERT INTO `users` (`id`, `name`, `email`, `email_verified_at`, `password`, `remember_token`, `created_at`, `updated_at`, `balance`, `status`, `role`, `referrer_id`, `force_mode`, `global_loss_ratio`, `username`, `is_affiliate_approved`) VALUES ('2', 'Top Affiliate', 'userA@finorix.com', NULL, '$2y$12$.tKW/pbB.xHrzXEBFrO2UOVFqxKqlwK48oieoo6bwGN94Ydxuf8Pm', NULL, '2026-05-07 03:10:34', '2026-05-07 03:10:34', '500', 'active', 'user', NULL, 'none', '70', 'topaff', '0');
INSERT INTO `users` (`id`, `name`, `email`, `email_verified_at`, `password`, `remember_token`, `created_at`, `updated_at`, `balance`, `status`, `role`, `referrer_id`, `force_mode`, `global_loss_ratio`, `username`, `is_affiliate_approved`) VALUES ('3', 'Middle Trader', 'userB@finorix.com', NULL, '$2y$12$yj0YQEbXMGxjFiSH2mss6OnkO93lJoLkaqxFPVrquab/ifX9k/WJq', NULL, '2026-05-07 03:10:34', '2026-05-07 03:10:34', '1000', 'active', 'user', '2', 'none', '70', 'midtrader', '0');
INSERT INTO `users` (`id`, `name`, `email`, `email_verified_at`, `password`, `remember_token`, `created_at`, `updated_at`, `balance`, `status`, `role`, `referrer_id`, `force_mode`, `global_loss_ratio`, `username`, `is_affiliate_approved`) VALUES ('4', 'Active Trader', 'userC@finorix.com', NULL, '$2y$12$HMqINOPuHoZgiJSAjG8LDufKxDtcdJ/9yiQn/N5l2dofsSuZM.TZO', NULL, '2026-05-07 03:10:34', '2026-05-07 03:10:34', '2500', 'active', 'user', '3', 'none', '70', 'activetrader', '0');

-- Table structure for table `password_reset_tokens`
DROP TABLE IF EXISTS `password_reset_tokens`;
CREATE TABLE `password_reset_tokens` (`email` varchar not null, `token` varchar not null, `created_at` datetime, primary key (`email`));

-- Dumping data for table `password_reset_tokens`
-- Table structure for table `sessions`
DROP TABLE IF EXISTS `sessions`;
CREATE TABLE `sessions` (`id` varchar not null, `user_id` integer, `ip_address` varchar, `user_agent` text, `payload` text not null, `last_activity` integer not null, primary key (`id`));

-- Dumping data for table `sessions`
INSERT INTO `sessions` (`id`, `user_id`, `ip_address`, `user_agent`, `payload`, `last_activity`) VALUES ('YJUitlBqTq0TfiGuyUsLlsKGwo4YbqsevUI3HMAp', NULL, '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', 'YTozOntzOjY6Il90b2tlbiI7czo0MDoiM3BNUmZJeFM0dGZKbndRdEhlMk9DMTIzRG43MVBpZGo2V2ZMVlBjOCI7czo5OiJfcHJldmlvdXMiO2E6Mjp7czozOiJ1cmwiO3M6MjE6Imh0dHA6Ly8xMjcuMC4wLjE6ODAwMCI7czo1OiJyb3V0ZSI7Tjt9czo2OiJfZmxhc2giO2E6Mjp7czozOiJvbGQiO2E6MDp7fXM6MzoibmV3IjthOjA6e319fQ==', '1778127161');
INSERT INTO `sessions` (`id`, `user_id`, `ip_address`, `user_agent`, `payload`, `last_activity`) VALUES ('6zhjPXvA2SmYsBC1D0khWbqJDmoomC0lNthAHz5A', NULL, '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36', 'YTozOntzOjY6Il90b2tlbiI7czo0MDoiWVZjQ3hiV3B2YU5wTXp6d1c2N3R1WGkxZVdSejVDM0JtWWpBUUFrRCI7czo5OiJfcHJldmlvdXMiO2E6Mjp7czozOiJ1cmwiO3M6MjE6Imh0dHA6Ly8xMjcuMC4wLjE6ODAwMCI7czo1OiJyb3V0ZSI7Tjt9czo2OiJfZmxhc2giO2E6Mjp7czozOiJvbGQiO2E6MDp7fXM6MzoibmV3IjthOjA6e319fQ==', '1778229648');

-- Table structure for table `cache`
DROP TABLE IF EXISTS `cache`;
CREATE TABLE `cache` (`key` varchar not null, `value` text not null, `expiration` integer not null, primary key (`key`));

-- Dumping data for table `cache`
-- Table structure for table `cache_locks`
DROP TABLE IF EXISTS `cache_locks`;
CREATE TABLE `cache_locks` (`key` varchar not null, `owner` varchar not null, `expiration` integer not null, primary key (`key`));

-- Dumping data for table `cache_locks`
-- Table structure for table `jobs`
DROP TABLE IF EXISTS `jobs`;
CREATE TABLE `jobs` (`id` integer primary key autoincrement not null, `queue` varchar not null, `payload` text not null, `attempts` integer not null, `reserved_at` integer, `available_at` integer not null, `created_at` integer not null);

-- Dumping data for table `jobs`
-- Table structure for table `job_batches`
DROP TABLE IF EXISTS `job_batches`;
CREATE TABLE `job_batches` (`id` varchar not null, `name` varchar not null, `total_jobs` integer not null, `pending_jobs` integer not null, `failed_jobs` integer not null, `failed_job_ids` text not null, `options` text, `cancelled_at` integer, `created_at` integer not null, `finished_at` integer, primary key (`id`));

-- Dumping data for table `job_batches`
-- Table structure for table `failed_jobs`
DROP TABLE IF EXISTS `failed_jobs`;
CREATE TABLE `failed_jobs` (`id` integer primary key autoincrement not null, `uuid` varchar not null, `connection` text not null, `queue` text not null, `payload` text not null, `exception` text not null, `failed_at` datetime not null default CURRENT_TIMESTAMP);

-- Dumping data for table `failed_jobs`
-- Table structure for table `affiliates`
DROP TABLE IF EXISTS `affiliates`;
CREATE TABLE `affiliates` (`id` integer primary key autoincrement not null, `user_id` integer not null, `model` varchar check (`model` in ('revshare', 'turnover')) not null default 'revshare', `created_at` datetime, `updated_at` datetime, foreign key(`user_id`) references `users`(`id`) on delete cascade);

-- Dumping data for table `affiliates`
INSERT INTO `affiliates` (`id`, `user_id`, `model`, `created_at`, `updated_at`) VALUES ('1', '2', 'revshare', '2026-05-07 03:10:34', '2026-05-07 03:10:34');
INSERT INTO `affiliates` (`id`, `user_id`, `model`, `created_at`, `updated_at`) VALUES ('2', '3', 'revshare', '2026-05-07 03:10:34', '2026-05-07 03:10:34');
INSERT INTO `affiliates` (`id`, `user_id`, `model`, `created_at`, `updated_at`) VALUES ('3', '4', 'revshare', '2026-05-07 03:10:34', '2026-05-07 03:10:34');

-- Table structure for table `trades`
DROP TABLE IF EXISTS `trades`;
CREATE TABLE `trades` (`id` integer primary key autoincrement not null, `user_id` integer not null, `asset` varchar not null, `direction` varchar check (`direction` in ('up', 'down')) not null, `amount` numeric not null, `payout_multiplier` numeric not null default '1.85', `payout_amount` numeric not null default '0', `expires_at` datetime not null, `status` varchar check (`status` in ('active', 'won', 'lost')) not null default 'active', `outcome_type` varchar check (`outcome_type` in ('natural', 'forced_win', 'forced_loss')) not null default 'natural', `created_at` datetime, `updated_at` datetime, foreign key(`user_id`) references `users`(`id`) on delete cascade);

-- Dumping data for table `trades`
INSERT INTO `trades` (`id`, `user_id`, `asset`, `direction`, `amount`, `payout_multiplier`, `payout_amount`, `expires_at`, `status`, `outcome_type`, `created_at`, `updated_at`) VALUES ('1', '4', 'BTC/USD', 'up', '100', '1.85', '0', '2026-05-07 03:15:34', 'active', 'natural', '2026-05-07 03:10:35', '2026-05-07 03:10:35');
INSERT INTO `trades` (`id`, `user_id`, `asset`, `direction`, `amount`, `payout_multiplier`, `payout_amount`, `expires_at`, `status`, `outcome_type`, `created_at`, `updated_at`) VALUES ('2', '4', 'ETH/USD', 'down', '200', '1.85', '0', '2026-05-07 03:00:35', 'lost', 'natural', '2026-05-07 03:10:35', '2026-05-07 03:10:35');
INSERT INTO `trades` (`id`, `user_id`, `asset`, `direction`, `amount`, `payout_multiplier`, `payout_amount`, `expires_at`, `status`, `outcome_type`, `created_at`, `updated_at`) VALUES ('3', '3', 'XAU/USD', 'up', '50', '1.9', '95', '2026-05-07 02:50:35', 'won', 'natural', '2026-05-07 03:10:35', '2026-05-07 03:10:35');

-- Table structure for table `commissions`
DROP TABLE IF EXISTS `commissions`;
CREATE TABLE `commissions` (`id` integer primary key autoincrement not null, `affiliate_id` integer not null, `user_id` integer not null, `trade_id` integer not null, `amount` numeric not null, `percentage` numeric not null, `level` varchar check (`level` in ('1', '2')) not null, `type` varchar check (`type` in ('revshare', 'turnover')) not null, `created_at` datetime, `updated_at` datetime, foreign key(`affiliate_id`) references `users`(`id`) on delete cascade, foreign key(`user_id`) references `users`(`id`) on delete cascade, foreign key(`trade_id`) references `trades`(`id`) on delete cascade);

-- Dumping data for table `commissions`
-- Table structure for table `withdrawals`
DROP TABLE IF EXISTS `withdrawals`;
CREATE TABLE `withdrawals` (`id` integer primary key autoincrement not null, `user_id` integer not null, `amount` numeric not null, `method` varchar not null, `wallet_address` varchar, `status` varchar check (`status` in ('pending', 'approved', 'rejected')) not null default 'pending', `processed_by` varchar, `processed_at` datetime, `created_at` datetime, `updated_at` datetime, foreign key(`user_id`) references `users`(`id`) on delete cascade);

-- Dumping data for table `withdrawals`
-- Table structure for table `ledgers`
DROP TABLE IF EXISTS `ledgers`;
CREATE TABLE `ledgers` (`id` integer primary key autoincrement not null, `user_id` integer not null, `amount` numeric not null, `balance_before` numeric not null, `balance_after` numeric not null, `type` varchar not null, `reference_type` varchar, `reference_id` integer, `description` varchar, `created_at` datetime, `updated_at` datetime, foreign key(`user_id`) references `users`(`id`) on delete cascade);

-- Dumping data for table `ledgers`
-- Table structure for table `personal_access_tokens`
DROP TABLE IF EXISTS `personal_access_tokens`;
CREATE TABLE `personal_access_tokens` (`id` integer primary key autoincrement not null, `tokenable_type` varchar not null, `tokenable_id` integer not null, `name` text not null, `token` varchar not null, `abilities` text, `last_used_at` datetime, `expires_at` datetime, `created_at` datetime, `updated_at` datetime);

-- Dumping data for table `personal_access_tokens`
SET FOREIGN_KEY_CHECKS=1;
