START TRANSACTION;



CREATE TABLE `categories` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `name` 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;

INSERT INTO `categories` (`id`, `code`, `name`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, NULL, 'Nouveauté', '2023-12-01 14:00:18', '2023-12-01 14:00:18', NULL),
(2, NULL, 'Souvent Acheté', '2023-12-01 14:00:18', '2023-12-01 14:00:18', NULL),
(3, NULL, 'Populaire', '2023-12-01 14:00:18', '2023-12-01 14:00:18', NULL);

CREATE TABLE `category_product` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `category_id` bigint(20) UNSIGNED NOT NULL,
  `product_id` bigint(20) UNSIGNED NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE `commands` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `date` datetime NOT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '1701439179',
  `supplier_id` bigint(20) UNSIGNED DEFAULT NULL,
  `products` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`products`)),
  `discount_on_total` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0',
  `total` double NOT NULL DEFAULT 0,
  `payment_method_id` bigint(20) UNSIGNED DEFAULT NULL,
  `tva` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0',
  `state_id` bigint(20) UNSIGNED 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;

CREATE TABLE `companies` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `slogan` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone1` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone2` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone3` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phone4` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email1` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email2` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `logo` 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;

INSERT INTO `companies` (`id`, `name`, `slogan`, `address`, `phone1`, `phone2`, `phone3`, `phone4`, `email1`, `email2`, `logo`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'Nom Compagnie', '', '', '+22812345678', '', '', '', 'email@email.com', '', 'images/logo.png', '2023-12-01 14:00:18', '2023-12-01 14:00:18', NULL);

CREATE TABLE `customers` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phones` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `shipping_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `shipping_address` 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;

CREATE TABLE `debtors` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `customer_id` bigint(20) UNSIGNED DEFAULT NULL,
  `sell_id` bigint(20) UNSIGNED DEFAULT NULL,
  `paid_amount` double 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;

CREATE TABLE `expenses` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `date` date DEFAULT NULL,
  `expense_type_id` bigint(20) UNSIGNED DEFAULT NULL,
  `description` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `amount` double DEFAULT NULL,
  `receipt` 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;

CREATE TABLE `expense_types` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `description` 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;

CREATE TABLE `failed_jobs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `uuid` varchar(255) 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;

CREATE TABLE `inventories` (
  `id` bigint(20) UNSIGNED NOT 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;

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

CREATE TABLE `logs` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `user_id` bigint(20) UNSIGNED DEFAULT NULL,
  `action` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
  `detail` varchar(255) COLLATE utf8mb4_unicode_ci NOT 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;

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

INSERT INTO `migrations` (`id`, `migration`, `batch`) VALUES
(83, '2014_10_12_000000_create_users_table', 1),
(84, '2014_10_12_100000_create_password_reset_tokens_table', 1),
(85, '2014_10_12_100000_create_password_resets_table', 1),
(86, '2019_08_19_000000_create_failed_jobs_table', 1),
(87, '2019_12_14_000001_create_personal_access_tokens_table', 1),
(88, '2020_07_27_174857_create_categories_table', 1),
(89, '2020_07_27_175010_create_unit_measures_table', 1),
(90, '2020_07_27_175016_create_products_table', 1),
(91, '2020_07_27_175017_create_product_details_table', 1),
(92, '2020_07_27_175018_create_states_table', 1),
(93, '2020_07_27_175424_create_payment_methods_table', 1),
(94, '2020_07_27_180334_create_movement_types_table', 1),
(95, '2020_07_27_180455_create_inventories_table', 1),
(96, '2020_07_27_180722_create_suppliers_table', 1),
(97, '2020_07_27_180803_create_customers_table', 1),
(98, '2020_07_29_162525_create_expense_types_table', 1),
(99, '2020_07_29_162535_create_expenses_table', 1),
(100, '2020_07_29_162609_create_invoices_table', 1),
(101, '2020_07_30_055205_create_stocks_table', 1),
(102, '2020_07_30_063705_create_out_types_table', 1),
(103, '2020_07_30_063706_create_sells_table', 1),
(104, '2020_08_06_150846_create_logs_table', 1),
(105, '2020_08_17_095047_create_companies_table', 1),
(106, '2020_08_18_063346_create_reports_table', 1),
(107, '2020_08_19_141815_create_roles_table', 1),
(108, '2020_08_19_141930_create_permissions_table', 1),
(109, '2020_08_19_141950_create_tables_table', 1),
(110, '2020_08_19_142024_create_role_user_table', 1),
(111, '2020_08_19_142044_create_permission_role_table', 1),
(112, '2020_08_19_142107_create_permission_table_table', 1),
(113, '2020_08_20_115644_create_debtors_table', 1),
(114, '2020_08_25_100729_create_printer_types_table', 1),
(115, '2020_08_25_100759_create_printers_table', 1),
(116, '2020_08_26_073717_create_navigator_types_table', 1),
(117, '2020_08_26_088604_create_navigators_table', 1),
(118, '2020_08_28_114520_create_role_table_table', 1),
(119, '2020_10_22_083406_create_commands_table', 1),
(120, '2021_01_02_121724_create_product_unit_measure_table', 1),
(121, '2021_04_23_111417_create_supplier_credits_table', 1),
(122, '2021_05_07_120456_create_return_stocks_table', 1),
(123, '2023_11_29_092332_create_category_products_table', 1);

CREATE TABLE `movement_types` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `movement` 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;

CREATE TABLE `navigators` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `navigator_type_id` bigint(20) UNSIGNED 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;

CREATE TABLE `navigator_types` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` 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;

CREATE TABLE `out_types` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `name` 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;

INSERT INTO `out_types` (`id`, `code`, `name`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, NULL, 'Vente', NULL, NULL, NULL),
(2, NULL, 'Echantillon', NULL, NULL, NULL),
(3, NULL, 'Administration', NULL, NULL, NULL),
(4, NULL, 'Autre', NULL, NULL, NULL);

CREATE TABLE `payment_methods` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `method` 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;

INSERT INTO `payment_methods` (`id`, `method`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'Especes', NULL, NULL, NULL),
(2, 'Flooz', NULL, NULL, NULL),
(3, 'Tmoney', NULL, NULL, NULL),
(4, 'Virement Bancaire', NULL, NULL, NULL),
(5, 'Cheque', NULL, NULL, NULL),
(6, 'Credit', NULL, NULL, NULL),
(7, 'Assurance', NULL, NULL, NULL);

CREATE TABLE `permissions` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT 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;

INSERT INTO `permissions` (`id`, `name`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'browse', NULL, NULL, NULL),
(2, 'edit', NULL, NULL, NULL),
(3, 'add', NULL, NULL, NULL),
(4, 'delete', NULL, NULL, NULL);

