-- https://www.phpmyadmin.net/
--

START TRANSACTION;



--
-- Database: `raffle_tool`
--

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

--
-- Table structure for table `categories`
--

CREATE TABLE `categories` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `image` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL,
  `no_of_winners` smallint(5) UNSIGNED NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `draw_type_id` bigint(20) UNSIGNED DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `categories`
--

INSERT INTO `categories` (`id`, `name`, `image`, `no_of_winners`, `created_at`, `updated_at`, `draw_type_id`) VALUES
(1, 'Motorcycle', 'motorcycle.png', 3, '2022-08-12 07:09:26', '2022-08-12 07:09:26', 1),
(2, 'Cash prize', 'weekly_cash.png', 50, '2022-08-12 07:09:26', '2022-08-12 07:09:26', 1),
(3, 'Motorcycle', 'motorcycle.png', 3, '2022-08-12 07:09:26', '2022-08-12 07:09:26', 2),
(4, 'Monthly Cash Prize', 'weekly_cash.png', 50, '2022-08-12 07:09:26', '2022-08-12 07:09:26', 2),
(5, 'Double Saving', 'double_savings.png', 200, '2022-08-12 07:09:26', '2022-08-12 07:09:26', 2),
(6, 'Grand Prize', 'grand_prize.png', 1, '2022-08-12 07:09:26', '2022-08-12 07:09:26', 3);

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

--
-- Table structure for table `draws`
--

CREATE TABLE `draws` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `draw_type_id` bigint(20) UNSIGNED NOT NULL,
  `participants` int(10) UNSIGNED NOT NULL,
  `no_of_winners` mediumint(8) UNSIGNED NOT NULL DEFAULT 10,
  `schedule` datetime NOT NULL,
  `status` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'started',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `draw_types`
--

CREATE TABLE `draw_types` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `draw_types`
--

INSERT INTO `draw_types` (`id`, `name`, `created_at`, `updated_at`) VALUES
(1, 'Weekly', '2022-08-12 07:09:25', '2022-08-12 07:09:25'),
(2, 'Monthly', '2022-08-12 07:09:25', '2022-08-12 07:09:25'),
(3, 'Grand Prize', '2022-08-12 07:09:25', '2022-08-12 07:09:25');

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

--
-- Table structure for table `draw_winners`
--

CREATE TABLE `draw_winners` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `draw_id` bigint(20) UNSIGNED NOT NULL,
  `category_id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(240) COLLATE utf8mb4_unicode_ci NOT NULL,
  `phone_number` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'new',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `failed_jobs`
--

CREATE TABLE `failed_jobs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `uuid` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `connection` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `queue` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `exception` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `failed_at` timestamp NOT NULL DEFAULT current_timestamp()
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `grand_winners`
--

CREATE TABLE `grand_winners` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `participant_id` bigint(20) UNSIGNED NOT NULL,
  `status` smallint(5) UNSIGNED NOT NULL DEFAULT 1,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `migrations`
--

