-- 08-08-2022
ALTER TABLE `mandals`
CHANGE `modified` `modified` timestamp NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created`,
RENAME TO `villages`;


ALTER TABLE `brands`
ADD `created_by` int(11) NULL AFTER `status`,
CHANGE `modified` `modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created`;

ALTER TABLE `category`
ADD `created_by` int(11) NULL AFTER `status`,
CHANGE `updated_at` `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created_at`,
CHANGE `modified` `modified` timestamp NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created`;

-- 09-08-2022

ALTER TABLE `products`
ADD `brand_id` int(11) NULL AFTER `id`,
CHANGE `updated_at` `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created_at`,
ADD FOREIGN KEY (`brand_id`) REFERENCES `brands` (`id`) ON DELETE CASCADE;

ALTER TABLE `products`
CHANGE `created_at` `created_at` datetime NULL AFTER `description`,
ADD `deleted_at` datetime NULL AFTER `created_at`,
ADD `created` datetime NULL AFTER `deleted_at`,
CHANGE `updated_at` `updated_at` datetime NOT NULL ON UPDATE CURRENT_TIMESTAMP AFTER `created`,
ADD `modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP;


ALTER TABLE `products`
CHANGE `updated_at` `updated_at` datetime NOT NULL AFTER `created`,
CHANGE `modified` `modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `updated_at`;


ALTER TABLE `products`
CHANGE `created_at` `created_by` datetime NULL AFTER `description`,
CHANGE `modified` `modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `updated_at`;

ALTER TABLE `products`
ADD `status` tinyint(1) NOT NULL DEFAULT '1' AFTER `description`,
CHANGE `modified` `modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `updated_at`;

ALTER TABLE `products`
CHANGE `created_by` `created_by` int(11) NULL AFTER `status`,
CHANGE `modified` `modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `updated_at`;

ALTER TABLE `products`
ADD `category_id` int(11) NULL AFTER `brand_id`,
CHANGE `modified` `modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `updated_at`,
ADD FOREIGN KEY (`category_id`) REFERENCES `category` (`id`) ON DELETE CASCADE;

ALTER TABLE `products`
CHANGE `imag` `image` varchar(255) COLLATE 'utf8mb4_general_ci' NULL AFTER `description`,
CHANGE `modified` `modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `updated_at`;

-- 12-08-2022

CREATE TABLE `item_request` (
  `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `name` varchar(255) NOT NULL,
  `brand_id` int(11) NULL,
  `cat_id` int(11) NULL,
  `price` varchar(20) NULL,
  `image` varchar(255) NULL,
  `message` longtext NULL,
  `status` tinyint(012) NULL,
  `deleted_at` datetime NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP,
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP,
  FOREIGN KEY (`brand_id`) REFERENCES `brands` (`id`) ON DELETE CASCADE,
  FOREIGN KEY (`category_id`) REFERENCES `category` (`id`) ON DELETE CASCADE
) ENGINE='InnoDB';

LTER TABLE `item_request`
CHANGE `status` `status` enum('0','1','2') NULL AFTER `message`,
CHANGE `created_at` `created_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `deleted_at`,
CHANGE `updated_at` `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created_at`;


CREATE TABLE `category_request` (
  `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
  `item_request_id` int(11) NOT NULL,
  `cat_id` int(11) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP,
  FOREIGN KEY (`item_request_id`) REFERENCES `item_request` (`id`) ON DELETE CASCADE
) ENGINE='InnoDB';

-- 18-08-2022
ALTER TABLE `users`
CHANGE `address` `address` varchar(255) COLLATE 'utf8mb4_unicode_ci' NULL AFTER `decoded_password`,
CHANGE `expire_otp` `expire_otp` datetime NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `otp`,
CHANGE `created_at` `created_at` timestamp NULL ON UPDATE CURRENT_TIMESTAMP AFTER `deleted_at`,
CHANGE `created` `created` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `updated_at`,
CHANGE `modified` `modified` timestamp NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created`;

ALTER TABLE `products`
ADD `image` varchar(255) COLLATE 'utf8mb4_general_ci' NULL AFTER `description`,
CHANGE `modified` `modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `updated_at`;

ALTER TABLE `bank_details`
ADD `confirm_account_no` varchar(255) COLLATE 'latin1_swedish_ci' NULL AFTER `account_no`,
CHANGE `created_at` `created_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `ifsc_code`,
CHANGE `updated_at` `updated_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created_at`,
CHANGE `modified` `modified` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE CURRENT_TIMESTAMP AFTER `created`;

-- 20-08-2022

ALTER TABLE `orders`
ADD `order_delivery_type` enum('pickup','home_delivery') COLLATE 'latin1_spanish_ci' NULL AFTER `shop_id`,
ADD `home_delivery_time` varchar(255) COLLATE 'latin1_swedish_ci' NULL AFTER `pickup_date`,
ADD `home_delivery_date` varchar(255) COLLATE 'latin1_swedish_ci' NULL AFTER `home_delivery_time`,
CHANGE `updated_at` `updated_at` datetime NULL ON UPDATE CURRENT_TIMESTAMP AFTER `created_at`;