CREATE TABLE `permission_role` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `permission_id` bigint(20) UNSIGNED DEFAULT NULL,
  `role_id` bigint(20) UNSIGNED 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;

INSERT INTO `permission_role` (`id`, `permission_id`, `role_id`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 1, 1, NULL, NULL, NULL),
(2, 2, 1, NULL, NULL, NULL),
(3, 3, 1, NULL, NULL, NULL),
(4, 4, 1, NULL, NULL, NULL),
(5, 1, 2, NULL, NULL, NULL),
(6, 2, 2, NULL, NULL, NULL),
(7, 3, 2, NULL, NULL, NULL),
(8, 4, 2, NULL, NULL, NULL);

CREATE TABLE `permission_table` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `permission_id` bigint(20) UNSIGNED DEFAULT NULL,
  `table_id` bigint(20) UNSIGNED DEFAULT NULL,
  `role_id` bigint(20) UNSIGNED 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;

INSERT INTO `permission_table` (`id`, `permission_id`, `table_id`, `role_id`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 1, 1, 1, NULL, NULL, NULL),
(2, 2, 1, 1, NULL, NULL, NULL),
(3, 3, 1, 1, NULL, NULL, NULL),
(4, 4, 1, 1, NULL, NULL, NULL),
(5, 1, 2, 1, NULL, NULL, NULL),
(6, 2, 2, 1, NULL, NULL, NULL),
(7, 3, 2, 1, NULL, NULL, NULL),
(8, 4, 2, 1, NULL, NULL, NULL),
(9, 1, 3, 1, NULL, NULL, NULL),
(10, 2, 3, 1, NULL, NULL, NULL),
(11, 3, 3, 1, NULL, NULL, NULL),
(12, 4, 3, 1, NULL, NULL, NULL),
(13, 1, 4, 1, NULL, NULL, NULL),
(14, 2, 4, 1, NULL, NULL, NULL),
(15, 3, 4, 1, NULL, NULL, NULL),
(16, 4, 4, 1, NULL, NULL, NULL),
(17, 1, 5, 1, NULL, NULL, NULL),
(18, 2, 5, 1, NULL, NULL, NULL),
(19, 3, 5, 1, NULL, NULL, NULL),
(20, 4, 5, 1, NULL, NULL, NULL),
(21, 1, 6, 1, NULL, NULL, NULL),
(22, 2, 6, 1, NULL, NULL, NULL),
(23, 3, 6, 1, NULL, NULL, NULL),
(24, 4, 6, 1, NULL, NULL, NULL),
(25, 1, 7, 1, NULL, NULL, NULL),
(26, 2, 7, 1, NULL, NULL, NULL),
(27, 3, 7, 1, NULL, NULL, NULL),
(28, 4, 7, 1, NULL, NULL, NULL),
(29, 1, 8, 1, NULL, NULL, NULL),
(30, 2, 8, 1, NULL, NULL, NULL),
(31, 3, 8, 1, NULL, NULL, NULL),
(32, 4, 8, 1, NULL, NULL, NULL),
(33, 1, 9, 1, NULL, NULL, NULL),
(34, 2, 9, 1, NULL, NULL, NULL),
(35, 3, 9, 1, NULL, NULL, NULL),
(36, 4, 9, 1, NULL, NULL, NULL),
(37, 1, 10, 1, NULL, NULL, NULL),
(38, 2, 10, 1, NULL, NULL, NULL),
(39, 3, 10, 1, NULL, NULL, NULL),
(40, 4, 10, 1, NULL, NULL, NULL),
(41, 1, 11, 1, NULL, NULL, NULL),
(42, 2, 11, 1, NULL, NULL, NULL),
(43, 3, 11, 1, NULL, NULL, NULL),
(44, 4, 11, 1, NULL, NULL, NULL),
(45, 1, 12, 1, NULL, NULL, NULL),
(46, 2, 12, 1, NULL, NULL, NULL),
(47, 3, 12, 1, NULL, NULL, NULL),
(48, 4, 12, 1, NULL, NULL, NULL),
(49, 1, 13, 1, NULL, NULL, NULL),
(50, 2, 13, 1, NULL, NULL, NULL),
(51, 3, 13, 1, NULL, NULL, NULL),
(52, 4, 13, 1, NULL, NULL, NULL),
(53, 1, 14, 1, NULL, NULL, NULL),
(54, 2, 14, 1, NULL, NULL, NULL),
(55, 3, 14, 1, NULL, NULL, NULL),
(56, 4, 14, 1, NULL, NULL, NULL),
(57, 1, 15, 1, NULL, NULL, NULL),
(58, 2, 15, 1, NULL, NULL, NULL),
(59, 3, 15, 1, NULL, NULL, NULL),
(60, 4, 15, 1, NULL, NULL, NULL),
(61, 1, 16, 1, NULL, NULL, NULL),
(62, 2, 16, 1, NULL, NULL, NULL),
(63, 3, 16, 1, NULL, NULL, NULL),
(64, 4, 16, 1, NULL, NULL, NULL),
(65, 1, 17, 1, NULL, NULL, NULL),
(66, 2, 17, 1, NULL, NULL, NULL),
(67, 3, 17, 1, NULL, NULL, NULL),
(68, 4, 17, 1, NULL, NULL, NULL),
(69, 1, 18, 1, NULL, NULL, NULL),
(70, 2, 18, 1, NULL, NULL, NULL),
(71, 3, 18, 1, NULL, NULL, NULL),
(72, 4, 18, 1, NULL, NULL, NULL),
(73, 1, 19, 1, NULL, NULL, NULL),
(74, 2, 19, 1, NULL, NULL, NULL),
(75, 3, 19, 1, NULL, NULL, NULL),
(76, 4, 19, 1, NULL, NULL, NULL),
(77, 1, 20, 1, NULL, NULL, NULL),
(78, 2, 20, 1, NULL, NULL, NULL),
(79, 3, 20, 1, NULL, NULL, NULL),
(80, 4, 20, 1, NULL, NULL, NULL),
(81, 1, 21, 1, NULL, NULL, NULL),
(82, 2, 21, 1, NULL, NULL, NULL),
(83, 3, 21, 1, NULL, NULL, NULL),
(84, 4, 21, 1, NULL, NULL, NULL),
(85, 1, 22, 1, NULL, NULL, NULL),
(86, 2, 22, 1, NULL, NULL, NULL),
(87, 3, 22, 1, NULL, NULL, NULL),
(88, 4, 22, 1, NULL, NULL, NULL),
(89, 1, 23, 1, NULL, NULL, NULL),
(90, 2, 23, 1, NULL, NULL, NULL),
(91, 3, 23, 1, NULL, NULL, NULL),
(92, 4, 23, 1, NULL, NULL, NULL),
(93, 1, 24, 1, NULL, NULL, NULL),
(94, 2, 24, 1, NULL, NULL, NULL),
(95, 3, 24, 1, NULL, NULL, NULL),
(96, 4, 24, 1, NULL, NULL, NULL),
(97, 1, 25, 1, NULL, NULL, NULL),
(98, 2, 25, 1, NULL, NULL, NULL),
(99, 3, 25, 1, NULL, NULL, NULL),
(100, 4, 25, 1, NULL, NULL, NULL),
(101, 1, 26, 1, NULL, NULL, NULL),
(102, 2, 26, 1, NULL, NULL, NULL),
(103, 3, 26, 1, NULL, NULL, NULL),
(104, 4, 26, 1, NULL, NULL, NULL),
(105, 1, 27, 1, NULL, NULL, NULL),
(106, 2, 27, 1, NULL, NULL, NULL),
(107, 3, 27, 1, NULL, NULL, NULL),
(108, 4, 27, 1, NULL, NULL, NULL),
(109, 1, 28, 1, NULL, NULL, NULL),
(110, 2, 28, 1, NULL, NULL, NULL),
(111, 3, 28, 1, NULL, NULL, NULL),
(112, 4, 28, 1, NULL, NULL, NULL),
(113, 1, 29, 1, NULL, NULL, NULL),
(114, 2, 29, 1, NULL, NULL, NULL),
(115, 3, 29, 1, NULL, NULL, NULL),
(116, 4, 29, 1, NULL, NULL, NULL),
(117, 1, 30, 1, NULL, NULL, NULL),
(118, 2, 30, 1, NULL, NULL, NULL),
(119, 3, 30, 1, NULL, NULL, NULL),
(120, 4, 30, 1, NULL, NULL, NULL),
(121, 1, 31, 1, NULL, NULL, NULL),
(122, 2, 31, 1, NULL, NULL, NULL),
(123, 3, 31, 1, NULL, NULL, NULL),
(124, 4, 31, 1, NULL, NULL, NULL),
(125, 1, 32, 1, NULL, NULL, NULL),
(126, 2, 32, 1, NULL, NULL, NULL),
(127, 3, 32, 1, NULL, NULL, NULL),
(128, 4, 32, 1, NULL, NULL, NULL),
(129, 1, 33, 1, NULL, NULL, NULL),
(130, 2, 33, 1, NULL, NULL, NULL),
(131, 3, 33, 1, NULL, NULL, NULL),
(132, 4, 33, 1, NULL, NULL, NULL),
(133, 1, 34, 1, NULL, NULL, NULL),
(134, 2, 34, 1, NULL, NULL, NULL),
(135, 3, 34, 1, NULL, NULL, NULL),
(136, 4, 34, 1, NULL, NULL, NULL),
(137, 1, 35, 1, NULL, NULL, NULL),
(138, 2, 35, 1, NULL, NULL, NULL),
(139, 3, 35, 1, NULL, NULL, NULL),
(140, 4, 35, 1, NULL, NULL, NULL),
(141, 1, 36, 1, NULL, NULL, NULL),
(142, 2, 36, 1, NULL, NULL, NULL),
(143, 3, 36, 1, NULL, NULL, NULL),
(144, 4, 36, 1, NULL, NULL, NULL),
(145, 1, 37, 1, NULL, NULL, NULL),
(146, 2, 37, 1, NULL, NULL, NULL),
(147, 3, 37, 1, NULL, NULL, NULL),
(148, 4, 37, 1, NULL, NULL, NULL),
(149, 1, 38, 1, NULL, NULL, NULL),
(150, 2, 38, 1, NULL, NULL, NULL),
(151, 3, 38, 1, NULL, NULL, NULL),
(152, 4, 38, 1, NULL, NULL, NULL),
(153, 1, 39, 1, NULL, NULL, NULL),
(154, 2, 39, 1, NULL, NULL, NULL),
(155, 3, 39, 1, NULL, NULL, NULL),
(156, 4, 39, 1, NULL, NULL, NULL),
(157, 1, 40, 1, NULL, NULL, NULL),
(158, 2, 40, 1, NULL, NULL, NULL),
(159, 3, 40, 1, NULL, NULL, NULL),
(160, 4, 40, 1, NULL, NULL, NULL),
(161, 1, 41, 1, NULL, NULL, NULL),
(162, 2, 41, 1, NULL, NULL, NULL),
(163, 3, 41, 1, NULL, NULL, NULL),
(164, 4, 41, 1, NULL, NULL, NULL),
(165, 1, 42, 1, NULL, NULL, NULL),
(166, 2, 42, 1, NULL, NULL, NULL),
(167, 3, 42, 1, NULL, NULL, NULL),
(168, 4, 42, 1, NULL, NULL, NULL),
(169, 1, 1, 1, NULL, NULL, NULL),
(170, 2, 1, 1, NULL, NULL, NULL),
(171, 3, 1, 1, NULL, NULL, NULL),
(172, 4, 1, 1, NULL, NULL, NULL),
(173, 1, 2, 1, NULL, NULL, NULL),
(174, 2, 2, 1, NULL, NULL, NULL),
(175, 3, 2, 1, NULL, NULL, NULL),
(176, 4, 2, 1, NULL, NULL, NULL),
(177, 1, 3, 1, NULL, NULL, NULL),
(178, 2, 3, 1, NULL, NULL, NULL),
(179, 3, 3, 1, NULL, NULL, NULL),
(180, 4, 3, 1, NULL, NULL, NULL),
(181, 1, 4, 1, NULL, NULL, NULL),
(182, 2, 4, 1, NULL, NULL, NULL),
(183, 3, 4, 1, NULL, NULL, NULL),
(184, 4, 4, 1, NULL, NULL, NULL),
(185, 1, 5, 1, NULL, NULL, NULL),
(186, 2, 5, 1, NULL, NULL, NULL),
(187, 3, 5, 1, NULL, NULL, NULL),
(188, 4, 5, 1, NULL, NULL, NULL),
(189, 1, 6, 1, NULL, NULL, NULL),
(190, 2, 6, 1, NULL, NULL, NULL),
(191, 3, 6, 1, NULL, NULL, NULL),
(192, 4, 6, 1, NULL, NULL, NULL),
(193, 1, 7, 1, NULL, NULL, NULL),
(194, 2, 7, 1, NULL, NULL, NULL),
(195, 3, 7, 1, NULL, NULL, NULL),
(196, 4, 7, 1, NULL, NULL, NULL),
(197, 1, 8, 1, NULL, NULL, NULL),
(198, 2, 8, 1, NULL, NULL, NULL),
(199, 3, 8, 1, NULL, NULL, NULL),
(200, 4, 8, 1, NULL, NULL, NULL),
(201, 1, 9, 1, NULL, NULL, NULL),
(202, 2, 9, 1, NULL, NULL, NULL),
(203, 3, 9, 1, NULL, NULL, NULL),
(204, 4, 9, 1, NULL, NULL, NULL),
(205, 1, 10, 1, NULL, NULL, NULL),
(206, 2, 10, 1, NULL, NULL, NULL),
(207, 3, 10, 1, NULL, NULL, NULL),
(208, 4, 10, 1, NULL, NULL, NULL),
(209, 1, 11, 1, NULL, NULL, NULL),
(210, 2, 11, 1, NULL, NULL, NULL),
(211, 3, 11, 1, NULL, NULL, NULL),
(212, 4, 11, 1, NULL, NULL, NULL),
(213, 1, 12, 1, NULL, NULL, NULL),
(214, 2, 12, 1, NULL, NULL, NULL),
(215, 3, 12, 1, NULL, NULL, NULL),
(216, 4, 12, 1, NULL, NULL, NULL),
(217, 1, 13, 1, NULL, NULL, NULL),
(218, 2, 13, 1, NULL, NULL, NULL),
(219, 3, 13, 1, NULL, NULL, NULL),
(220, 4, 13, 1, NULL, NULL, NULL),
(221, 1, 14, 1, NULL, NULL, NULL),
(222, 2, 14, 1, NULL, NULL, NULL),
(223, 3, 14, 1, NULL, NULL, NULL),
(224, 4, 14, 1, NULL, NULL, NULL),
(225, 1, 15, 1, NULL, NULL, NULL),
(226, 2, 15, 1, NULL, NULL, NULL),
(227, 3, 15, 1, NULL, NULL, NULL),
(228, 4, 15, 1, NULL, NULL, NULL),
(229, 1, 16, 1, NULL, NULL, NULL),
(230, 2, 16, 1, NULL, NULL, NULL),
(231, 3, 16, 1, NULL, NULL, NULL),
(232, 4, 16, 1, NULL, NULL, NULL),
(233, 1, 17, 1, NULL, NULL, NULL),
(234, 2, 17, 1, NULL, NULL, NULL),
(235, 3, 17, 1, NULL, NULL, NULL),
(236, 4, 17, 1, NULL, NULL, NULL),
(237, 1, 18, 1, NULL, NULL, NULL),
(238, 2, 18, 1, NULL, NULL, NULL),
(239, 3, 18, 1, NULL, NULL, NULL),
(240, 4, 18, 1, NULL, NULL, NULL),
(241, 1, 19, 1, NULL, NULL, NULL),
(242, 2, 19, 1, NULL, NULL, NULL),
(243, 3, 19, 1, NULL, NULL, NULL),
(244, 4, 19, 1, NULL, NULL, NULL),
(245, 1, 20, 1, NULL, NULL, NULL),
(246, 2, 20, 1, NULL, NULL, NULL),
(247, 3, 20, 1, NULL, NULL, NULL),
(248, 4, 20, 1, NULL, NULL, NULL),
(249, 1, 21, 1, NULL, NULL, NULL),
(250, 2, 21, 1, NULL, NULL, NULL),
(251, 3, 21, 1, NULL, NULL, NULL),
(252, 4, 21, 1, NULL, NULL, NULL),
(253, 1, 22, 1, NULL, NULL, NULL),
(254, 2, 22, 1, NULL, NULL, NULL),
(255, 3, 22, 1, NULL, NULL, NULL),
(256, 4, 22, 1, NULL, NULL, NULL),
(257, 1, 23, 1, NULL, NULL, NULL),
(258, 2, 23, 1, NULL, NULL, NULL),
(259, 3, 23, 1, NULL, NULL, NULL),
(260, 4, 23, 1, NULL, NULL, NULL),
(261, 1, 24, 1, NULL, NULL, NULL),
(262, 2, 24, 1, NULL, NULL, NULL),
(263, 3, 24, 1, NULL, NULL, NULL),
(264, 4, 24, 1, NULL, NULL, NULL),
(265, 1, 25, 1, NULL, NULL, NULL),
(266, 2, 25, 1, NULL, NULL, NULL),
(267, 3, 25, 1, NULL, NULL, NULL),
(268, 4, 25, 1, NULL, NULL, NULL),
(269, 1, 26, 1, NULL, NULL, NULL),
(270, 2, 26, 1, NULL, NULL, NULL),
(271, 3, 26, 1, NULL, NULL, NULL),
(272, 4, 26, 1, NULL, NULL, NULL),
(273, 1, 27, 1, NULL, NULL, NULL),
(274, 2, 27, 1, NULL, NULL, NULL),
(275, 3, 27, 1, NULL, NULL, NULL),
(276, 4, 27, 1, NULL, NULL, NULL),
(277, 1, 28, 1, NULL, NULL, NULL),
(278, 2, 28, 1, NULL, NULL, NULL),
(279, 3, 28, 1, NULL, NULL, NULL),
(280, 4, 28, 1, NULL, NULL, NULL),
(281, 1, 29, 1, NULL, NULL, NULL),
(282, 2, 29, 1, NULL, NULL, NULL),
(283, 3, 29, 1, NULL, NULL, NULL),
(284, 4, 29, 1, NULL, NULL, NULL),
(285, 1, 30, 1, NULL, NULL, NULL),
(286, 2, 30, 1, NULL, NULL, NULL),
(287, 3, 30, 1, NULL, NULL, NULL),
(288, 4, 30, 1, NULL, NULL, NULL),
(289, 1, 31, 1, NULL, NULL, NULL),
(290, 2, 31, 1, NULL, NULL, NULL),
(291, 3, 31, 1, NULL, NULL, NULL),
(292, 4, 31, 1, NULL, NULL, NULL),
(293, 1, 32, 1, NULL, NULL, NULL),
(294, 2, 32, 1, NULL, NULL, NULL),
(295, 3, 32, 1, NULL, NULL, NULL),
(296, 4, 32, 1, NULL, NULL, NULL),
(297, 1, 33, 1, NULL, NULL, NULL),
(298, 2, 33, 1, NULL, NULL, NULL),
(299, 3, 33, 1, NULL, NULL, NULL),
(300, 4, 33, 1, NULL, NULL, NULL),
(301, 1, 34, 1, NULL, NULL, NULL),
(302, 2, 34, 1, NULL, NULL, NULL),
(303, 3, 34, 1, NULL, NULL, NULL),
(304, 4, 34, 1, NULL, NULL, NULL),
(305, 1, 35, 1, NULL, NULL, NULL),
(306, 2, 35, 1, NULL, NULL, NULL),
(307, 3, 35, 1, NULL, NULL, NULL),
(308, 4, 35, 1, NULL, NULL, NULL),
(309, 1, 36, 1, NULL, NULL, NULL),
(310, 2, 36, 1, NULL, NULL, NULL),
(311, 3, 36, 1, NULL, NULL, NULL),
(312, 4, 36, 1, NULL, NULL, NULL),
(313, 1, 37, 1, NULL, NULL, NULL),
(314, 2, 37, 1, NULL, NULL, NULL),
(315, 3, 37, 1, NULL, NULL, NULL),
(316, 4, 37, 1, NULL, NULL, NULL),
(317, 1, 38, 1, NULL, NULL, NULL),
(318, 2, 38, 1, NULL, NULL, NULL),
(319, 3, 38, 1, NULL, NULL, NULL),
(320, 4, 38, 1, NULL, NULL, NULL),
(321, 1, 39, 1, NULL, NULL, NULL),
(322, 2, 39, 1, NULL, NULL, NULL),
(323, 3, 39, 1, NULL, NULL, NULL),
(324, 4, 39, 1, NULL, NULL, NULL),
(325, 1, 40, 1, NULL, NULL, NULL),
(326, 2, 40, 1, NULL, NULL, NULL),
(327, 3, 40, 1, NULL, NULL, NULL),
(328, 4, 40, 1, NULL, NULL, NULL),
(329, 1, 41, 1, NULL, NULL, NULL),
(330, 2, 41, 1, NULL, NULL, NULL),
(331, 3, 41, 1, NULL, NULL, NULL),
(332, 4, 41, 1, NULL, NULL, NULL),
(333, 1, 42, 1, NULL, NULL, NULL),
(334, 2, 42, 1, NULL, NULL, NULL),
(335, 3, 42, 1, NULL, NULL, NULL),
(336, 4, 42, 1, NULL, NULL, NULL),
(337, 1, 35, 2, NULL, NULL, NULL),
(338, 1, 5, 2, NULL, NULL, NULL),
(339, 1, 6, 2, NULL, NULL, NULL),
(340, 1, 8, 2, NULL, NULL, NULL),
(341, 2, 35, 2, NULL, NULL, NULL),
(342, 2, 5, 2, NULL, NULL, NULL),
(343, 2, 6, 2, NULL, NULL, NULL),
(344, 2, 8, 2, NULL, NULL, NULL),
(345, 3, 35, 2, NULL, NULL, NULL),
(346, 3, 5, 2, NULL, NULL, NULL),
(347, 3, 6, 2, NULL, NULL, NULL),
(348, 3, 8, 2, NULL, NULL, NULL),
(349, 4, 35, 2, NULL, NULL, NULL),
(350, 4, 5, 2, NULL, NULL, NULL),
(351, 4, 6, 2, NULL, NULL, NULL),
(352, 4, 8, 2, NULL, NULL, NULL);

