ALTER TABLE `services`
ADD COLUMN `country`  varchar(100) NULL AFTER `detail`,
ADD COLUMN `parent`  int(11) NULL DEFAULT 0 AFTER `country`;

ALTER TABLE `zone`
MODIFY COLUMN `name`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' AFTER `id`,
MODIFY COLUMN `country`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' AFTER `name`,
ADD COLUMN `province`  varchar(255) NULL AFTER `country`;

ALTER TABLE `zone`
MODIFY COLUMN `cities`  text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL AFTER `province`;

ALTER TABLE `city`
MODIFY COLUMN `country`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' AFTER `id`,
MODIFY COLUMN `name`  varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT '' ,
ADD COLUMN `province`  varchar(255) NULL AFTER `country`;


ALTER TABLE `tickets`
ADD COLUMN `inquiry_country`  varchar(255) NULL AFTER `updated_at`,
ADD COLUMN `inquiry_status`  tinyint(2) NULL AFTER `inquiry_country`,
ADD COLUMN `status`  tinyint(2) NULL AFTER `inquiry_status`,
ADD COLUMN `inquiry_type`  tinyint(2) NULL AFTER `status`,
ADD COLUMN `transfered_to`  int(11) NULL AFTER `inquiry_type`,
ADD COLUMN `transfered_date`  datetime NULL AFTER `transfered_to`;

ALTER TABLE `users`
MODIFY COLUMN `id`  int(11) UNSIGNED NOT NULL AUTO_INCREMENT FIRST ;

ALTER TABLE `users`
ADD COLUMN `department_id`  int(11) NULL AFTER `phone`;

ALTER TABLE `users`
ADD COLUMN `zone_id`  int(11) NULL AFTER `department_id`;

ALTER TABLE `tickets`
ADD COLUMN `lead_id`  int(11) NULL AFTER `transfered_date`;

ALTER TABLE `tickets`
ADD COLUMN `assigned_to`  int(11) NULL AFTER `lead_id`,
ADD COLUMN `assigned_at`  datetime NULL AFTER `assigned_to`;

ALTER TABLE `users`
ADD COLUMN `ticket_assigned_at`  datetime NULL AFTER `zone_id`;

ALTER TABLE `users`
MODIFY COLUMN `ticket_assigned_at`  timestamp NULL DEFAULT CURRENT_TIMESTAMP AFTER `zone_id`;
-------------------------------
/* permission added for import lead */
INSERT INTO `permissions` (`id`, `parent_id`, `name`, `guard_name`, `created_at`, `updated_at`) VALUES (NULL, '46', 'lead_import', 'web', '2023-12-27 17:32:08', '2023-12-27 17:32:08');

ALTER TABLE `leads` CHANGE `inquiry_status` `inquiry_status` TINYINT(2) NULL DEFAULT '1';
ALTER TABLE `tickets` CHANGE `inquiry_status` `inquiry_status` TINYINT(2) NULL DEFAULT '1';

ALTER TABLE `tickets` ADD `remarket_date` DATETIME NULL AFTER `assigned_at`;

ALTER TABLE `activity` ADD `transfered_to` INT(11) NULL AFTER `ref_type`;


ALTER TABLE `users`
ADD COLUMN `passcode`  int(4) NULL AFTER `api_token`;


ALTER TABLE `branches`
ADD COLUMN `currency_symbol`  varchar(50) NULL AFTER `updated_at`;

ALTER TABLE `bookings`
ADD COLUMN `assigned_to`  int(11) NULL AFTER `payment`;

ALTER TABLE `bookings`
ADD COLUMN `booking_from`  varchar(50) NULL DEFAULT 'SHOP' AFTER `assigned_to`;

ALTER TABLE `bookings`
MODIFY COLUMN `booking_time`  time NULL ,
ADD COLUMN `booking_date`  date NULL AFTER `coupon_id`;

-----

ALTER TABLE `bookings`
ADD COLUMN `note`  varchar(500) NULL AFTER `booking_from`;


ALTER TABLE `bookings`
ADD COLUMN `subtotal`  decimal(10,2) NULL AFTER `note`;

ALTER TABLE `booking_items`
ADD COLUMN `subtotal`  decimal(10,2) NULL AFTER `booking_id`;

-----

ALTER TABLE `bookings`
ADD COLUMN `status_by`  int(11) NULL AFTER `subtotal`,
ADD COLUMN `reason`  varchar(255) NULL AFTER `status_by`;

ALTER TABLE `booking_items`
ADD COLUMN `status`  tinyint(2) NULL DEFAULT 1 AFTER `subtotal`,
ADD COLUMN `reason`  varchar(255) NULL AFTER `status`;
---------

ALTER TABLE `coupons`
ADD COLUMN `balance`  decimal(10,2) NULL AFTER `branch_id`;

ALTER TABLE `bookings`
ADD COLUMN `coupon_discount`  decimal(10,2) NULL AFTER `status`;

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

ALTER TABLE `coupons`
MODIFY COLUMN `balance`  decimal(10,2) NULL DEFAULT 0 AFTER `branch_id`;
----------------

INSERT INTO `permissions` (`name`, `guard_name`) VALUES ('Report', 'web');
ALTER TABLE `booking_payments`
ADD COLUMN `created_at`  timestamp NULL DEFAULT CURRENT_TIMESTAMP AFTER `amount`,
ADD COLUMN `updated_at`  timestamp NULL ON UPDATE CURRENT_TIMESTAMP AFTER `created_at`;
---------------------
ALTER TABLE `dayend_report`
ADD COLUMN `voids`  int(11) NULL AFTER `branch_id`,
ADD COLUMN `cancelled`  int(11) NULL AFTER `voids`;
