ALTER TABLE `tbl_data_packets` ADD `device_reading_time` BIGINT(15) NOT NULL AFTER `details`;

CREATE PROCEDURE `procedureGetDataPacketsByUserIdByFromDateToDate`(IN `userId` INT, IN `fromDate` DATETIME, IN `toDate` DATETIME) NOT DETERMINISTIC READS SQL DATA SQL SECURITY DEFINER SELECT tdp.*, tu.first_name, tu.last_name, tudi.imei_number, tudi.product_id FROM tbl_data_packets tdp JOIN tbl_users tu ON tdp.user_id = tu.user_id JOIN tbl_user_device_info tudi ON tdp.user_id = tudi.user_id WHERE tdp.user_id = userId AND tdp.created_at BETWEEN fromDate AND toDate ORDER BY tdp.data_packet_id DESC

/**
* 04-09-2021
**/
ALTER TABLE `tbl_users` ADD `gender` INT(2) NULL COMMENT '1 = Male, 2 Female' AFTER `mobile_number`, ADD `date_of_birth` DATE NULL AFTER `gender`, ADD `aadhar_number` BIGINT(15) NULL AFTER `date_of_birth`;

ALTER TABLE `tbl_users` ADD `pincode` INT(7) NULL AFTER `city_id`;

ALTER TABLE `tbl_user_device_info` CHANGE `log_interval` `log_interval` INT(7) NOT NULL;

/**
* 05-09-2021
**/
ALTER TABLE `tbl_user_installation_info` ADD `taluka` VARCHAR(100) NULL AFTER `district_id`;

ALTER TABLE `tbl_user_installation_info` ADD `installation_date` DATE NULL AFTER `installation_company`;

/**
* 06-09-2021
**/
ALTER TABLE `tbl_user_solar_panel_info` CHANGE `loc` `ioc` INT(3) NULL DEFAULT NULL;

ALTER TABLE `tbl_user_solar_panel_info` CHANGE `lmax` `imax` INT(3) NULL DEFAULT NULL;

/**
* 12-09-2021
**/
DROP PROCEDURE `procedureGetDataPacketByUserIdByImeiByTableName`; CREATE DEFINER=`root`@`localhost` PROCEDURE `procedureGetDataPacketByUserIdByImeiByTableName`(IN `userId` INT(11), IN `imeiNumber` BIGINT(15)) NOT DETERMINISTIC READS SQL DATA SQL SECURITY DEFINER SELECT * FROM tbl_data_packets WHERE user_id = userId AND imei_number = imeiNumber ORDER BY data_packet_id DESC LIMIT 1


/**
* 17-09-2021
**/
ALTER TABLE `tbl_user_installation_info` CHANGE `po_number` `po_number` VARCHAR(155) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL;

ALTER TABLE `tbl_user_solar_panel_info` CHANGE `make` `make` VARCHAR(155) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL;

/**
* 26-09-2021
**/
ALTER TABLE `tbl_device_upgrades` ADD `user_id` INT(11) NOT NULL AFTER `product_id`, ADD `current_version` VARCHAR(100) NOT NULL AFTER `user_id`, ADD `updated_version` VARCHAR(100) NOT NULL AFTER `current_version`, ADD `status` INT(3) NOT NULL COMMENT '1 = Upgrading Started, 2 = Lower Version, 3 = Version Not Received' AFTER `updated_version`, ADD `download` INT(3) NOT NULL AFTER `status`, ADD INDEX `ix_device_upgrades_user_id` (`user_id`);

ALTER TABLE `tbl_device_upgrades` CHANGE `download` `download` INT(3) NOT NULL DEFAULT '0';

ALTER TABLE `tbl_device_upgrades` CHANGE `status` `status` INT(3) NOT NULL DEFAULT '3' COMMENT '1 = Upgrading Started, 2 = Lower Version, 3 = Version Not Received, 4 = Upgradation Completed ';