CREATE TABLE `printers` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `printer_type_id` bigint(20) UNSIGNED DEFAULT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `port` 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;

CREATE TABLE `printer_types` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` 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;

INSERT INTO `printer_types` (`id`, `name`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'Laser', NULL, NULL, NULL),
(2, 'Thermique', NULL, NULL, NULL),
(3, 'Jet d\'encre', NULL, NULL, NULL),
(4, 'Bulle d\'encre', NULL, NULL, NULL),
(5, 'Matricielle', NULL, NULL, NULL),
(6, 'LED', NULL, NULL, NULL);

CREATE TABLE `products` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `reference` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `image` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `wholesale_unit_selling_price` double NOT NULL DEFAULT 0,
  `wholesale_available_quantity` double NOT NULL DEFAULT 0,
  `in_detail_unit_selling_price` double NOT NULL DEFAULT 0,
  `in_detail_available_quantity` double NOT NULL DEFAULT 0,
  `tva` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0',
  `expiration_date` date DEFAULT NULL,
  `security_stock` double 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;

CREATE TABLE `product_details` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `product_id` bigint(20) UNSIGNED DEFAULT NULL,
  `data` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`data`)),
  `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;

CREATE TABLE `product_unit_measure` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `product_id` bigint(20) UNSIGNED DEFAULT NULL,
  `unit_measure_id` bigint(20) UNSIGNED DEFAULT NULL,
  `unit_price` double 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;

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

