-- phpMyAdmin SQL Dump
-- version 5.2.1
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
-- Generation Time: Aug 31, 2026 at 10:43 AM
-- Server version: 10.4.32-MariaDB
-- PHP Version: 8.2.12

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;

--
-- Database: `complete_bliss`
--

-- --------------------------------------------------------

--
-- Table structure for table `admins`
--

CREATE TABLE `admins` (
  `id` int(11) NOT NULL,
  `fullname` varchar(150) NOT NULL,
  `email` varchar(150) DEFAULT NULL,
  `phone` varchar(20) NOT NULL,
  `password` varchar(255) NOT NULL,
  `role` enum('super_admin','admin','staff') NOT NULL DEFAULT 'admin',
  `status` enum('active','inactive') NOT NULL DEFAULT 'active',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `contributions`
--

CREATE TABLE `contributions` (
  `id` int(11) NOT NULL,
  `subscription_id` int(11) NOT NULL,
  `contribution_no` int(11) NOT NULL,
  `amount` decimal(15,2) NOT NULL,
  `due_date` date NOT NULL,
  `paid_date` date DEFAULT NULL,
  `status` enum('pending','paid','overdue') DEFAULT 'pending',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `funding_account_requests`
--

CREATE TABLE `funding_account_requests` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `user_id` int(11) NOT NULL,
  `provider` varchar(50) NOT NULL DEFAULT 'paystack',
  `email` varchar(190) NOT NULL,
  `consent_given` tinyint(1) NOT NULL DEFAULT 0,
  `consent_at` datetime DEFAULT NULL,
  `status` enum('pending','processing','activated','failed','cancelled') NOT NULL DEFAULT 'pending',
  `failure_reason` text DEFAULT NULL,
  `requested_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `funding_account_requests`
--

INSERT INTO `funding_account_requests` (`id`, `user_id`, `provider`, `email`, `consent_given`, `consent_at`, `status`, `failure_reason`, `requested_at`, `updated_at`) VALUES
(1, 13, 'paystack', 'abdulafeezmoronkola@gmail.com', 1, '2026-08-25 12:22:37', 'pending', NULL, '2026-08-25 11:22:37', '2026-08-25 11:22:37');

-- --------------------------------------------------------

--
-- Table structure for table `member_virtual_accounts`
--

CREATE TABLE `member_virtual_accounts` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `user_id` int(11) NOT NULL,
  `provider` varchar(50) NOT NULL DEFAULT 'paystack',
  `environment` enum('test','live') NOT NULL DEFAULT 'test',
  `provider_customer_id` bigint(20) UNSIGNED DEFAULT NULL,
  `customer_code` varchar(100) DEFAULT NULL,
  `dedicated_account_id` bigint(20) UNSIGNED DEFAULT NULL,
  `bank_name` varchar(150) DEFAULT NULL,
  `bank_slug` varchar(100) DEFAULT NULL,
  `account_name` varchar(200) DEFAULT NULL,
  `account_number` varchar(20) DEFAULT NULL,
  `currency` varchar(10) NOT NULL DEFAULT 'NGN',
  `validation_status` enum('not_required','not_started','pending','validated','failed') NOT NULL DEFAULT 'not_started',
  `consent_at` datetime DEFAULT NULL,
  `assigned` tinyint(1) NOT NULL DEFAULT 0,
  `active` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `member_virtual_accounts`
--

INSERT INTO `member_virtual_accounts` (`id`, `user_id`, `provider`, `environment`, `provider_customer_id`, `customer_code`, `dedicated_account_id`, `bank_name`, `bank_slug`, `account_name`, `account_number`, `currency`, `validation_status`, `consent_at`, `assigned`, `active`, `created_at`, `updated_at`) VALUES
(1, 13, 'paystack', 'test', 393746931, 'CUS_skcotz6y5ssok8v', NULL, NULL, NULL, NULL, NULL, 'NGN', 'not_started', NULL, 0, 0, '2026-08-25 07:18:35', '2026-08-25 07:18:35'),
(2, 14, 'paystack', 'test', 393750167, 'CUS_gi2nrqrhv65xuwk', NULL, NULL, NULL, NULL, NULL, 'NGN', 'validated', '2026-08-25 08:52:52', 0, 0, '2026-08-25 07:33:00', '2026-08-25 07:57:21');

-- --------------------------------------------------------

--
-- Table structure for table `notifications`
--

CREATE TABLE `notifications` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `title` varchar(150) NOT NULL,
  `message` text NOT NULL,
  `type` enum('success','info','warning','error') DEFAULT 'info',
  `is_read` tinyint(1) DEFAULT 0,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `password_reset_requests`
--

CREATE TABLE `password_reset_requests` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `phone` varchar(30) NOT NULL,
  `email` varchar(255) DEFAULT NULL,
  `request_type` enum('email','admin') NOT NULL,
  `token_hash` varchar(255) DEFAULT NULL,
  `token_expires_at` datetime DEFAULT NULL,
  `attempt_count` int(10) UNSIGNED NOT NULL DEFAULT 0,
  `status` enum('pending','email_sent','approved','completed','rejected','expired') NOT NULL DEFAULT 'pending',
  `requested_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `approved_at` datetime DEFAULT NULL,
  `completed_at` datetime DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `password_reset_requests`
--

INSERT INTO `password_reset_requests` (`id`, `user_id`, `phone`, `email`, `request_type`, `token_hash`, `token_expires_at`, `attempt_count`, `status`, `requested_at`, `approved_at`, `completed_at`) VALUES
(3, 13, '08167452166', NULL, 'admin', NULL, NULL, 0, 'expired', '2026-08-24 19:32:48', '2026-08-24 20:33:02', NULL),
(4, 13, '08167452166', NULL, 'admin', NULL, NULL, 0, 'completed', '2026-08-24 19:38:35', '2026-08-24 20:38:46', '2026-08-24 20:39:02');

-- --------------------------------------------------------

--
-- Table structure for table `payment_events`
--

CREATE TABLE `payment_events` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `provider` varchar(50) NOT NULL DEFAULT 'paystack',
  `environment` enum('test','live') NOT NULL DEFAULT 'test',
  `event_type` varchar(100) DEFAULT NULL,
  `provider_reference` varchar(150) DEFAULT NULL,
  `provider_event_id` varchar(150) DEFAULT NULL,
  `user_id` int(11) DEFAULT NULL,
  `amount` decimal(15,2) DEFAULT NULL,
  `currency` varchar(10) NOT NULL DEFAULT 'NGN',
  `payload` longtext DEFAULT NULL,
  `processing_status` enum('received','processing','processed','ignored','failed') NOT NULL DEFAULT 'received',
  `failure_reason` text DEFAULT NULL,
  `processed_at` datetime DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `payment_events`
--

INSERT INTO `payment_events` (`id`, `provider`, `environment`, `event_type`, `provider_reference`, `provider_event_id`, `user_id`, `amount`, `currency`, `payload`, `processing_status`, `failure_reason`, `processed_at`, `created_at`, `updated_at`) VALUES
(1, 'paystack', 'test', 'charge.success', 'CB_TEST_20260825150928_4827', '853e6ed6c073be435fd77c5f2941490516dc315da75d72d2cefba6f7aaeff2f7', 14, 2500.00, 'NGN', '{\"event\":\"charge.success\",\"data\":{\"id\":4068052,\"domain\":\"test\",\"status\":\"success\",\"reference\":\"CB_TEST_20260825150928_4827\",\"amount\":250000,\"currency\":\"NGN\",\"channel\":\"dedicated_nuban\",\"customer\":{\"customer_code\":\"CUS_gi2nrqrhv65xuwk\",\"email\":\"moronkolaabdulafeez@gmail.com\"},\"authorization\":{\"channel\":\"dedicated_nuban\",\"receiver_bank_account_number\":\"9999999999\"}}}', 'received', NULL, NULL, '2026-08-25 13:09:28', '2026-08-25 13:09:28');

-- --------------------------------------------------------

--
-- Table structure for table `plans`
--

CREATE TABLE `plans` (
  `id` int(11) NOT NULL,
  `plan_name` varchar(150) NOT NULL,
  `plan_type` enum('Savings','Food','Contribution') NOT NULL,
  `amount` decimal(15,2) NOT NULL,
  `frequency` enum('Daily','Weekly','Monthly','Yearly') NOT NULL,
  `duration` int(11) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `plan_image` varchar(255) DEFAULT NULL,
  `package_items` text DEFAULT NULL,
  `start_month` tinyint(4) DEFAULT NULL,
  `start_year` smallint(6) DEFAULT NULL,
  `status` enum('active','inactive') DEFAULT 'active',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `plans`
--

INSERT INTO `plans` (`id`, `plan_name`, `plan_type`, `amount`, `frequency`, `duration`, `description`, `plan_image`, `package_items`, `start_month`, `start_year`, `status`, `created_at`, `updated_at`) VALUES
(19, 'FOOD SCHEME', 'Food', 7000.00, 'Monthly', 12, 'JNJJJJJ', 'plan_1787555161_a35be0c251.jpg', 'NNJHHJ', 12, 2025, 'active', '2026-08-24 07:06:01', '2026-08-24 07:06:01');

-- --------------------------------------------------------

--
-- Table structure for table `registration_payments`
--

CREATE TABLE `registration_payments` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `amount` decimal(15,2) NOT NULL,
  `receipt` varchar(255) NOT NULL,
  `status` enum('pending','approved','rejected') NOT NULL DEFAULT 'pending',
  `admin_remark` text DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `registration_payments`
--

INSERT INTO `registration_payments` (`id`, `user_id`, `amount`, `receipt`, `status`, `admin_remark`, `created_at`) VALUES
(13, 13, 5000.00, 'receipt_6a8c9690cf25d.jpeg', 'approved', NULL, '2026-08-24 19:08:00'),
(14, 14, 5000.00, 'receipt_6a8d44e9042df.jpeg', 'approved', NULL, '2026-08-25 07:31:53');

-- --------------------------------------------------------

--
-- Table structure for table `scheme_clearances`
--

CREATE TABLE `scheme_clearances` (
  `id` int(11) NOT NULL,
  `subscription_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `plan_id` int(11) NOT NULL,
  `clearance_code` varchar(50) NOT NULL,
  `total_defaults_settled` decimal(15,2) NOT NULL DEFAULT 0.00,
  `clearance_date` datetime NOT NULL,
  `status` enum('completed') NOT NULL DEFAULT 'completed',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `settings`
--

CREATE TABLE `settings` (
  `id` int(11) NOT NULL,
  `company_name` varchar(150) NOT NULL,
  `registration_fee` decimal(15,2) NOT NULL DEFAULT 0.00,
  `default_penalty` decimal(15,2) NOT NULL DEFAULT 1000.00,
  `support_phone` varchar(20) DEFAULT NULL,
  `support_email` varchar(150) DEFAULT NULL,
  `support_whatsapp` varchar(20) DEFAULT NULL,
  `auto_deduction_enabled` tinyint(1) NOT NULL DEFAULT 1,
  `auto_deduction_day` int(11) DEFAULT 1,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `bank_name` varchar(150) DEFAULT NULL,
  `account_number` varchar(30) DEFAULT NULL,
  `account_name` varchar(150) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `settings`
--

INSERT INTO `settings` (`id`, `company_name`, `registration_fee`, `default_penalty`, `support_phone`, `support_email`, `support_whatsapp`, `auto_deduction_enabled`, `auto_deduction_day`, `created_at`, `updated_at`, `bank_name`, `account_number`, `account_name`) VALUES
(1, 'Complete Bliss Solutions', 5000.00, 1000.00, '08084052058', 'abdulafeezmoronkola@gmail.com', '08090261011', 1, 1, '2026-08-02 00:17:01', '2026-08-24 07:13:10', 'Access Bank', '01234', 'Complete Bliss Solutions');

-- --------------------------------------------------------

--
-- Table structure for table `subscriptions`
--

CREATE TABLE `subscriptions` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `plan_id` int(11) NOT NULL,
  `hands` int(11) NOT NULL DEFAULT 1,
  `total_amount` decimal(15,2) NOT NULL DEFAULT 0.00,
  `amount` decimal(15,2) NOT NULL,
  `next_deduction_date` date DEFAULT NULL,
  `status` enum('active','paused','completed') DEFAULT 'active',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `subscription_defaults`
--

CREATE TABLE `subscription_defaults` (
  `id` int(11) NOT NULL,
  `subscription_id` int(11) NOT NULL,
  `contribution_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `plan_id` int(11) NOT NULL,
  `default_date` date NOT NULL,
  `amount` decimal(15,2) NOT NULL DEFAULT 1000.00,
  `reason` varchar(255) DEFAULT 'Missed payment deadline',
  `status` enum('unpaid','paid') NOT NULL DEFAULT 'unpaid',
  `paid_at` timestamp NULL DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

-- --------------------------------------------------------

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` int(11) NOT NULL,
  `fullname` varchar(150) NOT NULL,
  `profile_picture` varchar(255) DEFAULT NULL,
  `email` varchar(150) DEFAULT NULL,
  `phone` varchar(20) NOT NULL,
  `password` varchar(255) NOT NULL,
  `wallet_balance` decimal(15,2) NOT NULL DEFAULT 0.00,
  `savings_target` decimal(15,2) NOT NULL DEFAULT 0.00,
  `role` enum('admin','member') NOT NULL DEFAULT 'member',
  `status` enum('pending','active','suspended') NOT NULL DEFAULT 'pending',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp(),
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  `virtual_bank` varchar(100) DEFAULT NULL,
  `virtual_account_number` varchar(30) DEFAULT NULL,
  `virtual_account_name` varchar(150) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `users`
--

INSERT INTO `users` (`id`, `fullname`, `profile_picture`, `email`, `phone`, `password`, `wallet_balance`, `savings_target`, `role`, `status`, `created_at`, `updated_at`, `virtual_bank`, `virtual_account_number`, `virtual_account_name`) VALUES
(1, 'MORONKOLA OLADIPUPO ABDULAFEEZ', NULL, '', '08090261011', '$2y$10$7T/8z9hpZ1FXq5gvB8qeJubF1W0zgqxW3bi0/a3roZMyg5XRsW6ua', 0.00, 0.00, 'admin', 'active', '2026-08-02 05:58:08', '2026-08-02 06:00:16', NULL, NULL, NULL),
(13, 'MORONKOLA OLADIPUPO ABDULAFEEZ', NULL, 'abdulafeezmoronkola@gmail.com', '08167452166', '$2y$10$oLNCeBIudU96FMhGBEV00O9JpjkYWG5cBele.ECe8Zegl2JP/ptDu', 0.00, 0.00, 'member', 'active', '2026-08-24 19:08:00', '2026-08-25 07:18:23', NULL, NULL, NULL),
(14, 'Uchenna Okoro', NULL, 'moronkolaabdulafeez@gmail.com', '07019324894', '$2y$10$ytTfM7XnSt7t5yv2XVPUT..1evRQstkwW4tEtlVXaS0jb8RYh1JSK', 0.00, 0.00, 'member', 'active', '2026-08-25 07:31:53', '2026-08-25 07:32:09', NULL, NULL, NULL);

-- --------------------------------------------------------

--
-- Table structure for table `wallet_transactions`
--

CREATE TABLE `wallet_transactions` (
  `id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `transaction_type` enum('funding','deduction','refund','bonus','registration') NOT NULL,
  `amount` decimal(15,2) NOT NULL,
  `balance_before` decimal(15,2) NOT NULL DEFAULT 0.00,
  `balance_after` decimal(15,2) NOT NULL DEFAULT 0.00,
  `reference` varchar(100) DEFAULT NULL,
  `description` text DEFAULT NULL,
  `status` enum('pending','successful','failed') NOT NULL DEFAULT 'successful',
  `created_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Indexes for dumped tables
--

--
-- Indexes for table `admins`
--
ALTER TABLE `admins`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `phone` (`phone`);

--
-- Indexes for table `contributions`
--
ALTER TABLE `contributions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_contribution_subscription` (`subscription_id`);

--
-- Indexes for table `funding_account_requests`
--
ALTER TABLE `funding_account_requests`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_member_funding_request` (`user_id`,`provider`),
  ADD KEY `idx_funding_request_status` (`status`);

--
-- Indexes for table `member_virtual_accounts`
--
ALTER TABLE `member_virtual_accounts`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_member_provider_environment` (`user_id`,`provider`,`environment`),
  ADD UNIQUE KEY `unique_customer_code` (`provider`,`environment`,`customer_code`),
  ADD UNIQUE KEY `unique_dedicated_account` (`provider`,`environment`,`dedicated_account_id`),
  ADD UNIQUE KEY `unique_bank_account` (`provider`,`environment`,`bank_name`,`account_number`);

--
-- Indexes for table `notifications`
--
ALTER TABLE `notifications`
  ADD PRIMARY KEY (`id`),
  ADD KEY `user_id` (`user_id`);

--
-- Indexes for table `password_reset_requests`
--
ALTER TABLE `password_reset_requests`
  ADD PRIMARY KEY (`id`),
  ADD KEY `idx_password_reset_user` (`user_id`),
  ADD KEY `idx_password_reset_status` (`status`),
  ADD KEY `idx_password_reset_token` (`token_hash`);

--
-- Indexes for table `payment_events`
--
ALTER TABLE `payment_events`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_provider_reference` (`provider`,`environment`,`provider_reference`),
  ADD UNIQUE KEY `unique_provider_event` (`provider`,`environment`,`provider_event_id`),
  ADD KEY `idx_payment_event_status` (`processing_status`),
  ADD KEY `idx_payment_event_type` (`event_type`),
  ADD KEY `idx_payment_event_user` (`user_id`);

--
-- Indexes for table `plans`
--
ALTER TABLE `plans`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `registration_payments`
--
ALTER TABLE `registration_payments`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_registration_user` (`user_id`);

--
-- Indexes for table `scheme_clearances`
--
ALTER TABLE `scheme_clearances`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_subscription_clearance` (`subscription_id`),
  ADD UNIQUE KEY `unique_clearance_code` (`clearance_code`),
  ADD KEY `idx_clearance_user` (`user_id`),
  ADD KEY `idx_clearance_plan` (`plan_id`);

--
-- Indexes for table `settings`
--
ALTER TABLE `settings`
  ADD PRIMARY KEY (`id`);

--
-- Indexes for table `subscriptions`
--
ALTER TABLE `subscriptions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `fk_subscription_user` (`user_id`),
  ADD KEY `fk_subscription_plan` (`plan_id`);

--
-- Indexes for table `subscription_defaults`
--
ALTER TABLE `subscription_defaults`
  ADD PRIMARY KEY (`id`),
  ADD KEY `subscription_id` (`subscription_id`),
  ADD KEY `user_id` (`user_id`),
  ADD KEY `plan_id` (`plan_id`),
  ADD KEY `default_date` (`default_date`),
  ADD KEY `contribution_id` (`contribution_id`);

--
-- Indexes for table `users`
--
ALTER TABLE `users`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `phone` (`phone`);

--
-- Indexes for table `wallet_transactions`
--
ALTER TABLE `wallet_transactions`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `uq_wallet_reference` (`reference`),
  ADD KEY `fk_wallet_user` (`user_id`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `admins`
--
ALTER TABLE `admins`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `contributions`
--
ALTER TABLE `contributions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=364;

--
-- AUTO_INCREMENT for table `funding_account_requests`
--
ALTER TABLE `funding_account_requests`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `member_virtual_accounts`
--
ALTER TABLE `member_virtual_accounts`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `notifications`
--
ALTER TABLE `notifications`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=29;

--
-- AUTO_INCREMENT for table `password_reset_requests`
--
ALTER TABLE `password_reset_requests`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

--
-- AUTO_INCREMENT for table `payment_events`
--
ALTER TABLE `payment_events`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `plans`
--
ALTER TABLE `plans`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=20;

--
-- AUTO_INCREMENT for table `registration_payments`
--
ALTER TABLE `registration_payments`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;

--
-- AUTO_INCREMENT for table `scheme_clearances`
--
ALTER TABLE `scheme_clearances`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `settings`
--
ALTER TABLE `settings`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `subscriptions`
--
ALTER TABLE `subscriptions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=40;

--
-- AUTO_INCREMENT for table `subscription_defaults`
--
ALTER TABLE `subscription_defaults`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;

--
-- AUTO_INCREMENT for table `wallet_transactions`
--
ALTER TABLE `wallet_transactions`
  MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=69;

--
-- Constraints for dumped tables
--

--
-- Constraints for table `contributions`
--
ALTER TABLE `contributions`
  ADD CONSTRAINT `fk_contribution_subscription` FOREIGN KEY (`subscription_id`) REFERENCES `subscriptions` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `funding_account_requests`
--
ALTER TABLE `funding_account_requests`
  ADD CONSTRAINT `fk_funding_request_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `member_virtual_accounts`
--
ALTER TABLE `member_virtual_accounts`
  ADD CONSTRAINT `fk_virtual_account_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `notifications`
--
ALTER TABLE `notifications`
  ADD CONSTRAINT `fk_notification_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `password_reset_requests`
--
ALTER TABLE `password_reset_requests`
  ADD CONSTRAINT `fk_password_reset_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `payment_events`
--
ALTER TABLE `payment_events`
  ADD CONSTRAINT `fk_payment_event_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;

--
-- Constraints for table `registration_payments`
--
ALTER TABLE `registration_payments`
  ADD CONSTRAINT `fk_registration_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `scheme_clearances`
--
ALTER TABLE `scheme_clearances`
  ADD CONSTRAINT `fk_clearance_plan` FOREIGN KEY (`plan_id`) REFERENCES `plans` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_clearance_subscription` FOREIGN KEY (`subscription_id`) REFERENCES `subscriptions` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_clearance_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `subscriptions`
--
ALTER TABLE `subscriptions`
  ADD CONSTRAINT `fk_subscription_plan` FOREIGN KEY (`plan_id`) REFERENCES `plans` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_subscription_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `subscription_defaults`
--
ALTER TABLE `subscription_defaults`
  ADD CONSTRAINT `fk_default_contribution` FOREIGN KEY (`contribution_id`) REFERENCES `contributions` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_default_plan` FOREIGN KEY (`plan_id`) REFERENCES `plans` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_default_subscription` FOREIGN KEY (`subscription_id`) REFERENCES `subscriptions` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `fk_default_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `wallet_transactions`
--
ALTER TABLE `wallet_transactions`
  ADD CONSTRAINT `fk_wallet_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE;
COMMIT;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