CREATE TABLE `migrations` (
  `id` int(10) UNSIGNED NOT NULL,
  `migration` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `batch` int(11) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `migrations`
--

INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
(1, '2014_10_12_000000_create_users_table', 1),
(2, '2014_10_12_100000_create_password_resets_table', 1),
(3, '2019_08_19_000000_create_failed_jobs_table', 1),
(4, '2019_12_14_000001_create_personal_access_tokens_table', 1),
(5, '2021_10_05_115200_create_draw_types_table', 1),
(6, '2021_10_07_115109_create_participants_table', 1),
(7, '2021_10_07_115634_create_categories_table', 1),
(8, '2021_10_07_144637_create_draws_table', 1),
(9, '2021_10_07_145155_create_draw_winners_table', 1),
(10, '2021_10_25_061619_add_account_number_column_to_participants', 1),
(11, '2021_10_25_062341_add_no_of_winners_column_to_categories', 1),
(12, '2021_10_25_093849_add_draw_id_to_participants_table', 1),
(13, '2021_10_26_071202_create_grand_winners_table', 1),
(14, '2021_10_27_062628_add_image_name_to_categories_table', 1),
(15, '2021_10_27_065823_add_grand_prize_completed_flag_to_participants_table', 1),
(16, '2022_07_28_151745_add_draw_type_id_to_categories_table', 1),
(17, '2022_08_04_073545_drop_account_number_column_from_participants', 1),
(18, '2022_08_06_080558_create_sub_draw_types_table', 1);

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

--
-- Table structure for table `participants`
--

CREATE TABLE `participants` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `draw_id` bigint(20) UNSIGNED DEFAULT NULL,
  `name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `phone_number` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `haswon` smallint(5) UNSIGNED NOT NULL DEFAULT 0,
  `has_participated_grand_prize` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `sub_draw_types`
--

CREATE TABLE `sub_draw_types` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `sub_draw_types`
--

INSERT INTO `sub_draw_types` (`id`, `name`, `created_at`, `updated_at`) VALUES
(1, 'Motorcycle', '2022-08-12 07:09:26', '2022-08-12 07:09:26'),
(2, 'Cash Prize', '2022-08-12 07:09:26', '2022-08-12 07:09:26'),
(3, 'Monthly Motorcycle', '2022-08-12 07:09:26', '2022-08-12 07:09:26'),
(4, 'Monthly Cash Prize', '2022-08-12 07:09:26', '2022-08-12 07:09:26'),
(5, 'Double Saving', '2022-08-12 07:09:26', '2022-08-12 07:09:26');

--
-- Indexes for dumped tables
--

--
-- Indexes for table `categories`
--
ALTER TABLE `categories`
  ADD PRIMARY KEY (`id`),
  ADD KEY `categories_draw_type_id_foreign` (`draw_type_id`);

--
-- Indexes for table `draws`
--
ALTER TABLE `draws`
  ADD PRIMARY KEY (`id`),
  ADD KEY `draws_draw_type_id_foreign` (`draw_type_id`);

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

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

--
-- Indexes for table `failed_jobs`
--
ALTER TABLE `failed_jobs`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`);

--
-- Indexes for table `grand_winners`
--
ALTER TABLE `grand_winners`
  ADD PRIMARY KEY (`id`),
  ADD KEY `grand_winners_participant_id_foreign` (`participant_id`);

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

--
-- Indexes for table `participants`
--
ALTER TABLE `participants`
  ADD PRIMARY KEY (`id`),
  ADD KEY `participants_phone_number_haswon_index` (`phone_number`,`haswon`);

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

--
-- AUTO_INCREMENT for dumped tables
--

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

--
-- AUTO_INCREMENT for table `draws`
--
ALTER TABLE `draws`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

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

--
-- AUTO_INCREMENT for table `draw_winners`
--
ALTER TABLE `draw_winners`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `failed_jobs`
--
ALTER TABLE `failed_jobs`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `grand_winners`
--
ALTER TABLE `grand_winners`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `migrations`
--
ALTER TABLE `migrations`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=19;

--
-- AUTO_INCREMENT for table `participants`
--
ALTER TABLE `participants`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

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

--
-- Constraints for dumped tables
--

--
-- Constraints for table `categories`
--
ALTER TABLE `categories`
  ADD CONSTRAINT `categories_draw_type_id_foreign` FOREIGN KEY (`draw_type_id`) REFERENCES `draw_types` (`id`);

--
-- Constraints for table `draws`
--
ALTER TABLE `draws`
  ADD CONSTRAINT `draws_draw_type_id_foreign` FOREIGN KEY (`draw_type_id`) REFERENCES `draw_types` (`id`);

--
-- Constraints for table `grand_winners`
--
ALTER TABLE `grand_winners`
  ADD CONSTRAINT `grand_winners_participant_id_foreign` FOREIGN KEY (`participant_id`) REFERENCES `participants` (`id`);
COMMIT;