CREATE TABLE `return_stocks` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `date` datetime NOT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '1701439187',
  `supplier_id` bigint(20) UNSIGNED DEFAULT NULL,
  `products` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`products`)),
  `discount_on_total` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0',
  `total` double NOT NULL DEFAULT 0,
  `payment_method_id` bigint(20) UNSIGNED DEFAULT NULL,
  `tva` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0',
  `state_id` bigint(20) UNSIGNED 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;

CREATE TABLE `roles` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT 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;

INSERT INTO `roles` (`id`, `name`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'admin', NULL, NULL, NULL),
(2, 'vendeur', NULL, NULL, NULL),
(3, 'user', NULL, NULL, NULL);

CREATE TABLE `role_table` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `role_id` bigint(20) UNSIGNED DEFAULT NULL,
  `table_id` bigint(20) UNSIGNED 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;

INSERT INTO `role_table` (`id`, `role_id`, `table_id`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 1, 1, NULL, NULL, NULL),
(2, 1, 2, NULL, NULL, NULL),
(3, 1, 3, NULL, NULL, NULL),
(4, 1, 4, NULL, NULL, NULL),
(7, 1, 7, NULL, NULL, NULL),
(9, 1, 9, NULL, NULL, NULL),
(10, 1, 10, NULL, NULL, NULL),
(11, 1, 11, NULL, NULL, NULL),
(12, 1, 12, NULL, NULL, NULL),
(13, 1, 13, NULL, NULL, NULL),
(14, 1, 14, NULL, NULL, NULL),
(15, 1, 15, NULL, NULL, NULL),
(16, 1, 16, NULL, NULL, NULL),
(17, 1, 17, NULL, NULL, NULL),
(18, 1, 18, NULL, NULL, NULL),
(19, 1, 19, NULL, NULL, NULL),
(20, 1, 20, NULL, NULL, NULL),
(21, 1, 21, NULL, NULL, NULL),
(22, 1, 22, NULL, NULL, NULL),
(23, 1, 23, NULL, NULL, NULL),
(24, 1, 24, NULL, NULL, NULL),
(25, 1, 25, NULL, NULL, NULL),
(26, 1, 26, NULL, NULL, NULL),
(27, 1, 27, NULL, NULL, NULL),
(28, 1, 28, NULL, NULL, NULL),
(29, 1, 29, NULL, NULL, NULL),
(30, 1, 30, NULL, NULL, NULL),
(31, 1, 31, NULL, NULL, NULL),
(32, 1, 32, NULL, NULL, NULL),
(33, 1, 33, NULL, NULL, NULL),
(34, 1, 34, NULL, NULL, NULL),
(36, 1, 36, NULL, NULL, NULL),
(37, 1, 37, NULL, NULL, NULL),
(38, 1, 38, NULL, NULL, NULL),
(39, 1, 39, NULL, NULL, NULL),
(40, 1, 40, NULL, NULL, NULL),
(41, 1, 41, NULL, NULL, NULL),
(42, 1, 42, NULL, NULL, NULL),
(43, 2, 35, NULL, NULL, NULL),
(44, 2, 5, NULL, NULL, NULL),
(45, 2, 6, NULL, NULL, NULL),
(46, 2, 8, NULL, NULL, NULL);

