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

START TRANSACTION;



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

--
-- Table structure for table `cart_items`
--

CREATE TABLE `cart_items` (
  `id` bigint UNSIGNED NOT NULL,
  `cart_id` bigint UNSIGNED NOT NULL,
  `product_id` bigint UNSIGNED NOT NULL,
  `product_variant_id` bigint UNSIGNED DEFAULT NULL,
  `quantity` int NOT NULL,
  `price` decimal(10,2) 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 `cart_items`
--

INSERT INTO `cart_items` (`id`, `cart_id`, `product_id`, `product_variant_id`, `quantity`, `price`, `created_at`, `updated_at`) VALUES
(1, 1, 13, 27, 1, 4.99, '2026-02-06 07:32:50', '2026-02-06 07:32:50'),
(2, 2, 2, 4, 1, 2.99, '2026-02-06 07:39:51', '2026-02-06 07:39:51');

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

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

CREATE TABLE `categories` (
  `id` bigint UNSIGNED NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `image` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `parent_id` bigint UNSIGNED DEFAULT NULL,
  `sort_order` int NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

INSERT INTO `categories` (`id`, `name`, `slug`, `description`, `image`, `parent_id`, `sort_order`, `is_active`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'Fruits', 'fruits', 'Fresh fruits and vegetables', NULL, NULL, 1, 1, '2026-01-27 05:51:52', '2026-01-27 05:51:52', NULL),
(2, 'Vegetables', 'vegetables', 'Fresh vegetables', NULL, NULL, 2, 1, '2026-01-27 05:51:52', '2026-01-27 05:51:52', NULL),
(3, 'Dairy & Eggs', 'dairy', 'Milk, cheese, eggs and dairy products', NULL, NULL, 3, 1, '2026-01-27 05:51:52', '2026-01-27 05:51:52', NULL),
(4, 'Meat & Seafood', 'meat-seafood', 'Fresh meat and seafood', NULL, NULL, 4, 1, '2026-01-27 05:51:53', '2026-01-27 05:51:53', NULL),
(5, 'Beverages', 'beverages', 'Drinks and beverages', NULL, NULL, 5, 1, '2026-01-27 05:51:53', '2026-01-27 05:51:53', NULL),
(6, 'Snacks', 'snacks', 'Snacks and chips', NULL, NULL, 6, 1, '2026-01-27 05:51:53', '2026-01-27 05:51:53', NULL);

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

--
-- Table structure for table `coupons`
--

CREATE TABLE `coupons` (
  `id` bigint UNSIGNED NOT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `type` enum('percentage','fixed') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'percentage',
  `discount_value` decimal(10,2) NOT NULL,
  `minimum_order_amount` decimal(10,2) NOT NULL DEFAULT '0.00',
  `maximum_discount` decimal(10,2) DEFAULT NULL,
  `usage_limit` int DEFAULT NULL,
  `used_count` int NOT NULL DEFAULT '0',
  `valid_from` date NOT NULL,
  `valid_until` date NOT NULL,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `applicable_categories` json DEFAULT NULL,
  `applicable_products` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

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

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

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

INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
(1, '2019_12_14_000001_create_personal_access_tokens_table', 1),
(2, '2024_01_01_000001_create_users_table', 1),
(3, '2024_01_01_000002_create_password_reset_tokens_table', 1),
(4, '2024_01_01_000003_create_sessions_table', 1),
(5, '2024_01_01_000004_create_categories_table', 1),
(6, '2024_01_01_000005_create_products_table', 1),
(7, '2024_01_01_000006_create_product_images_table', 1),
(8, '2024_01_01_000007_create_product_variants_table', 1),
(9, '2024_01_01_000008_create_carts_table', 1),
(10, '2024_01_01_000009_create_cart_items_table', 1),
(11, '2024_01_01_000010_create_orders_table', 1),
(12, '2024_01_01_000011_create_order_items_table', 1),
(13, '2024_01_01_000012_create_payments_table', 1),
(14, '2024_01_15_000001_add_sub_admin_role_to_users', 2),
(15, '2024_01_15_000002_create_coupons_table', 2),
(16, '2024_01_15_000003_create_settings_table', 2),
(17, '2024_01_15_000004_create_pages_table', 2),
(18, '2024_01_15_000005_create_stock_history_table', 2),
(19, '2024_01_15_000006_add_fields_to_orders_table', 2),
(20, '2024_01_15_000007_add_fields_to_products_table', 2),
(21, '2026_01_27_112033_create_cache_table', 3),
(22, '2026_01_29_000001_add_video_path_to_products_table', 4),
(23, '2026_01_29_100000_create_sliders_table', 4),
(24, '2026_01_29_200000_add_rating_to_orders_and_create_product_ratings', 4);

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

--
-- Table structure for table `orders`
--

CREATE TABLE `orders` (
  `id` bigint UNSIGNED NOT NULL,
  `order_number` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` bigint UNSIGNED NOT NULL,
  `status` enum('pending','paid','shipped','delivered','cancelled') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `subtotal` decimal(10,2) NOT NULL,
  `tax` decimal(10,2) NOT NULL DEFAULT '0.00',
  `shipping` decimal(10,2) NOT NULL DEFAULT '0.00',
  `discount` decimal(10,2) NOT NULL DEFAULT '0.00',
  `coupon_id` bigint UNSIGNED DEFAULT NULL,
  `total` decimal(10,2) NOT NULL,
  `currency` varchar(3) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'USD',
  `shipping_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `shipping_email` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `shipping_phone` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `shipping_address` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `shipping_city` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `shipping_state` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `shipping_postal_code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `shipping_country` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `admin_notes` text COLLATE utf8mb4_unicode_ci,
  `assigned_to` bigint UNSIGNED DEFAULT NULL,
  `paid_at` timestamp NULL DEFAULT NULL,
  `shipped_at` timestamp NULL DEFAULT NULL,
  `delivered_at` timestamp NULL DEFAULT NULL,
  `cancelled_at` timestamp NULL DEFAULT NULL,
  `rating` tinyint UNSIGNED DEFAULT NULL,
  `review_text` text COLLATE utf8mb4_unicode_ci,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `order_items`
--

CREATE TABLE `order_items` (
  `id` bigint UNSIGNED NOT NULL,
  `order_id` bigint UNSIGNED NOT NULL,
  `product_id` bigint UNSIGNED NOT NULL,
  `product_variant_id` bigint UNSIGNED DEFAULT NULL,
  `product_name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `variant_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sku` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `quantity` int NOT NULL,
  `price` decimal(10,2) NOT NULL,
  `subtotal` decimal(10,2) NOT NULL,
  `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 `pages`
--

CREATE TABLE `pages` (
  `id` bigint UNSIGNED NOT NULL,
  `slug` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `content` text COLLATE utf8mb4_unicode_ci NOT NULL,
  `meta_title` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `meta_description` text COLLATE utf8mb4_unicode_ci,
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `sort_order` int NOT NULL DEFAULT '0',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

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

--
-- Table structure for table `payments`
--

CREATE TABLE `payments` (
  `id` bigint UNSIGNED NOT NULL,
  `order_id` bigint UNSIGNED NOT NULL,
  `payment_method` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'stripe',
  `payment_intent_id` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `status` enum('pending','processing','succeeded','failed','cancelled','refunded') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'pending',
  `amount` decimal(10,2) NOT NULL,
  `currency` varchar(3) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'USD',
  `metadata` json DEFAULT NULL,
  `payment_details` json DEFAULT NULL,
  `paid_at` timestamp NULL DEFAULT NULL,
  `failed_at` timestamp NULL DEFAULT NULL,
  `failure_reason` text COLLATE utf8mb4_unicode_ci,
  `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 `products`
--

CREATE TABLE `products` (
  `id` bigint UNSIGNED NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `slug` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `description` text COLLATE utf8mb4_unicode_ci,
  `short_description` text COLLATE utf8mb4_unicode_ci,
  `sku` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `category_id` bigint UNSIGNED NOT NULL,
  `base_price` decimal(10,2) NOT NULL DEFAULT '0.00',
  `discount_price` decimal(10,2) DEFAULT NULL,
  `discount_start` date DEFAULT NULL,
  `discount_end` date DEFAULT NULL,
  `tax_rate` decimal(5,2) NOT NULL DEFAULT '0.00',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `is_featured` tinyint(1) NOT NULL DEFAULT '0',
  `sort_order` int NOT NULL DEFAULT '0',
  `meta` json DEFAULT NULL,
  `video_path` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `products`
--

INSERT INTO `products` (`id`, `name`, `slug`, `description`, `short_description`, `sku`, `category_id`, `base_price`, `discount_price`, `discount_start`, `discount_end`, `tax_rate`, `is_active`, `is_featured`, `sort_order`, `meta`, `video_path`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'Fresh Apples', 'fresh-apples', 'Fresh, crisp red apples perfect for snacking or cooking. Rich in fiber and vitamin C.', 'Crisp and sweet red apples', 'FRU-APP-001', 1, 4.99, 3.99, '2026-01-27', '2026-02-03', 0.00, 1, 1, 0, NULL, NULL, '2026-01-27 05:51:53', '2026-01-27 05:51:53', NULL),
(2, 'Bananas', 'bananas', 'Fresh yellow bananas, perfect for breakfast or smoothies. High in potassium.', 'Sweet and ripe bananas', 'FRU-BAN-001', 1, 2.99, NULL, NULL, NULL, 0.00, 1, 0, 0, NULL, NULL, '2026-01-27 05:51:53', '2026-01-27 05:51:53', NULL),
(3, 'Oranges', 'oranges', 'Sweet and juicy oranges packed with vitamin C.', 'Juicy fresh oranges', 'FRU-ORA-001', 1, 3.99, NULL, NULL, NULL, 0.00, 1, 0, 0, NULL, NULL, '2026-01-27 05:51:53', '2026-01-27 05:51:53', NULL),
(4, 'Fresh Tomatoes', 'fresh-tomatoes', 'Fresh, juicy red tomatoes perfect for salads and cooking.', 'Ripe red tomatoes', 'VEG-TOM-001', 2, 3.49, NULL, NULL, NULL, 0.00, 1, 1, 0, NULL, NULL, '2026-01-27 05:51:53', '2026-01-27 05:51:53', NULL),
(5, 'Carrots', 'carrots', 'Crisp and sweet organic carrots, great for snacking or cooking.', 'Fresh organic carrots', 'VEG-CAR-001', 2, 2.99, NULL, NULL, NULL, 0.00, 1, 0, 0, NULL, NULL, '2026-01-27 05:51:54', '2026-01-27 05:51:54', NULL),
(6, 'Broccoli', 'broccoli', 'Nutritious fresh broccoli, rich in vitamins and fiber.', 'Fresh green broccoli', 'VEG-BRO-001', 2, 4.99, NULL, NULL, NULL, 0.00, 1, 0, 0, NULL, NULL, '2026-01-27 05:51:54', '2026-01-27 05:51:54', NULL),
(7, 'Fresh Milk', 'fresh-milk', 'Fresh whole milk, pasteurized and homogenized.', 'Whole milk 1 liter', 'DAI-MIL-001', 3, 3.99, NULL, NULL, NULL, 0.00, 1, 1, 0, NULL, NULL, '2026-01-27 05:51:54', '2026-01-27 05:51:54', NULL),
(8, 'Free Range Eggs', 'free-range-eggs', 'Fresh free range eggs from happy hens.', '12 free range eggs', 'DAI-EGG-001', 3, 5.99, NULL, NULL, NULL, 0.00, 1, 0, 0, NULL, NULL, '2026-01-27 05:51:54', '2026-01-27 05:51:54', NULL),
(9, 'Cheddar Cheese', 'cheddar-cheese', 'Sharp and flavorful aged cheddar cheese.', 'Aged cheddar cheese', 'DAI-CHE-001', 3, 6.99, NULL, NULL, NULL, 0.00, 1, 0, 0, NULL, NULL, '2026-01-27 05:51:55', '2026-01-27 05:51:55', NULL),
(10, 'Chicken Breast', 'chicken-breast', 'Fresh, boneless chicken breast fillets. Perfect for grilling or baking.', 'Fresh chicken breast fillets', 'MEA-CHI-001', 4, 12.99, NULL, NULL, NULL, 0.00, 1, 1, 0, NULL, NULL, '2026-01-27 05:51:55', '2026-01-27 05:51:55', NULL),
(11, 'Salmon Fillet', 'salmon-fillet', 'Fresh Atlantic salmon fillet, rich in omega-3 fatty acids.', 'Fresh Atlantic salmon', 'MEA-SAL-001', 4, 18.99, NULL, NULL, NULL, 0.00, 1, 0, 0, NULL, NULL, '2026-01-27 05:51:55', '2026-01-27 05:51:55', NULL),
(12, 'Orange Juice', 'orange-juice', 'Fresh squeezed 100% pure orange juice, no added sugar.', '100% pure orange juice', 'BEV-OJU-001', 5, 4.99, NULL, NULL, NULL, 0.00, 1, 0, 0, NULL, NULL, '2026-01-27 05:51:55', '2026-01-27 05:51:55', NULL),
(13, 'Bottled Water', 'bottled-water', 'Pure natural spring water, 24 pack.', 'Natural spring water', 'BEV-WAT-001', 5, 8.99, NULL, NULL, NULL, 0.00, 1, 0, 0, NULL, NULL, '2026-01-27 05:51:55', '2026-01-27 05:51:55', NULL),
(14, 'Potato Chips', 'potato-chips', 'Crispy and delicious classic salted potato chips.', 'Classic salted potato chips', 'SNK-CHI-001', 6, 3.99, 2.99, '2026-01-27', '2026-02-10', 0.00, 1, 0, 0, NULL, NULL, '2026-01-27 05:51:56', '2026-01-31 05:12:29', NULL),
(15, 'Mixed Nuts', 'mixed-nuts', 'Premium roasted mixed nuts including almonds, cashews, and peanuts.', 'Roasted mixed nuts', 'SNK-NUT-001', 6, 12.99, NULL, NULL, NULL, 0.00, 1, 0, 0, NULL, NULL, '2026-01-27 05:51:56', '2026-01-27 05:51:56', NULL);

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

--
-- Table structure for table `product_images`
--

CREATE TABLE `product_images` (
  `id` bigint UNSIGNED NOT NULL,
  `product_id` bigint UNSIGNED NOT NULL,
  `image_path` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `alt_text` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sort_order` int NOT NULL DEFAULT '0',
  `is_primary` 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;

--
-- Dumping data for table `product_images`
--

INSERT INTO `product_images` (`id`, `product_id`, `image_path`, `alt_text`, `sort_order`, `is_primary`, `created_at`, `updated_at`) VALUES
(1, 14, 'products/fifdoqoiVmTjCWa2VreMXgt80lJ4oUUETr72CooO.jpg', NULL, 0, 1, '2026-01-31 05:12:30', '2026-01-31 05:12:30');

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

--
-- Table structure for table `product_ratings`
--

CREATE TABLE `product_ratings` (
  `id` bigint UNSIGNED NOT NULL,
  `order_id` bigint UNSIGNED NOT NULL,
  `product_id` bigint UNSIGNED NOT NULL,
  `rating` tinyint UNSIGNED NOT NULL,
  `review_text` text COLLATE utf8mb4_unicode_ci,
  `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 `product_variants`
--

CREATE TABLE `product_variants` (
  `id` bigint UNSIGNED NOT NULL,
  `product_id` bigint UNSIGNED NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `sku` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `price` decimal(10,2) NOT NULL,
  `stock_quantity` int NOT NULL DEFAULT '0',
  `min_stock_level` int NOT NULL DEFAULT '0',
  `is_active` tinyint(1) NOT NULL DEFAULT '1',
  `attributes` json DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL,
  `deleted_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `product_variants`
--

INSERT INTO `product_variants` (`id`, `product_id`, `name`, `sku`, `price`, `stock_quantity`, `min_stock_level`, `is_active`, `attributes`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 1, '1kg', 'FRU-APP-001-1KG', 4.99, 50, 10, 1, NULL, '2026-01-27 05:51:53', '2026-01-27 05:51:53', NULL),
(2, 1, '2kg', 'FRU-APP-001-2KG', 8.99, 30, 10, 1, NULL, '2026-01-27 05:51:53', '2026-01-27 05:51:53', NULL),
(3, 1, '5kg', 'FRU-APP-001-5KG', 19.99, 20, 10, 1, NULL, '2026-01-27 05:51:53', '2026-01-27 05:51:53', NULL),
(4, 2, '1kg', 'FRU-BAN-001-1KG', 2.99, 100, 10, 1, NULL, '2026-01-27 05:51:53', '2026-01-27 05:51:53', NULL),
(5, 2, '2kg', 'FRU-BAN-001-2KG', 5.49, 60, 10, 1, NULL, '2026-01-27 05:51:53', '2026-01-27 05:51:53', NULL),
(6, 3, '1kg', 'FRU-ORA-001-1KG', 3.99, 40, 10, 1, NULL, '2026-01-27 05:51:53', '2026-01-27 05:51:53', NULL),
(7, 3, '3kg', 'FRU-ORA-001-3KG', 10.99, 25, 10, 1, NULL, '2026-01-27 05:51:53', '2026-01-27 05:51:53', NULL),
(8, 4, '500g', 'VEG-TOM-001-500G', 3.49, 80, 10, 1, NULL, '2026-01-27 05:51:53', '2026-01-27 05:51:53', NULL),
(9, 4, '1kg', 'VEG-TOM-001-1KG', 6.49, 50, 10, 1, NULL, '2026-01-27 05:51:53', '2026-01-27 05:51:53', NULL),
(10, 5, '500g', 'VEG-CAR-001-500G', 2.99, 60, 10, 1, NULL, '2026-01-27 05:51:54', '2026-01-27 05:51:54', NULL),
(11, 5, '1kg', 'VEG-CAR-001-1KG', 5.49, 40, 10, 1, NULL, '2026-01-27 05:51:54', '2026-01-27 05:51:54', NULL),
(12, 6, '1 piece', 'VEG-BRO-001-PC', 4.99, 30, 10, 1, NULL, '2026-01-27 05:51:54', '2026-01-27 05:51:54', NULL),
(13, 6, '500g', 'VEG-BRO-001-500G', 4.99, 25, 10, 1, NULL, '2026-01-27 05:51:54', '2026-01-27 05:51:54', NULL),
(14, 7, '1L', 'DAI-MIL-001-1L', 3.99, 100, 10, 1, NULL, '2026-01-27 05:51:54', '2026-01-27 05:51:54', NULL),
(15, 7, '2L', 'DAI-MIL-001-2L', 7.49, 80, 10, 1, NULL, '2026-01-27 05:51:54', '2026-01-27 05:51:54', NULL),
(16, 8, '6 eggs', 'DAI-EGG-001-6', 3.49, 50, 10, 1, NULL, '2026-01-27 05:51:54', '2026-01-27 05:51:54', NULL),
(17, 8, '12 eggs', 'DAI-EGG-001-12', 5.99, 70, 10, 1, NULL, '2026-01-27 05:51:54', '2026-01-27 05:51:54', NULL),
(18, 8, '24 eggs', 'DAI-EGG-001-24', 10.99, 40, 10, 1, NULL, '2026-01-27 05:51:55', '2026-01-27 05:51:55', NULL),
(19, 9, '200g', 'DAI-CHE-001-200G', 6.99, 45, 10, 1, NULL, '2026-01-27 05:51:55', '2026-01-27 05:51:55', NULL),
(20, 9, '500g', 'DAI-CHE-001-500G', 15.99, 30, 10, 1, NULL, '2026-01-27 05:51:55', '2026-01-27 05:51:55', NULL),
(21, 10, '500g', 'MEA-CHI-001-500G', 12.99, 35, 10, 1, NULL, '2026-01-27 05:51:55', '2026-01-27 05:51:55', NULL),
(22, 10, '1kg', 'MEA-CHI-001-1KG', 24.99, 25, 10, 1, NULL, '2026-01-27 05:51:55', '2026-01-27 05:51:55', NULL),
(23, 11, '300g', 'MEA-SAL-001-300G', 18.99, 20, 10, 1, NULL, '2026-01-27 05:51:55', '2026-01-27 05:51:55', NULL),
(24, 11, '500g', 'MEA-SAL-001-500G', 29.99, 15, 10, 1, NULL, '2026-01-27 05:51:55', '2026-01-27 05:51:55', NULL),
(25, 12, '1L', 'BEV-OJU-001-1L', 4.99, 60, 10, 1, NULL, '2026-01-27 05:51:55', '2026-01-27 05:51:55', NULL),
(26, 12, '2L', 'BEV-OJU-001-2L', 8.99, 40, 10, 1, NULL, '2026-01-27 05:51:55', '2026-01-27 05:51:55', NULL),
(27, 13, '12 pack', 'BEV-WAT-001-12', 4.99, 100, 10, 1, NULL, '2026-01-27 05:51:55', '2026-01-27 05:51:55', NULL),
(28, 13, '24 pack', 'BEV-WAT-001-24', 8.99, 80, 10, 1, NULL, '2026-01-27 05:51:56', '2026-01-27 05:51:56', NULL),
(29, 14, '150g', 'SNK-CHI-001-150G', 3.99, 90, 10, 1, NULL, '2026-01-27 05:51:56', '2026-01-27 05:51:56', NULL),
(30, 14, '300g', 'SNK-CHI-001-300G', 6.99, 50, 10, 1, NULL, '2026-01-27 05:51:56', '2026-01-27 05:51:56', NULL),
(31, 15, '250g', 'SNK-NUT-001-250G', 12.99, 40, 10, 1, NULL, '2026-01-27 05:51:56', '2026-01-27 05:51:56', NULL),
(32, 15, '500g', 'SNK-NUT-001-500G', 23.99, 30, 10, 1, NULL, '2026-01-27 05:51:56', '2026-01-27 05:51:56', NULL);

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

--
-- Table structure for table `sessions`
--

CREATE TABLE `sessions` (
  `id` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `user_id` bigint UNSIGNED DEFAULT NULL,
  `ip_address` varchar(45) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `user_agent` text COLLATE utf8mb4_unicode_ci,
  `payload` longtext COLLATE utf8mb4_unicode_ci NOT NULL,
  `last_activity` int NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Dumping data for table `sessions`
--

INSERT INTO `sessions` (`id`, `user_id`, `ip_address`, `user_agent`, `payload`, `last_activity`) VALUES
('BO7jOByseKriEZ8D6Cu1QyPp7fqxnlbIhzrnXxtb', NULL, '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36', 'YTozOntzOjY6Il90b2tlbiI7czo0MDoiNmxqb0JwalNod0M0ODBPaGI4ekUyc29yNmFwUmJib0oyS2dDQnNYcSI7czo5OiJfcHJldmlvdXMiO2E6MTp7czozOiJ1cmwiO3M6MjE6Imh0dHA6Ly8xMjcuMC4wLjE6ODAwMCI7fXM6NjoiX2ZsYXNoIjthOjI6e3M6Mzoib2xkIjthOjA6e31zOjM6Im5ldyI7YTowOnt9fX0=', 1770015273),
('ezVQrJG2YlJ2n2nIFSq5HIMMy0iEg9oGpqnPWjud', NULL, '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36', 'YTozOntzOjY6Il90b2tlbiI7czo0MDoiS2VaVGkxN3dMejdjWEFpNGJaR2Vlb284NnNkdFh5ZXd5Uk9wbTNjWiI7czo5OiJfcHJldmlvdXMiO2E6MTp7czozOiJ1cmwiO3M6MjE6Imh0dHA6Ly8xMjcuMC4wLjE6ODAwMCI7fXM6NjoiX2ZsYXNoIjthOjI6e3M6Mzoib2xkIjthOjA6e31zOjM6Im5ldyI7YTowOnt9fX0=', 1769600092),
('H4aSSa0qoCT1CjrEjcCONtPiKn6O2aJyU4zKGbgA', 1, '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36', 'YTo0OntzOjY6Il90b2tlbiI7czo0MDoic1VSR01rdnBDZTc2cmF2YXNISXh3dkRoVXFwSnhjVUU4VzFNdEFHZSI7czo5OiJfcHJldmlvdXMiO2E6MTp7czozOiJ1cmwiO3M6NDQ6Imh0dHA6Ly8xMjcuMC4wLjE6ODAwMC9hZG1pbi9wcm9kdWN0cy8xNC9lZGl0Ijt9czo2OiJfZmxhc2giO2E6Mjp7czozOiJvbGQiO2E6MDp7fXM6MzoibmV3IjthOjA6e319czo1MDoibG9naW5fd2ViXzU5YmEzNmFkZGMyYjJmOTQwMTU4MGYwMTRjN2Y1OGVhNGUzMDk4OWQiO2k6MTt9', 1769856150),
('KPBJAix3JjLNPtJiWlZnhM39n5SoSf8JGB9fB7Pv', 1, '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36', 'YTo0OntzOjY6Il90b2tlbiI7czo0MDoicGlDcnJpb01xc3pDeHVXbUdxZHNwNnNSemRlcW1kSHlaaVNWQ3NIQyI7czo5OiJfcHJldmlvdXMiO2E6MTp7czozOiJ1cmwiO3M6Mjc6Imh0dHA6Ly8xMjcuMC4wLjE6ODAwMC9hZG1pbiI7fXM6NjoiX2ZsYXNoIjthOjI6e3M6Mzoib2xkIjthOjA6e31zOjM6Im5ldyI7YTowOnt9fXM6NTA6ImxvZ2luX3dlYl81OWJhMzZhZGRjMmIyZjk0MDE1ODBmMDE0YzdmNThlYTRlMzA5ODlkIjtpOjE7fQ==', 1769513168),
('oGDDi0dBtcu8g3J2qPA4iPgxOokvSr4Clq0NfWCQ', NULL, '192.168.0.180', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36', 'YTozOntzOjY6Il90b2tlbiI7czo0MDoiOWFyb2NuQ3g0SjhPVEdhalBEWFNCb0RVQVpxZjRUY1lTbzdMUWdadiI7czo5OiJfcHJldmlvdXMiO2E6MTp7czozOiJ1cmwiO3M6MjU6Imh0dHA6Ly8xOTIuMTY4LjAuMTgwOjgwMDAiO31zOjY6Il9mbGFzaCI7YToyOntzOjM6Im9sZCI7YTowOnt9czozOiJuZXciO2E6MDp7fX19', 1769600121),
('SABgGh3mTeUEOmmlNGvJdHpRGQaRtSG7o7de2aec', 5, '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36', 'YTo1OntzOjY6Il90b2tlbiI7czo0MDoiZUlhak5DZVBnMkYwMktaVHJJSVlzOTVESHJ5ZnhqdkNONnlJNkc3RiI7czo5OiJfcHJldmlvdXMiO2E6MTp7czozOiJ1cmwiO3M6MjE6Imh0dHA6Ly8xMjcuMC4wLjE6ODAwMCI7fXM6NjoiX2ZsYXNoIjthOjI6e3M6Mzoib2xkIjthOjA6e31zOjM6Im5ldyI7YTowOnt9fXM6MzoidXJsIjthOjE6e3M6ODoiaW50ZW5kZWQiO3M6MzA6Imh0dHA6Ly8xMjcuMC4wLjE6ODAwMC9jaGVja291dCI7fXM6NTA6ImxvZ2luX3dlYl81OWJhMzZhZGRjMmIyZjk0MDE1ODBmMDE0YzdmNThlYTRlMzA5ODlkIjtpOjU7fQ==', 1770384328),
('t6qq9lbwCi2oMFuoI7u6VIKeZlkBpnwSWTrienlV', NULL, '127.0.0.1', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36', 'YTozOntzOjY6Il90b2tlbiI7czo0MDoiWFM0NG55bHZXRlh4NFBaS1BCclRCbVB0QTc3N3JDdndBSnVUdlAxaSI7czo5OiJfcHJldmlvdXMiO2E6MTp7czozOiJ1cmwiO3M6MjE6Imh0dHA6Ly8xMjcuMC4wLjE6ODAwMCI7fXM6NjoiX2ZsYXNoIjthOjI6e3M6Mzoib2xkIjthOjA6e31zOjM6Im5ldyI7YTowOnt9fX0=', 1769520505),
('thjWBpXvEiyhEw4bBoehoZ7hnp9tVJWlCvx9f3Yh', NULL, '127.0.0.1', 'Mozilla/5.0 (Windows NT; Windows NT 10.0; en-US) WindowsPowerShell/5.1.22621.4249', 'YTozOntzOjY6Il90b2tlbiI7czo0MDoiZzVla1ZzR0ZVS1JNTDJZa2luWjFxWnEyOXVxVlRvS1Z1MTZpckJqWSI7czo5OiJfcHJldmlvdXMiO2E6MTp7czozOiJ1cmwiO3M6MzM6Imh0dHA6Ly9sb2NhbGhvc3Q6ODAwMC9hZG1pbi9sb2dpbiI7fXM6NjoiX2ZsYXNoIjthOjI6e3M6Mzoib2xkIjthOjA6e31zOjM6Im5ldyI7YTowOnt9fX0=', 1769511973);

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

--
-- Table structure for table `sliders`
--

CREATE TABLE `sliders` (
  `id` bigint UNSIGNED NOT NULL,
  `title` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `subtitle` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `image_path` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `link_url` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `background_color` varchar(20) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sort_order` smallint UNSIGNED NOT NULL DEFAULT '0',
  `is_active` tinyint(1) 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 `stock_history`
--

CREATE TABLE `stock_history` (
  `id` bigint UNSIGNED NOT NULL,
  `product_variant_id` bigint UNSIGNED NOT NULL,
  `type` enum('in','out','adjustment','sale','return') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'adjustment',
  `quantity` int NOT NULL,
  `previous_stock` int NOT NULL,
  `new_stock` int NOT NULL,
  `reference_type` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reference_id` bigint UNSIGNED DEFAULT NULL,
  `notes` text COLLATE utf8mb4_unicode_ci,
  `user_id` bigint UNSIGNED DEFAULT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

--
-- Indexes for table `cart_items`
--
ALTER TABLE `cart_items`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `unique_cart_item` (`cart_id`,`product_id`,`product_variant_id`),
  ADD KEY `cart_items_cart_id_index` (`cart_id`),
  ADD KEY `cart_items_product_id_index` (`product_id`),
  ADD KEY `cart_items_product_variant_id_index` (`product_variant_id`);

--
-- Indexes for table `categories`
--
ALTER TABLE `categories`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `categories_slug_unique` (`slug`),
  ADD KEY `categories_slug_index` (`slug`),
  ADD KEY `categories_parent_id_index` (`parent_id`),
  ADD KEY `categories_is_active_index` (`is_active`),
  ADD KEY `categories_sort_order_index` (`sort_order`);

--
-- Indexes for table `coupons`
--
ALTER TABLE `coupons`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `coupons_code_unique` (`code`),
  ADD KEY `coupons_code_index` (`code`),
  ADD KEY `coupons_is_active_index` (`is_active`),
  ADD KEY `coupons_valid_from_index` (`valid_from`),
  ADD KEY `coupons_valid_until_index` (`valid_until`);

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

--
-- Indexes for table `orders`
--
ALTER TABLE `orders`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `orders_order_number_unique` (`order_number`),
  ADD KEY `orders_order_number_index` (`order_number`),
  ADD KEY `orders_user_id_index` (`user_id`),
  ADD KEY `orders_status_index` (`status`),
  ADD KEY `orders_created_at_index` (`created_at`),
  ADD KEY `orders_coupon_id_foreign` (`coupon_id`),
  ADD KEY `orders_assigned_to_foreign` (`assigned_to`);

--
-- Indexes for table `order_items`
--
ALTER TABLE `order_items`
  ADD PRIMARY KEY (`id`),
  ADD KEY `order_items_order_id_index` (`order_id`),
  ADD KEY `order_items_product_id_index` (`product_id`),
  ADD KEY `order_items_product_variant_id_index` (`product_variant_id`);

--
-- Indexes for table `pages`
--
ALTER TABLE `pages`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `pages_slug_unique` (`slug`),
  ADD KEY `pages_slug_index` (`slug`),
  ADD KEY `pages_is_active_index` (`is_active`);

--
-- Indexes for table `payments`
--
ALTER TABLE `payments`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `payments_payment_intent_id_unique` (`payment_intent_id`),
  ADD KEY `payments_order_id_index` (`order_id`),
  ADD KEY `payments_payment_intent_id_index` (`payment_intent_id`),
  ADD KEY `payments_status_index` (`status`),
  ADD KEY `payments_payment_method_index` (`payment_method`);

--
-- Indexes for table `products`
--
ALTER TABLE `products`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `products_slug_unique` (`slug`),
  ADD UNIQUE KEY `products_sku_unique` (`sku`),
  ADD KEY `products_slug_index` (`slug`),
  ADD KEY `products_sku_index` (`sku`),
  ADD KEY `products_category_id_index` (`category_id`),
  ADD KEY `products_is_active_index` (`is_active`),
  ADD KEY `products_is_featured_index` (`is_featured`);

--
-- Indexes for table `product_images`
--
ALTER TABLE `product_images`
  ADD PRIMARY KEY (`id`),
  ADD KEY `product_images_product_id_index` (`product_id`),
  ADD KEY `product_images_is_primary_index` (`is_primary`),
  ADD KEY `product_images_sort_order_index` (`sort_order`);

--
-- Indexes for table `product_ratings`
--
ALTER TABLE `product_ratings`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `product_ratings_order_id_product_id_unique` (`order_id`,`product_id`),
  ADD KEY `product_ratings_product_id_index` (`product_id`);

--
-- Indexes for table `product_variants`
--
ALTER TABLE `product_variants`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `product_variants_sku_unique` (`sku`),
  ADD KEY `product_variants_product_id_index` (`product_id`),
  ADD KEY `product_variants_sku_index` (`sku`),
  ADD KEY `product_variants_is_active_index` (`is_active`),
  ADD KEY `product_variants_stock_quantity_index` (`stock_quantity`);

--
-- Indexes for table `sessions`
--
ALTER TABLE `sessions`
  ADD PRIMARY KEY (`id`),
  ADD KEY `sessions_user_id_index` (`user_id`),
  ADD KEY `sessions_last_activity_index` (`last_activity`);

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

--
-- Indexes for table `stock_history`
--
ALTER TABLE `stock_history`
  ADD PRIMARY KEY (`id`),
  ADD KEY `stock_history_user_id_foreign` (`user_id`),
  ADD KEY `stock_history_product_variant_id_index` (`product_variant_id`),
  ADD KEY `stock_history_type_index` (`type`),
  ADD KEY `stock_history_created_at_index` (`created_at`),
  ADD KEY `stock_history_reference_type_reference_id_index` (`reference_type`,`reference_id`);

--
-- AUTO_INCREMENT for table `cart_items`
--
ALTER TABLE `cart_items`
  MODIFY `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

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

--
-- AUTO_INCREMENT for table `coupons`
--
ALTER TABLE `coupons`
  MODIFY `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `migrations`
--
ALTER TABLE `migrations`
  MODIFY `id` int UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=25;

--
-- AUTO_INCREMENT for table `orders`
--
ALTER TABLE `orders`
  MODIFY `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `order_items`
--
ALTER TABLE `order_items`
  MODIFY `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `pages`
--
ALTER TABLE `pages`
  MODIFY `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `payments`
--
ALTER TABLE `payments`
  MODIFY `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `products`
--
ALTER TABLE `products`
  MODIFY `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=16;

--
-- AUTO_INCREMENT for table `product_images`
--
ALTER TABLE `product_images`
  MODIFY `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `product_ratings`
--
ALTER TABLE `product_ratings`
  MODIFY `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `product_variants`
--
ALTER TABLE `product_variants`
  MODIFY `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=33;

--
-- AUTO_INCREMENT for table `sliders`
--
ALTER TABLE `sliders`
  MODIFY `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `stock_history`
--
ALTER TABLE `stock_history`
  MODIFY `id` bigint UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- Constraints for table `cart_items`
--
ALTER TABLE `cart_items`
  ADD CONSTRAINT `cart_items_cart_id_foreign` FOREIGN KEY (`cart_id`) REFERENCES `carts` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `cart_items_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `cart_items_product_variant_id_foreign` FOREIGN KEY (`product_variant_id`) REFERENCES `product_variants` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `categories`
--
ALTER TABLE `categories`
  ADD CONSTRAINT `categories_parent_id_foreign` FOREIGN KEY (`parent_id`) REFERENCES `categories` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `orders`
--
ALTER TABLE `orders`
  ADD CONSTRAINT `orders_assigned_to_foreign` FOREIGN KEY (`assigned_to`) REFERENCES `users` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `orders_coupon_id_foreign` FOREIGN KEY (`coupon_id`) REFERENCES `coupons` (`id`) ON DELETE SET NULL,
  ADD CONSTRAINT `orders_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE RESTRICT;

--
-- Constraints for table `order_items`
--
ALTER TABLE `order_items`
  ADD CONSTRAINT `order_items_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `order_items_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE RESTRICT,
  ADD CONSTRAINT `order_items_product_variant_id_foreign` FOREIGN KEY (`product_variant_id`) REFERENCES `product_variants` (`id`) ON DELETE RESTRICT;

--
-- Constraints for table `payments`
--
ALTER TABLE `payments`
  ADD CONSTRAINT `payments_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `products`
--
ALTER TABLE `products`
  ADD CONSTRAINT `products_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`) ON DELETE RESTRICT;

--
-- Constraints for table `product_images`
--
ALTER TABLE `product_images`
  ADD CONSTRAINT `product_images_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `product_ratings`
--
ALTER TABLE `product_ratings`
  ADD CONSTRAINT `product_ratings_order_id_foreign` FOREIGN KEY (`order_id`) REFERENCES `orders` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `product_ratings_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `product_variants`
--
ALTER TABLE `product_variants`
  ADD CONSTRAINT `product_variants_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON DELETE CASCADE;

--
-- Constraints for table `stock_history`
--
ALTER TABLE `stock_history`
  ADD CONSTRAINT `stock_history_product_variant_id_foreign` FOREIGN KEY (`product_variant_id`) REFERENCES `product_variants` (`id`) ON DELETE CASCADE,
  ADD CONSTRAINT `stock_history_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;
COMMIT;

