SET FOREIGN_KEY_CHECKS=0;


CREATE TABLE IF NOT EXISTS `custom_menus` (
    `id` bigint(20) UNSIGNED NOT NULL,
    `restaurant_id` int(10) UNSIGNED NOT NULL,
    `category_id` int(10) UNSIGNED NOT NULL,
    `name` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
    `image` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
    `created_at` timestamp NULL DEFAULT NULL,
    `updated_at` timestamp NULL DEFAULT NULL
);

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

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

ALTER TABLE `restaurants` ADD `footer` VARCHAR(191) NULL DEFAULT NULL AFTER `status`;

ALTER TABLE `restaurants` ADD `template` ENUM('classic','modern','flipbook','custom') NULL DEFAULT 'classic' AFTER `status`;

ALTER TABLE `items` ADD `tax_id` INT(11) UNSIGNED NULL DEFAULT NULL AFTER `updated_at`;

ALTER TABLE `order_details` ADD `tax_amount` DOUBLE NOT NULL DEFAULT '0' AFTER `updated_at`;

ALTER TABLE `plans` ADD `item_unlimited` ENUM('yes','no') DEFAULT 'no' AFTER `updated_at`;
ALTER TABLE `plans` ADD `restaurant_unlimited` ENUM('yes','no') DEFAULT 'no' AFTER `updated_at`;
ALTER TABLE `plans` ADD `table_unlimited` ENUM('yes','no') DEFAULT 'no' AFTER `updated_at`;

ALTER TABLE `user_plans` ADD `item_unlimited` ENUM('yes','no') DEFAULT 'no' AFTER `updated_at`;
ALTER TABLE `user_plans` ADD `restaurant_unlimited` ENUM('yes','no') DEFAULT 'no' AFTER `updated_at`;
ALTER TABLE `user_plans` ADD `table_unlimited` ENUM('yes','no') DEFAULT 'no' AFTER `updated_at`;


CREATE TABLE IF NOT EXISTS `item_extras` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `item_id` int(10) UNSIGNED NOT NULL,
  `title` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `price` double NOT NULL,
  `status` enum('active','inactive') COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT 'active',
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
);

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

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

CREATE TABLE `order_extras` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `order_id` int(10) UNSIGNED NOT NULL,
  `item_id` int(10) UNSIGNED NOT NULL,
  `item_extra_id` int(10) UNSIGNED NOT NULL,
  `title` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `price` double NOT NULL,
  `quantity` double NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
);
ALTER TABLE `order_extras`
  ADD PRIMARY KEY (`id`);

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

CREATE TABLE `taxes` (
  `id` bigint(20) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `title` varchar(191) COLLATE utf8mb4_unicode_ci NOT NULL,
  `amount` double NOT NULL,
  `type` enum('flat','percentage') COLLATE utf8mb4_unicode_ci NOT NULL,
  `status` enum('active','inactive') COLLATE utf8mb4_unicode_ci NOT NULL,
  `created_at` timestamp NULL DEFAULT NULL,
  `updated_at` timestamp NULL DEFAULT NULL
);
ALTER TABLE `taxes`
  ADD PRIMARY KEY (`id`);

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


SET FOREIGN_KEY_CHECKS=1;