CREATE TABLE `role_user` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `role_id` bigint(20) UNSIGNED DEFAULT NULL,
  `user_id` bigint(20) UNSIGNED 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;

INSERT INTO `role_user` (`id`, `role_id`, `user_id`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 1, 1, NULL, NULL, NULL),
(2, 1, 2, NULL, NULL, NULL),
(3, 2, 3, NULL, NULL, NULL);

CREATE TABLE `sells` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `date` datetime NOT NULL,
  `code` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '1701439155',
  `customer_id` bigint(20) UNSIGNED DEFAULT NULL,
  `achats` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL CHECK (json_valid(`achats`)),
  `shipping` double NOT NULL DEFAULT 0,
  `discount_on_total` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0',
  `total` double NOT NULL DEFAULT 0,
  `payment_method_id` bigint(20) UNSIGNED DEFAULT NULL,
  `debtor_paid_amount` double NOT NULL DEFAULT 0,
  `tva` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '0',
  `out_type_id` bigint(20) UNSIGNED DEFAULT NULL,
  `state_id` bigint(20) UNSIGNED 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;

CREATE TABLE `states` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` 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;

INSERT INTO `states` (`id`, `name`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'DRAFT', NULL, NULL, NULL),
(2, 'SENT', NULL, NULL, NULL),
(3, 'ACCEPTED', NULL, NULL, NULL),
(4, 'REJECTED', NULL, NULL, NULL),
(5, 'PERFECT', NULL, NULL, NULL),
(6, 'SEALED', NULL, NULL, NULL),
(7, 'UNPAID', NULL, NULL, NULL),
(8, 'PAID', NULL, NULL, NULL),
(9, 'SEMIPAID', NULL, NULL, NULL),
(10, 'SUCCESS', NULL, NULL, NULL),
(11, 'WARNING', NULL, NULL, NULL),
(12, 'ERROR', NULL, NULL, NULL),
(13, 'CLOSED', NULL, NULL, NULL),
(14, 'CANCELED', NULL, NULL, NULL),
(15, 'PENDING', NULL, NULL, NULL),
(16, 'ADDED', NULL, NULL, NULL);

CREATE TABLE `stocks` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `date` date DEFAULT NULL,
  `supplier_id` bigint(20) UNSIGNED DEFAULT NULL,
  `product_id` bigint(20) UNSIGNED DEFAULT NULL,
  `wholesale_measure_id` bigint(20) UNSIGNED DEFAULT NULL,
  `wholesale_initial_quantity` double NOT NULL DEFAULT 0,
  `wholesale_unit_purchase_price` double NOT NULL DEFAULT 0,
  `in_detail_measure_id` bigint(20) UNSIGNED DEFAULT NULL,
  `in_detail_quantity` double NOT NULL DEFAULT 0,
  `in_detail_unit_purchase_price` double NOT NULL DEFAULT 0,
  `payment_method_id` bigint(20) UNSIGNED DEFAULT NULL,
  `credit_paid_amount` double NOT NULL DEFAULT 0,
  `total_purchase_cost` double NOT NULL DEFAULT 0,
  `receipt` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `tva` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `charge` double NOT NULL DEFAULT 0,
  `shipping` double NOT NULL DEFAULT 0,
  `discharge` double NOT NULL DEFAULT 0,
  `state_id` bigint(20) UNSIGNED 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;

CREATE TABLE `suppliers` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `phones` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `email` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `address` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `particular_name` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `particular_phones` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `particular_email` 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;

CREATE TABLE `supplier_credits` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `supplier_id` bigint(20) UNSIGNED DEFAULT NULL,
  `stock_id` bigint(20) UNSIGNED DEFAULT NULL,
  `paid_amount` double 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;

CREATE TABLE `tables` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT 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;

INSERT INTO `tables` (`id`, `name`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'categories', '2023-12-01 13:59:53', '2023-12-01 13:59:53', NULL),
(2, 'category_product', '2023-12-01 13:59:53', '2023-12-01 13:59:53', NULL),
(3, 'commands', '2023-12-01 13:59:54', '2023-12-01 13:59:54', NULL),
(4, 'companies', '2023-12-01 13:59:54', '2023-12-01 13:59:54', NULL),
(5, 'customers', '2023-12-01 13:59:54', '2023-12-01 13:59:54', NULL),
(6, 'debtors', '2023-12-01 13:59:54', '2023-12-01 13:59:54', NULL),
(7, 'expense_types', '2023-12-01 13:59:54', '2023-12-01 13:59:54', NULL),
(8, 'expenses', '2023-12-01 13:59:54', '2023-12-01 13:59:54', NULL),
(9, 'failed_jobs', '2023-12-01 13:59:54', '2023-12-01 13:59:54', NULL),
(10, 'inventories', '2023-12-01 13:59:54', '2023-12-01 13:59:54', NULL),
(11, 'invoices', '2023-12-01 13:59:54', '2023-12-01 13:59:54', NULL),
(12, 'logs', '2023-12-01 13:59:54', '2023-12-01 13:59:54', NULL),
(13, 'migrations', '2023-12-01 13:59:54', '2023-12-01 13:59:54', NULL),
(14, 'movement_types', '2023-12-01 13:59:54', '2023-12-01 13:59:54', NULL),
(15, 'navigator_types', '2023-12-01 13:59:54', '2023-12-01 13:59:54', NULL),
(16, 'navigators', '2023-12-01 13:59:54', '2023-12-01 13:59:54', NULL),
(17, 'out_types', '2023-12-01 13:59:54', '2023-12-01 13:59:54', NULL),
(18, 'password_reset_tokens', '2023-12-01 13:59:54', '2023-12-01 13:59:54', NULL),
(19, 'password_resets', '2023-12-01 13:59:54', '2023-12-01 13:59:54', NULL),
(20, 'payment_methods', '2023-12-01 13:59:54', '2023-12-01 13:59:54', NULL),
(21, 'permission_role', '2023-12-01 13:59:54', '2023-12-01 13:59:54', NULL),
(22, 'permission_table', '2023-12-01 13:59:55', '2023-12-01 13:59:55', NULL),
(23, 'permissions', '2023-12-01 13:59:55', '2023-12-01 13:59:55', NULL),
(24, 'personal_access_tokens', '2023-12-01 13:59:55', '2023-12-01 13:59:55', NULL),
(25, 'printer_types', '2023-12-01 13:59:55', '2023-12-01 13:59:55', NULL),
(26, 'printers', '2023-12-01 13:59:55', '2023-12-01 13:59:55', NULL),
(27, 'product_details', '2023-12-01 13:59:55', '2023-12-01 13:59:55', NULL),
(28, 'product_unit_measure', '2023-12-01 13:59:55', '2023-12-01 13:59:55', NULL),
(29, 'products', '2023-12-01 13:59:55', '2023-12-01 13:59:55', NULL),
(30, 'reports', '2023-12-01 13:59:55', '2023-12-01 13:59:55', NULL),
(31, 'return_stocks', '2023-12-01 13:59:55', '2023-12-01 13:59:55', NULL),
(32, 'role_table', '2023-12-01 13:59:55', '2023-12-01 13:59:55', NULL),
(33, 'role_user', '2023-12-01 13:59:55', '2023-12-01 13:59:55', NULL),
(34, 'roles', '2023-12-01 13:59:55', '2023-12-01 13:59:55', NULL),
(35, 'sells', '2023-12-01 13:59:55', '2023-12-01 13:59:55', NULL),
(36, 'states', '2023-12-01 13:59:55', '2023-12-01 13:59:55', NULL),
(37, 'stocks', '2023-12-01 13:59:55', '2023-12-01 13:59:55', NULL),
(38, 'supplier_credits', '2023-12-01 13:59:55', '2023-12-01 13:59:55', NULL),
(39, 'suppliers', '2023-12-01 13:59:55', '2023-12-01 13:59:55', NULL),
(40, 'tables', '2023-12-01 13:59:55', '2023-12-01 13:59:55', NULL),
(41, 'unit_measures', '2023-12-01 13:59:55', '2023-12-01 13:59:55', NULL),
(42, 'users', '2023-12-01 13:59:56', '2023-12-01 13:59:56', NULL);

CREATE TABLE `unit_measures` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `unit` 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;

INSERT INTO `unit_measures` (`id`, `unit`, `created_at`, `updated_at`, `deleted_at`) VALUES
(1, 'Carton', NULL, NULL, NULL),
(2, 'Sac', NULL, NULL, NULL),
(3, 'Sachet', NULL, NULL, NULL),
(4, 'Casier', NULL, NULL, NULL),
(5, 'Bouteille', NULL, NULL, NULL),
(6, 'Rouleau', NULL, NULL, NULL),
(7, 'Piece', NULL, NULL, NULL),
(8, 'Bidon', NULL, NULL, NULL),
(9, 'Plaquette', NULL, NULL, NULL);


ALTER TABLE `categories`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `category_product`
  ADD PRIMARY KEY (`id`),
  ADD KEY `category_product_category_id_foreign` (`category_id`),
  ADD KEY `category_product_product_id_foreign` (`product_id`);

ALTER TABLE `commands`
  ADD PRIMARY KEY (`id`),
  ADD KEY `commands_supplier_id_foreign` (`supplier_id`),
  ADD KEY `commands_payment_method_id_foreign` (`payment_method_id`),
  ADD KEY `commands_state_id_foreign` (`state_id`);

ALTER TABLE `companies`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `customers`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `debtors`
  ADD PRIMARY KEY (`id`),
  ADD KEY `debtors_customer_id_foreign` (`customer_id`),
  ADD KEY `debtors_sell_id_foreign` (`sell_id`);

ALTER TABLE `expenses`
  ADD PRIMARY KEY (`id`),
  ADD KEY `expenses_expense_type_id_foreign` (`expense_type_id`);

ALTER TABLE `expense_types`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `failed_jobs`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `failed_jobs_uuid_unique` (`uuid`);

ALTER TABLE `inventories`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `invoices`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `logs`
  ADD PRIMARY KEY (`id`),
  ADD KEY `logs_user_id_foreign` (`user_id`);

ALTER TABLE `migrations`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `movement_types`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `navigators`
  ADD PRIMARY KEY (`id`),
  ADD KEY `navigators_navigator_type_id_foreign` (`navigator_type_id`);

ALTER TABLE `navigator_types`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `out_types`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `payment_methods`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `permissions`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `permission_role`
  ADD PRIMARY KEY (`id`),
  ADD KEY `permission_role_permission_id_foreign` (`permission_id`),
  ADD KEY `permission_role_role_id_foreign` (`role_id`);

ALTER TABLE `permission_table`
  ADD PRIMARY KEY (`id`),
  ADD KEY `permission_table_permission_id_foreign` (`permission_id`),
  ADD KEY `permission_table_table_id_foreign` (`table_id`),
  ADD KEY `permission_table_role_id_foreign` (`role_id`);

ALTER TABLE `printers`
  ADD PRIMARY KEY (`id`),
  ADD KEY `printers_printer_type_id_foreign` (`printer_type_id`);

ALTER TABLE `printer_types`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `products`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `product_details`
  ADD PRIMARY KEY (`id`),
  ADD KEY `product_details_product_id_foreign` (`product_id`);

ALTER TABLE `product_unit_measure`
  ADD PRIMARY KEY (`id`),
  ADD KEY `product_unit_measure_product_id_foreign` (`product_id`),
  ADD KEY `product_unit_measure_unit_measure_id_foreign` (`unit_measure_id`);

ALTER TABLE `reports`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `return_stocks`
  ADD PRIMARY KEY (`id`),
  ADD KEY `return_stocks_supplier_id_foreign` (`supplier_id`),
  ADD KEY `return_stocks_payment_method_id_foreign` (`payment_method_id`),
  ADD KEY `return_stocks_state_id_foreign` (`state_id`);

ALTER TABLE `roles`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `role_table`
  ADD PRIMARY KEY (`id`),
  ADD KEY `role_table_role_id_foreign` (`role_id`),
  ADD KEY `role_table_table_id_foreign` (`table_id`);

ALTER TABLE `role_user`
  ADD PRIMARY KEY (`id`),
  ADD KEY `role_user_role_id_foreign` (`role_id`),
  ADD KEY `role_user_user_id_foreign` (`user_id`);

ALTER TABLE `sells`
  ADD PRIMARY KEY (`id`),
  ADD KEY `sells_customer_id_foreign` (`customer_id`),
  ADD KEY `sells_payment_method_id_foreign` (`payment_method_id`),
  ADD KEY `sells_out_type_id_foreign` (`out_type_id`),
  ADD KEY `sells_state_id_foreign` (`state_id`);

ALTER TABLE `states`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `stocks`
  ADD PRIMARY KEY (`id`),
  ADD KEY `stocks_supplier_id_foreign` (`supplier_id`),
  ADD KEY `stocks_product_id_foreign` (`product_id`),
  ADD KEY `stocks_wholesale_measure_id_foreign` (`wholesale_measure_id`),
  ADD KEY `stocks_in_detail_measure_id_foreign` (`in_detail_measure_id`),
  ADD KEY `stocks_payment_method_id_foreign` (`payment_method_id`),
  ADD KEY `stocks_state_id_foreign` (`state_id`);

ALTER TABLE `suppliers`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `supplier_credits`
  ADD PRIMARY KEY (`id`),
  ADD KEY `supplier_credits_supplier_id_foreign` (`supplier_id`),
  ADD KEY `supplier_credits_stock_id_foreign` (`stock_id`);

ALTER TABLE `tables`
  ADD PRIMARY KEY (`id`);

ALTER TABLE `unit_measures`
  ADD PRIMARY KEY (`id`);


ALTER TABLE `categories`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

ALTER TABLE `category_product`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `commands`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `companies`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

ALTER TABLE `customers`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `debtors`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `expenses`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `expense_types`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

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

ALTER TABLE `inventories`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `invoices`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `logs`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `migrations`
  MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=124;

ALTER TABLE `movement_types`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `navigators`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `navigator_types`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `out_types`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

ALTER TABLE `payment_methods`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;

ALTER TABLE `permissions`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;

ALTER TABLE `permission_role`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;

ALTER TABLE `permission_table`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=353;

ALTER TABLE `printers`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `printer_types`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;

ALTER TABLE `products`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `product_details`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `product_unit_measure`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `reports`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `return_stocks`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `roles`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

ALTER TABLE `role_table`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=47;

ALTER TABLE `role_user`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;

ALTER TABLE `sells`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `states`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=17;

ALTER TABLE `stocks`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `suppliers`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `supplier_credits`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT;

ALTER TABLE `tables`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=43;

ALTER TABLE `unit_measures`
  MODIFY `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=10;


