-- --------------------------------------------------------
-- Host:                         127.0.0.1
-- Server version:               8.0.29 - MySQL Community Server - GPL
-- Server OS:                    Win64
-- HeidiSQL Version:             11.2.0.6213
-- --------------------------------------------------------

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

-- Dumping structure for table hgagent.retail_customers
DROP TABLE IF EXISTS `retail_customers`;
CREATE TABLE IF NOT EXISTS `retail_customers` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT,
  `agent_id` bigint unsigned DEFAULT NULL,
  `name` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `ic_number` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `gender` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `civil_status` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `contact_number` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `education_level` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `area_cities_cover` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `answer_question_1` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `agent_code` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `referral` longtext COLLATE utf8mb4_unicode_ci,
  `upload_ic_path` longtext COLLATE utf8mb4_unicode_ci,
  `upload_ssm_path` longtext COLLATE utf8mb4_unicode_ci,
  `status` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email_verified_at` datetime DEFAULT NULL,
  `password` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `remember_token` varchar(191) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL,
  `referral_id` bigint unsigned DEFAULT NULL,
  `payment_term_id` bigint unsigned DEFAULT NULL,
  `grade_id` bigint unsigned DEFAULT NULL,
  `referral_fee_id` bigint unsigned DEFAULT NULL,
  `salesperson_id` bigint unsigned DEFAULT NULL,
  `state_id` bigint unsigned DEFAULT NULL,
  `city_id` bigint unsigned DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `retail_customers_ic_number_unique` (`ic_number`),
  UNIQUE KEY `retail_customers_email_unique` (`email`),
  KEY `retail_customers_referral_id_foreign` (`referral_id`),
  KEY `retail_customers_payment_term_id_foreign` (`payment_term_id`),
  KEY `retail_customers_grade_id_foreign` (`grade_id`),
  KEY `retail_customers_referral_fee_id_foreign` (`referral_fee_id`),
  KEY `retail_customers_salesperson_id_foreign` (`salesperson_id`),
  KEY `retail_customers_state_id_foreign` (`state_id`),
  KEY `retail_customers_city_id_foreign` (`city_id`),
  CONSTRAINT `retail_customers_city_id_foreign` FOREIGN KEY (`city_id`) REFERENCES `cities` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  CONSTRAINT `retail_customers_grade_id_foreign` FOREIGN KEY (`grade_id`) REFERENCES `grades` (`id`),
  CONSTRAINT `retail_customers_payment_term_id_foreign` FOREIGN KEY (`payment_term_id`) REFERENCES `payment_terms` (`id`),
  CONSTRAINT `retail_customers_referral_fee_id_foreign` FOREIGN KEY (`referral_fee_id`) REFERENCES `referral_fees` (`id`),
  CONSTRAINT `retail_customers_referral_id_foreign` FOREIGN KEY (`referral_id`) REFERENCES `agent_codes` (`id`),
  CONSTRAINT `retail_customers_salesperson_id_foreign` FOREIGN KEY (`salesperson_id`) REFERENCES `agent_codes` (`id`),
  CONSTRAINT `retail_customers_state_id_foreign` FOREIGN KEY (`state_id`) REFERENCES `states` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- Dumping data for table hgagent.retail_customers: ~0 rows (approximately)
DELETE FROM `retail_customers`;
/*!40000 ALTER TABLE `retail_customers` DISABLE KEYS */;
INSERT INTO `retail_customers` (`id`, `agent_id`, `name`, `ic_number`, `address`, `gender`, `civil_status`, `contact_number`, `email`, `education_level`, `area_cities_cover`, `answer_question_1`, `agent_code`, `referral`, `upload_ic_path`, `upload_ssm_path`, `status`, `email_verified_at`, `password`, `remember_token`, `created_at`, `updated_at`, `deleted_at`, `referral_id`, `payment_term_id`, `grade_id`, `referral_fee_id`, `salesperson_id`, `state_id`, `city_id`) VALUES
	(1, NULL, 'Test Retail Customer', '981032031111', '1109 N Highland St, Arlington, VA', '0', '0', '01238784232', 'retailCustomer@customer.com', '0', NULL, NULL, NULL, NULL, NULL, NULL, '0', NULL, 'password', NULL, '2022-08-04 16:56:08', '2022-08-04 16:56:08', NULL, NULL, NULL, NULL, NULL, NULL, 3, 589),
	(2, NULL, 'Test Retail Customer', '981032031555', '1109 N Highland St, Arlington, VA', '0', '0', '01238784232', 'retailCustomer2@customer.com', '0', NULL, NULL, NULL, NULL, NULL, NULL, '0', NULL, 'password', NULL, '2022-08-04 17:10:42', '2022-08-04 17:10:42', NULL, NULL, NULL, NULL, NULL, NULL, 3, 589),
	(3, NULL, 'retailCustomer3', '981032031025', '1109 N Highland St, Arlington, VA', '0', '0', '01238784567', 'retailCustomer3@gmail.com', '0', NULL, NULL, NULL, NULL, NULL, NULL, '0', NULL, 'password', NULL, '2022-08-05 10:06:00', '2022-08-05 10:06:00', NULL, NULL, NULL, NULL, NULL, NULL, 3, 589);
/*!40000 ALTER TABLE `retail_customers` ENABLE KEYS */;

-- Dumping structure for table hgagent.retail_customer_role
DROP TABLE IF EXISTS `retail_customer_role`;
CREATE TABLE IF NOT EXISTS `retail_customer_role` (
  `retail_customer_id` bigint unsigned NOT NULL,
  `role_id` bigint unsigned NOT NULL,
  KEY `retail_customer_role_retail_customer_id_foreign` (`retail_customer_id`),
  KEY `retail_customer_role_role_id_foreign` (`role_id`),
  CONSTRAINT `retail_customer_role_retail_customer_id_foreign` FOREIGN KEY (`retail_customer_id`) REFERENCES `retail_customers` (`id`) ON DELETE CASCADE,
  CONSTRAINT `retail_customer_role_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci ROW_FORMAT=DYNAMIC;

-- Dumping data for table hgagent.retail_customer_role: ~0 rows (approximately)
DELETE FROM `retail_customer_role`;
/*!40000 ALTER TABLE `retail_customer_role` DISABLE KEYS */;
INSERT INTO `retail_customer_role` (`retail_customer_id`, `role_id`) VALUES
	(2, 4),
	(3, 4);
/*!40000 ALTER TABLE `retail_customer_role` ENABLE KEYS */;

/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IFNULL(@OLD_FOREIGN_KEY_CHECKS, 1) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40111 SET SQL_NOTES=IFNULL(@OLD_SQL_NOTES, 1) */;
