public function m_0_4_18()
 {
     @apache_setenv('no-gzip', 1);
     @ini_set('zlib.output_compression', 0);
     @ini_set('implicit_flush', 1);
     ini_set('memory_limit', '-1');
     $this->flushNotification("\n...Please wait... Updating is going on... DO NOT LEAVE THIS PAGE!");
     $this->flushNotification("<br/><br/>...Add new measurement....");
     $sql = "INSERT INTO `refbook_measurement_type` (`measurement_type_id` ,`display_name` ,`code` ,`ord`)\n                VALUES ('21', 'Cloud Measuring Range', 'cloud_measuring_range', '18')";
     Yii::app()->db->createCommand($sql)->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $sql = "INSERT INTO `refbook_measurement_type_metric` (`measurement_type_metric_id` ,`measurement_type_id` ,`metric_id` ,`is_main`)\n                VALUES ('32', '21', '11', '1'), ('33', '21', '22', '0')";
     Yii::app()->db->createCommand($sql)->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $sql = "ALTER TABLE `sensor_data` ADD `is_m` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `sensor_feature_value` ";
     Yii::app()->db->createCommand($sql)->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $sql = "ALTER TABLE `sensor_data` DROP INDEX `sensor_data__feature_measuuring_index` ,\n                ADD INDEX `sensor_data__feature_measuuring_index` ( `sensor_feature_id` , `measuring_timestamp` , `is_m` )";
     Yii::app()->db->createCommand($sql)->query();
     Yii::app()->db->createCommand("COMMIT")->query();
     $sql = "SELECT * FROM `" . StationSensor::model()->tableName() . "` WHERE `handler_id` = 15";
     $res = Yii::app()->db->createCommand($sql)->queryAll();
     if ($res) {
         foreach ($res as $key => $value) {
             $sql = "SELECT * \n                        FROM `" . StationSensorFeature::model()->tableName() . "` \n                        WHERE sensor_id = '" . $value['station_sensor_id'] . "' AND `feature_code` IN ('cloud_height_height_1', 'cloud_measuring_range')\n                        ORDER BY `feature_code`";
             $res2 = Yii::app()->db->createCommand($sql)->queryAll();
             if ($res2 && count($res2) == 1) {
                 $obj = new StationSensorFeature();
                 $obj->sensor_id = $res2[0]['sensor_id'];
                 $obj->feature_code = 'cloud_measuring_range';
                 $obj->feature_display_name = 'Measuring Range';
                 $obj->feature_constant_value = 0;
                 $obj->measurement_type_code = 'cloud_measuring_range';
                 $obj->metric_id = $res2[0]['metric_id'];
                 $obj->is_main = 0;
                 $obj->has_filters = 1;
                 $obj->has_filter_min = 1;
                 $obj->has_filter_max = 1;
                 $obj->has_filter_diff = 1;
                 $obj->is_constant = 0;
                 $obj->is_cumulative = 0;
                 $obj->save();
             }
         }
     }
     $this->flushNotification("<br/><br/>...Updated ....");
     It::memStatus('update__success');
     $this->flushNotification('<script type="text/javascript"> setTimeout(function(){document.location.href="' . Yii::app()->controller->createUrl('update/index') . '"}, 5000)</script>');
 }