ALTER TABLE `category_product`
  ADD CONSTRAINT `category_product_category_id_foreign` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`),
  ADD CONSTRAINT `category_product_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`);

ALTER TABLE `commands`
  ADD CONSTRAINT `commands_payment_method_id_foreign` FOREIGN KEY (`payment_method_id`) REFERENCES `payment_methods` (`id`),
  ADD CONSTRAINT `commands_state_id_foreign` FOREIGN KEY (`state_id`) REFERENCES `states` (`id`),
  ADD CONSTRAINT `commands_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`id`);

ALTER TABLE `debtors`
  ADD CONSTRAINT `debtors_customer_id_foreign` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`),
  ADD CONSTRAINT `debtors_sell_id_foreign` FOREIGN KEY (`sell_id`) REFERENCES `sells` (`id`);

ALTER TABLE `expenses`
  ADD CONSTRAINT `expenses_expense_type_id_foreign` FOREIGN KEY (`expense_type_id`) REFERENCES `expense_types` (`id`);

ALTER TABLE `logs`
  ADD CONSTRAINT `logs_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`);

ALTER TABLE `navigators`
  ADD CONSTRAINT `navigators_navigator_type_id_foreign` FOREIGN KEY (`navigator_type_id`) REFERENCES `navigator_types` (`id`);

ALTER TABLE `permission_role`
  ADD CONSTRAINT `permission_role_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`),
  ADD CONSTRAINT `permission_role_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`);

ALTER TABLE `permission_table`
  ADD CONSTRAINT `permission_table_permission_id_foreign` FOREIGN KEY (`permission_id`) REFERENCES `permissions` (`id`),
  ADD CONSTRAINT `permission_table_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`),
  ADD CONSTRAINT `permission_table_table_id_foreign` FOREIGN KEY (`table_id`) REFERENCES `tables` (`id`);

ALTER TABLE `printers`
  ADD CONSTRAINT `printers_printer_type_id_foreign` FOREIGN KEY (`printer_type_id`) REFERENCES `printer_types` (`id`);

ALTER TABLE `product_details`
  ADD CONSTRAINT `product_details_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`);

ALTER TABLE `product_unit_measure`
  ADD CONSTRAINT `product_unit_measure_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`),
  ADD CONSTRAINT `product_unit_measure_unit_measure_id_foreign` FOREIGN KEY (`unit_measure_id`) REFERENCES `unit_measures` (`id`);

ALTER TABLE `return_stocks`
  ADD CONSTRAINT `return_stocks_payment_method_id_foreign` FOREIGN KEY (`payment_method_id`) REFERENCES `payment_methods` (`id`),
  ADD CONSTRAINT `return_stocks_state_id_foreign` FOREIGN KEY (`state_id`) REFERENCES `states` (`id`),
  ADD CONSTRAINT `return_stocks_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`id`);

ALTER TABLE `role_table`
  ADD CONSTRAINT `role_table_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`),
  ADD CONSTRAINT `role_table_table_id_foreign` FOREIGN KEY (`table_id`) REFERENCES `tables` (`id`);

ALTER TABLE `role_user`
  ADD CONSTRAINT `role_user_role_id_foreign` FOREIGN KEY (`role_id`) REFERENCES `roles` (`id`),
  ADD CONSTRAINT `role_user_user_id_foreign` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`);

ALTER TABLE `sells`
  ADD CONSTRAINT `sells_customer_id_foreign` FOREIGN KEY (`customer_id`) REFERENCES `customers` (`id`),
  ADD CONSTRAINT `sells_out_type_id_foreign` FOREIGN KEY (`out_type_id`) REFERENCES `out_types` (`id`),
  ADD CONSTRAINT `sells_payment_method_id_foreign` FOREIGN KEY (`payment_method_id`) REFERENCES `payment_methods` (`id`),
  ADD CONSTRAINT `sells_state_id_foreign` FOREIGN KEY (`state_id`) REFERENCES `states` (`id`);

ALTER TABLE `stocks`
  ADD CONSTRAINT `stocks_in_detail_measure_id_foreign` FOREIGN KEY (`in_detail_measure_id`) REFERENCES `unit_measures` (`id`),
  ADD CONSTRAINT `stocks_payment_method_id_foreign` FOREIGN KEY (`payment_method_id`) REFERENCES `payment_methods` (`id`),
  ADD CONSTRAINT `stocks_product_id_foreign` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`),
  ADD CONSTRAINT `stocks_state_id_foreign` FOREIGN KEY (`state_id`) REFERENCES `states` (`id`),
  ADD CONSTRAINT `stocks_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`id`),
  ADD CONSTRAINT `stocks_wholesale_measure_id_foreign` FOREIGN KEY (`wholesale_measure_id`) REFERENCES `unit_measures` (`id`);

ALTER TABLE `supplier_credits`
  ADD CONSTRAINT `supplier_credits_stock_id_foreign` FOREIGN KEY (`stock_id`) REFERENCES `stocks` (`id`),
  ADD CONSTRAINT `supplier_credits_supplier_id_foreign` FOREIGN KEY (`supplier_id`) REFERENCES `suppliers` (`id`);
COMMIT;

