<?php

require_once 'globals.php';


class improveDbCommand extends CConsoleCommand
{
	public function run($args)
	{


		//var_dump($args);
		
		echo "\n######################################################################";
		echo "\n##                                                                  ##";
		echo "\n##                         Improve Db                               ##";
		echo "\n##                                                                  ##";
		echo "\n######################################################################";
		echo "\n";
		echo "\n";
		


		//echo array_search('/?', $args) ;
		
		echo "\n delete indexes.";
		
/*		
		
		echo "\n delete index UserID on abbonamentotable..";
		Yii::app()->db->createCommand('DROP INDEX UserID ON abbonamentotable')->execute();
		echo "\n done";
		
		echo "\n delete index status_index on event_reporting..";
		Yii::app()->db->createCommand('DROP INDEX UserID ON event_reporting')->execute();
		echo "\n done";
		
		
		echo "\n delete index type_index on event_reporting..";
		Yii::app()->db->createCommand('DROP INDEX type_index ON event_reporting')->execute();
		echo "\n done";
		
		echo "\n delete index Index_class_time_gate_counter on statstable..";
		Yii::app()->db->createCommand('DROP INDEX Index_class_time_gate_counter ON statstable')->execute();
		echo "\n done";
		
		echo "\n delete index Index_enddatetime_gate on statstable..";
		Yii::app()->db->createCommand('DROP INDEX Index_enddatetime_gate ON statstable')->execute();
		echo "\n done";
		
		echo "\n delete index Index_gate_startdatetimev on statstable..";
		Yii::app()->db->createCommand('DROP INDEX Index_gate_startdatetime ON statstable')->execute();
		echo "\n done";
		
		echo "\n delete index index_start_time on statstable..";
		Yii::app()->db->createCommand('DROP INDEX index_start_time ON statstable')->execute();
		echo "\n done";
		
		echo "\n delete index start_end_date_index on statstable..";
		Yii::app()->db->createCommand('DROP INDEX start_end_date_index ON statstable')->execute();
		echo "\n done";
		
		echo "\n delete index StatID on statsvaluestable..";
		Yii::app()->db->createCommand('DROP INDEX StatID ON statsvaluestable')->execute();
		echo "\n done";
		
		echo "\n delete index index_approved_not_exported on storicotable..";
		Yii::app()->db->createCommand('DROP INDEX index_approved_not_exported ON storicotable')->execute();
		echo "\n done";
		
		echo "\n delete index start_end_date_index on storicotable..";
		Yii::app()->db->createCommand('DROP INDEX Index_ext_code_validation_result_validated_by ON storicotable')->execute();
		echo "\n done";
		
		echo "\n delete index Index_for_pending on storicotable..";
		Yii::app()->db->createCommand('DROP INDEX Index_for_pending ON storicotable')->execute();
		echo "\n done";
		
		echo "\n delete index index_order_starttime on storicotable..";
		Yii::app()->db->createCommand('DROP INDEX index_order_starttime ON storicotable')->execute();
		echo "\n done";
		
		echo "\n delete index index_order_validatedby on storicotable..";
		Yii::app()->db->createCommand('DROP INDEX index_order_validatedby ON storicotable')->execute();
		echo "\n done";
		
		echo "\n delete index validated_user_validatetime on storicotable..";
		Yii::app()->db->createCommand('DROP INDEX validated_user_validatetime ON storicotable')->execute();
		echo "\n done";
		
		
		echo "\n delete index EventID on teb_table..";
		Yii::app()->db->createCommand('DROP INDEX EventID ON teb_table')->execute();
		echo "\n done";
		
		
		echo "\n delete index index_plate on vehicletable..";
		Yii::app()->db->createCommand('DROP INDEX index_plate ON vehicletable')->execute();
		echo "\n done";
		
		echo "\n delete index UserID on vehicletable..";
		Yii::app()->db->createCommand('DROP INDEX UserID ON vehicletable')->execute();
		echo "\n done";
		
		echo "\n delete index AbbonamentoID on whitelisttable..";
		Yii::app()->db->createCommand('DROP INDEX AbbonamentoID ON whitelisttable')->execute();
		echo "\n done";
		
		echo "\n delete index GateID on whitelisttable..";
		Yii::app()->db->createCommand('DROP INDEX GateID ON whitelisttable')->execute();
		echo "\n done";
		
		*/		
		
		echo "\n improve abbonamentotable..";
		Yii::app()->db->createCommand(
		    "ALTER TABLE abbonamentotable
    		MODIFY COLUMN ID int(11) NOT NULL auto_increment
    		, MODIFY COLUMN Descrizione varchar(250) NULL
    		, MODIFY COLUMN Tipo varchar(30) NULL
    		, MODIFY COLUMN Abilitato tinyint(4) NULL
    		, MODIFY COLUMN Credito tinyint(4) NULL
    		, MODIFY COLUMN Autorizzazione SMALLINT(4) NULL
    		, MODIFY COLUMN UserID int(11) NULL
    		, MODIFY COLUMN Codice varchar(2) NULL
    		, MODIFY COLUMN list_code int(11) NULL"
		    )->execute();
		    echo "\n done";
		    
		    
		    echo "\n improve activitytable..";
		    Yii::app()->db->createCommand(
		    "ALTER TABLE activitytable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN Code varchar(250) NULL
		    , MODIFY COLUMN Description varchar(250) NULL
		    , MODIFY COLUMN TableName varchar(250) NULL
		    , MODIFY COLUMN RecordID int(11) NULL
		    , MODIFY COLUMN Type varchar(250) NULL
		    , MODIFY COLUMN Priority int(11) NULL
		    , MODIFY COLUMN Managed int(11) NULL
		    , MODIFY COLUMN ManagedBy varchar(250) NULL
		    , MODIFY COLUMN EventUUID varchar(250) NULL"
	        )->execute();
	        echo "\n done";
	        
    		echo "\n improve alarmtable..";
    		Yii::app()->db->createCommand(
		    "ALTER TABLE alarmtable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN AlarmID varchar(250) NULL
		    , MODIFY COLUMN AlarmDescription varchar(250) NULL
		    , MODIFY COLUMN LinkedTable varchar(5) NULL
		    , MODIFY COLUMN LinkedID int(11) NULL
		    , MODIFY COLUMN LinkedPage varchar(5) NULL
		    , MODIFY COLUMN Source varchar(10) NULL
		    , MODIFY COLUMN ManagedBy varchar(10) NULL
		    , MODIFY COLUMN Type varchar(50) NULL
		    , MODIFY COLUMN Priority tinyint(4) NULL
		    , MODIFY COLUMN UserID int(11) NULL
		    , MODIFY COLUMN TicketID int(11) NULL
		    , MODIFY COLUMN Ticket varchar(25) NULL
		    , MODIFY COLUMN AreaID int(11) NULL
		    , MODIFY COLUMN PositionID int(11) NULL
		    , MODIFY COLUMN Gate int(11) NULL
		    , MODIFY COLUMN Plate varchar(10) NULL
		    , MODIFY COLUMN Nationality varchar(15) NULL
		    , MODIFY COLUMN ImageLength int(11) NULL"
    		)->execute();
    		echo "\n done";
    		    
    		echo "\n improve appinfotable..";
    		Yii::app()->db->createCommand(
		    "ALTER TABLE appinfotable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN ApplicationID int(11) NULL
		    , MODIFY COLUMN ApplicationName varchar(25) NULL
		    , MODIFY COLUMN ApplicationVer varchar(25) NULL
		    , MODIFY COLUMN ApplicationIP varchar(15) NULL
		    , MODIFY COLUMN TheUser varchar(25) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve areatable..";
    		Yii::app()->db->createCommand(
		    "ALTER TABLE areatable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN Descrizione varchar(250) NULL
		    , MODIFY COLUMN IDArea int(11) NULL
		    , MODIFY COLUMN TempoTransito int(11) NULL
		    , MODIFY COLUMN PostiTotali int(11) NULL
		    , MODIFY COLUMN PostiOffSet int(11) NULL
		    , MODIFY COLUMN PostiOccupati int(11) NULL
		    , MODIFY COLUMN field_prova int(11) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve backuptable..";
    		Yii::app()->db->createCommand(		    
		   "ALTER TABLE backuptable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN UserID int(11) NULL
		    , MODIFY COLUMN EventType varchar(10) NULL
		    , MODIFY COLUMN EventMode varchar(50) NULL
		    , MODIFY COLUMN ModifiedBy varchar(5) NULL
		    , MODIFY COLUMN EventValid varchar(10) NULL
		    , MODIFY COLUMN ValidatedBy varchar(10) NULL
		    , MODIFY COLUMN Protocol varchar(20) NULL
		    , MODIFY COLUMN NextID int(11) NULL
		    , MODIFY COLUMN PreviousID int(11) NULL
		    , MODIFY COLUMN TicketID int(11) NULL
		    , MODIFY COLUMN Ticket varchar(250) NULL
		    , MODIFY COLUMN AreaID int(11) NULL
		    , MODIFY COLUMN PositionID int(11) NULL
		    , MODIFY COLUMN Direction tinyint(4) NULL
		    , MODIFY COLUMN Speed float NULL
		    , MODIFY COLUMN Classe varchar(20) NULL
		    , MODIFY COLUMN Height float NULL
		    , MODIFY COLUMN Width float NULL
		    , MODIFY COLUMN Length float NULL
		    , MODIFY COLUMN LaneID int(11) NULL
		    , MODIFY COLUMN IsBoxComputed tinyint(4) NULL
		    , MODIFY COLUMN Gate int(11) NULL
		    , MODIFY COLUMN Plate varchar(50) NULL
		    , MODIFY COLUMN ExtPlate varchar(50) NULL
		    , MODIFY COLUMN Nationality varchar(50) NULL
		    , MODIFY COLUMN NetworkID int(11) NULL
		    , MODIFY COLUMN ImageLength int(11) NULL
		    , MODIFY COLUMN Comments varchar(50) NULL
		    , MODIFY COLUMN ExtraDataLength int(11) NULL
		    , MODIFY COLUMN SignatureLength int(11) NULL
		    , MODIFY COLUMN UUID varchar(50) NULL
		    , MODIFY COLUMN ExtraInfoID int(11) NULL
		    , MODIFY COLUMN MatchMeasure float NULL
		    , MODIFY COLUMN GateDescription varchar(100) NULL
		    , MODIFY COLUMN TransitComments varchar(250) NULL
		    , MODIFY COLUMN GateType varchar(10) NULL
		    , MODIFY COLUMN Kemler varchar(10) NULL
		    , MODIFY COLUMN PlateCheck tinyint(4) NULL
		    , MODIFY COLUMN BlobFileName varchar(250) NULL
		    , MODIFY COLUMN Color varchar(250) NULL
		    , MODIFY COLUMN id_run int(11) NULL
		    , MODIFY COLUMN id_vehicle_color int(11) NULL
		    , MODIFY COLUMN id_data_check_user int(11) NULL
		    , MODIFY COLUMN id_validate_user int(11) NULL
		    , MODIFY COLUMN validation_result varchar(20) NULL
		    , MODIFY COLUMN ext_code varchar(20) NULL
		    , MODIFY COLUMN speed_limit int(11) NULL
		    , MODIFY COLUMN custom_plate_type varchar(20) NULL
		    , MODIFY COLUMN custom_property_type varchar(20) NULL
		    , MODIFY COLUMN custom_vehicle_type varchar(20) NULL
		    , MODIFY COLUMN speed_limit_signs varchar(10) NULL
		    , MODIFY COLUMN truck_bar_type varchar(10) NULL
		    , MODIFY COLUMN measured_speed float NULL
		    , MODIFY COLUMN ocr_quality float NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve behavior..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE behavior
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN name varchar(50) NULL
		    , MODIFY COLUMN tag varchar(50) NULL
		    , MODIFY COLUMN priority tinyint(4) NULL
		    , MODIFY COLUMN alarm_tag_name varchar(55) NULL"
    	    )->execute();
    	    echo "\n done";
    		    
    		echo "\n improve bfrmsgtable..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE bfrmsgtable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN PHNum int(11) NULL
		    , MODIFY COLUMN EvtISOString varchar(250) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve blacklistevents..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE blacklistevents
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN UserID int(11) NULL
		    , MODIFY COLUMN EventType varchar(250) NULL
		    , MODIFY COLUMN EventMode varchar(250) NULL
		    , MODIFY COLUMN ModifiedBy varchar(250) NULL
		    , MODIFY COLUMN EventValid varchar(250) NULL
		    , MODIFY COLUMN ValidatedBy varchar(250) NULL
		    , MODIFY COLUMN Protocol varchar(250) NULL
		    , MODIFY COLUMN NextID int(11) NULL
		    , MODIFY COLUMN PreviousID int(11) NULL
		    , MODIFY COLUMN TicketID int(11) NULL
		    , MODIFY COLUMN Ticket varchar(250) NULL
		    , MODIFY COLUMN AreaID int(11) NULL
		    , MODIFY COLUMN PositionID int(11) NULL
		    , MODIFY COLUMN Direction int(11) NULL
		    , MODIFY COLUMN Speed float NULL
		    , MODIFY COLUMN Classe varchar(250) NULL
		    , MODIFY COLUMN Height float NULL
		    , MODIFY COLUMN Width float NULL
		    , MODIFY COLUMN Length float NULL
		    , MODIFY COLUMN LaneID int(11) NULL
		    , MODIFY COLUMN IsBoxComputed int(11) NULL
		    , MODIFY COLUMN Gate int(11) NULL
		    , MODIFY COLUMN Plate varchar(250) NULL
		    , MODIFY COLUMN ExtPlate varchar(250) NULL
		    , MODIFY COLUMN Nationality varchar(250) NULL
		    , MODIFY COLUMN NetworkID int(11) NULL
		    , MODIFY COLUMN ImageLength int(11) NULL
		    , MODIFY COLUMN Comments varchar(250) NULL
		    , MODIFY COLUMN ExtraDataLength int(11) NULL
		    , MODIFY COLUMN SignatureLength int(11) NULL
		    , MODIFY COLUMN UUID varchar(250) NULL
		    , MODIFY COLUMN ExtraInfoID int(11) NULL
		    , MODIFY COLUMN MatchMeasure float NULL
		    , MODIFY COLUMN GateDescription varchar(250) NULL
		    , MODIFY COLUMN TransitComments varchar(250) NULL
		    , MODIFY COLUMN GateType varchar(10) NULL
		    , MODIFY COLUMN Kemler varchar(250) NULL
		    , MODIFY COLUMN PlateCheck int(11) NULL
		    , MODIFY COLUMN BlobFileName varchar(250) NULL
		    , MODIFY COLUMN Color varchar(250) NULL
		    , MODIFY COLUMN id_run int(11) NULL
		    , MODIFY COLUMN id_vehicle_color int(11) NULL
		    , MODIFY COLUMN id_data_check_user int(11) NULL
		    , MODIFY COLUMN id_validate_user int(11) NULL
		    , MODIFY COLUMN validation_result varchar(250) NULL
		    , MODIFY COLUMN ext_code varchar(250) NULL
		    , MODIFY COLUMN speed_limit int(11) NULL
		    , MODIFY COLUMN custom_plate_type varchar(250) NULL
		    , MODIFY COLUMN custom_property_type varchar(250) NULL
		    , MODIFY COLUMN custom_vehicle_type varchar(250) NULL
		    , MODIFY COLUMN speed_limit_signs varchar(250) NULL
		    , MODIFY COLUMN truck_bar_type varchar(250) NULL
		    , MODIFY COLUMN measured_speed float NULL
		    , MODIFY COLUMN ocr_quality float NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve command..";
    		Yii::app()->db->createCommand(		    
		   "ALTER TABLE command
		    MODIFY COLUMN id int(11) NOT NULL auto_increment
		    , MODIFY COLUMN status varchar(20) NULL
		    , MODIFY COLUMN operator varchar(100) NULL
		    , MODIFY COLUMN id_gate int(11) NULL
		    , MODIFY COLUMN uuid varchar(50) NULL
		    , MODIFY COLUMN command_data_length int(11) NULL
		    , MODIFY COLUMN comment varchar(250) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve configtable..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE configtable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN Status varchar(20) NULL
		    , MODIFY COLUMN Operator varchar(100) NULL
		    , MODIFY COLUMN GateID int(11) NULL
		    , MODIFY COLUMN UUID varchar(50) NULL
		    , MODIFY COLUMN Version int(11) NULL
		    , MODIFY COLUMN ConfigDataLength int(11) NULL
		    , MODIFY COLUMN Comment varchar(250) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve custom_plate_type..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE custom_plate_type
		    MODIFY COLUMN type varchar(55) NULL
		    , MODIFY COLUMN label varchar(55) NULL
		    , MODIFY COLUMN description varchar(155) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		    
    		echo "\n improve diagnostic..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE diagnostic
		    MODIFY COLUMN id int(11) NOT NULL auto_increment
		    , MODIFY COLUMN uuid varchar(50) NULL
		    , MODIFY COLUMN type varchar(25) NULL
		    , MODIFY COLUMN sub_type varchar(25) NULL
		    , MODIFY COLUMN description varchar(150) NULL
		    , MODIFY COLUMN status varchar(25) NULL
		    , MODIFY COLUMN taken_in_charge_by int(11) NULL
		    , MODIFY COLUMN managed_by int(11) NULL
		    , MODIFY COLUMN gate int(11) NULL
		    , MODIFY COLUMN extra_data varchar(250) NULL"
		    )->execute();
		    echo "\n done";
    		    
		    
		    
		    
		    
		    
		   
		    
		    
    		echo "\n improve event_reporting..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE event_reporting
		    MODIFY COLUMN id int(11) NOT NULL auto_increment
		    , MODIFY COLUMN type varchar(25) NULL
		    , MODIFY COLUMN description varchar(50) NULL
		    , MODIFY COLUMN status varchar(20) NULL
		    , MODIFY COLUMN taken_in_charge_by int(11) NULL
		    , MODIFY COLUMN managed_by int(11) NULL
		    , MODIFY COLUMN event_id int(11) NULL
		    , MODIFY COLUMN event_uuid varchar(50) NULL
		    , MODIFY COLUMN event_table_name varchar(50) NULL
		    , MODIFY COLUMN gate int(11) NULL"
		    )->execute();
		    echo "\n done";
    		    
		   
		    
		    
    		echo "\n improve events_behavior..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE events_behavior
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN id_event int(11) NULL
		    , MODIFY COLUMN id_behavior int(11) NULL
		    , MODIFY COLUMN validation_result varchar(25) NULL
		    , MODIFY COLUMN comment varchar(150) NULL
		    , MODIFY COLUMN violation_code varchar(20) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve eventtransfertable..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE eventtransfertable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN TableName varchar(250) NULL
		    , MODIFY COLUMN EventID int(11) NULL
		    , MODIFY COLUMN EventUUID varchar(250) NULL
		    , MODIFY COLUMN Plate varchar(250) NULL
		    , MODIFY COLUMN EventType varchar(250) NULL
		    , MODIFY COLUMN ReferenceSystem varchar(250) NULL
		    , MODIFY COLUMN ErrorCode float NULL
		    , MODIFY COLUMN ErrorDescription varchar(250) NULL
		    , MODIFY COLUMN gate int(11) NULL
		    , MODIFY COLUMN match_list varchar(250) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve gate_behavior..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE gate_behavior
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN id_gate int(11) NULL
		    , MODIFY COLUMN id_behavior int(11) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve gate_group..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE gate_group
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN name varchar(150) NULL
		    , MODIFY COLUMN num_of_events_per_run int(11) NULL DEFAULT '0'"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve gate_set..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE gate_set
		    MODIFY COLUMN name varchar(55) NOT NULL
		    , MODIFY COLUMN description varchar(55) NULL"
		    )->execute();
		    echo "\n done";
    		    
/*		    
    		echo "\n improve gatedetectortable..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE gatedetectortable
		    MODIFY COLUMN GateId int(11) NULL
		    , MODIFY COLUMN Direction varchar(15) NULL"
		    )->execute();
		    echo "\n done";
*/    		    
    		echo "\n improve gatedirectiontable..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE gatedirectiontable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN Descrizione varchar(250) NULL
		    , MODIFY COLUMN Type varchar(50) NULL
		    , MODIFY COLUMN Gate int(11) NULL
		    , MODIFY COLUMN Direction int(11) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve gateordertable..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE gateordertable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN Gate int(11) NULL
		    , MODIFY COLUMN PrevGate int(11) NULL
		    , MODIFY COLUMN MinTimeElapsed varchar(250) NULL
		    , MODIFY COLUMN MaxTimeElapsed varchar(250) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve gatetable..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE gatetable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN Descrizione varchar(150) NULL
		    , MODIFY COLUMN Matricola varchar(25) NULL
		    , MODIFY COLUMN ValidationMaxDelay int(11) NULL
		    , MODIFY COLUMN Type varchar(25) NULL
		    , MODIFY COLUMN Gate int(11) NULL
		    , MODIFY COLUMN Enable tinyint(4) NULL
		    , MODIFY COLUMN IP varchar(16) NULL
		    , MODIFY COLUMN Code varchar(50) NULL
		    , MODIFY COLUMN LinkedGate int(11) NULL
		    , MODIFY COLUMN AreaSourceID int(11) NULL
		    , MODIFY COLUMN AreaDestinationID int(11) NULL
		    , MODIFY COLUMN Status varchar(25) NULL
		    , MODIFY COLUMN Homologation varchar(150) NULL
		    , MODIFY COLUMN LastEventID int(11) NULL
		    , MODIFY COLUMN LifeSignalTimeOut int(11) NULL
		    , MODIFY COLUMN GateType varchar(10) NULL
		    , MODIFY COLUMN id_group int(11) NULL
		    , MODIFY COLUMN speed_limit int(11) NULL
		    , MODIFY COLUMN last_exported_event_id int(11) NULL
		    , MODIFY COLUMN short_name varchar(25) NULL
		    , MODIFY COLUMN work_mode varchar(15) NULL
		    , MODIFY COLUMN immunity_from_s int(11) NULL
		    , MODIFY COLUMN immunity_to_s int(11) NULL
		    , MODIFY COLUMN device_model varchar(25) NULL
		    , MODIFY COLUMN function varchar(15) NULL
		    , MODIFY COLUMN mapx varchar(15) NULL
		    , MODIFY COLUMN mapy varchar(15) NULL
		    , MODIFY COLUMN master_gate int(11) NULL
		    , MODIFY COLUMN yellow_time_set float NULL
		    , MODIFY COLUMN life_signal_filter_id int(11) NULL DEFAULT '-1'
		    , MODIFY COLUMN life_signal_filter_type varchar(15) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve interestingevents..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE interestingevents
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN UserID int(11) NULL
		    , MODIFY COLUMN EventType varchar(250) NULL
		    , MODIFY COLUMN EventMode varchar(250) NULL
		    , MODIFY COLUMN ModifiedBy varchar(250) NULL
		    , MODIFY COLUMN EventValid varchar(250) NULL
		    , MODIFY COLUMN ValidatedBy varchar(250) NULL
		    , MODIFY COLUMN Protocol varchar(250) NULL
		    , MODIFY COLUMN NextID int(11) NULL
		    , MODIFY COLUMN PreviousID int(11) NULL
		    , MODIFY COLUMN TicketID int(11) NULL
		    , MODIFY COLUMN Ticket varchar(250) NULL
		    , MODIFY COLUMN AreaID int(11) NULL
		    , MODIFY COLUMN PositionID int(11) NULL
		    , MODIFY COLUMN Direction int(11) NULL
		    , MODIFY COLUMN Speed float NULL
		    , MODIFY COLUMN Classe varchar(250) NULL
		    , MODIFY COLUMN Height float NULL
		    , MODIFY COLUMN Width float NULL
		    , MODIFY COLUMN Length float NULL
		    , MODIFY COLUMN LaneID int(11) NULL
		    , MODIFY COLUMN IsBoxComputed int(11) NULL
		    , MODIFY COLUMN Gate int(11) NULL
		    , MODIFY COLUMN Plate varchar(250) NULL
		    , MODIFY COLUMN ExtPlate varchar(250) NULL
		    , MODIFY COLUMN Nationality varchar(250) NULL
		    , MODIFY COLUMN NetworkID int(11) NULL
		    , MODIFY COLUMN ImageLength int(11) NULL
		    , MODIFY COLUMN Comments varchar(250) NULL
		    , MODIFY COLUMN ExtraDataLength int(11) NULL
		    , MODIFY COLUMN SignatureLength int(11) NULL
		    , MODIFY COLUMN UUID varchar(250) NULL
		    , MODIFY COLUMN ExtraInfoID int(11) NULL
		    , MODIFY COLUMN MatchMeasure float NULL
		    , MODIFY COLUMN GateDescription varchar(250) NULL
		    , MODIFY COLUMN TransitComments varchar(250) NULL
		    , MODIFY COLUMN GateType varchar(10) NULL
		    , MODIFY COLUMN Kemler varchar(250) NULL
		    , MODIFY COLUMN PlateCheck int(11) NULL
		    , MODIFY COLUMN BlobFileName varchar(250) NULL
		    , MODIFY COLUMN Color varchar(250) NULL
		    , MODIFY COLUMN id_run int(11) NULL
		    , MODIFY COLUMN id_vehicle_color int(11) NULL
		    , MODIFY COLUMN id_data_check_user int(11) NULL
		    , MODIFY COLUMN id_validate_user int(11) NULL
		    , MODIFY COLUMN validation_result varchar(250) NULL
		    , MODIFY COLUMN ext_code varchar(250) NULL
		    , MODIFY COLUMN speed_limit int(11) NULL
		    , MODIFY COLUMN custom_plate_type varchar(250) NULL
		    , MODIFY COLUMN custom_property_type varchar(250) NULL
		    , MODIFY COLUMN custom_vehicle_type varchar(250) NULL
		    , MODIFY COLUMN speed_limit_signs varchar(250) NULL
		    , MODIFY COLUMN truck_bar_type varchar(250) NULL
		    , MODIFY COLUMN measured_speed float NULL
		    , MODIFY COLUMN ocr_quality float NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve plate_auth_insert_profile..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE plate_auth_insert_profile
		    MODIFY COLUMN name varchar(100) NOT NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve plate_auth_insert_profile_field..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE plate_auth_insert_profile_field
		    MODIFY COLUMN profile tinyint(3) unsigned NOT NULL
		    , MODIFY COLUMN `group` varchar(55) NOT NULL DEFAULT ''
		    , MODIFY COLUMN `name` varchar(55) NOT NULL
		    , MODIFY COLUMN label varchar(55) NOT NULL
		    , MODIFY COLUMN description varchar(155) NULL
		    , MODIFY COLUMN type varchar(55) NOT NULL
		    , MODIFY COLUMN `default` varchar(155) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve plate_country..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE plate_country
		    MODIFY COLUMN label varchar(55) NULL
		    , MODIFY COLUMN iso_code varchar(5) NULL
		    , MODIFY COLUMN format varchar(10) NULL
		    , MODIFY COLUMN `rows` varchar(10) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve plate_list..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE plate_list
		    MODIFY COLUMN id int(11) NOT NULL auto_increment
		    , MODIFY COLUMN name varchar(50) NULL
		    , MODIFY COLUMN source varchar(100) NULL
		    , MODIFY COLUMN code int(11) NULL
		    , MODIFY COLUMN import_folder varchar(250) NULL
		    , MODIFY COLUMN import_type varchar(25) NULL
		    , MODIFY COLUMN title varchar(100) NULL
		    , MODIFY COLUMN mode varchar(25) NULL
		    , MODIFY COLUMN delete_old_days int(11) NULL
		    , MODIFY COLUMN import_mode varchar(5) NULL
		    , MODIFY COLUMN import_status varchar(25) NULL
		    , MODIFY COLUMN default_nationality varchar(15) NULL
		    , MODIFY COLUMN import_default_gate_id int(11) NULL DEFAULT '0'
		    , MODIFY COLUMN import_default_gate_type varchar(15) NULL DEFAULT 'gate'
		    , MODIFY COLUMN export_folder varchar(25) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve platetable..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE platetable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN Plate varchar(250) NULL
		    , MODIFY COLUMN ExtPlate varchar(250) NULL
		    , MODIFY COLUMN ImageLength int(11) NULL
		    , MODIFY COLUMN Gate int(11) NULL
		    , MODIFY COLUMN DirectionID int(11) NULL
		    , MODIFY COLUMN DirectionRecog int(11) NULL
		    , MODIFY COLUMN DirectionMatch int(11) NULL
		    , MODIFY COLUMN ChannelID int(11) NULL
		    , MODIFY COLUMN ID1 int(11) NULL
		    , MODIFY COLUMN ID2 int(11) NULL
		    , MODIFY COLUMN ID3 int(11) NULL
		    , MODIFY COLUMN Speed float NULL
		    , MODIFY COLUMN Classe varchar(250) NULL
		    , MODIFY COLUMN TicketID varchar(250) NULL
		    , MODIFY COLUMN AreaID int(11) NULL
		    , MODIFY COLUMN Nationality varchar(250) NULL
		    , MODIFY COLUMN NetworkID int(11) NULL
		    , MODIFY COLUMN Comments varchar(250) NULL
		    , MODIFY COLUMN ExtraDataLength int(11) NULL
		    , MODIFY COLUMN SignatureLength int(11) NULL
		    , MODIFY COLUMN UUID varchar(250) NULL
		    , MODIFY COLUMN ExtraInfoID int(11) NULL
		    , MODIFY COLUMN MatchMeasure float NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve platetypetable..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE platetypetable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN Descrizione varchar(250) NULL
		    , MODIFY COLUMN TypeID int(11) NULL
		    , MODIFY COLUMN Type varchar(250) NULL
		    , MODIFY COLUMN PlateLayout varchar(250) NULL
		    , MODIFY COLUMN Gestito varchar(250) NULL
		    , MODIFY COLUMN Abilitato varchar(250) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve run..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE run
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN id_gategroup int(11) NULL
		    , MODIFY COLUMN status varchar(50) NULL
		    , MODIFY COLUMN origin_type varchar(25) NULL
		    , MODIFY COLUMN confirmed_by int(11) NULL
		    , MODIFY COLUMN in_charge_to int(11) NULL
		    , MODIFY COLUMN terminated_by int(11) NULL
		    , MODIFY COLUMN termination_type varchar(25) NULL
		    , MODIFY COLUMN name varchar(50) NULL
		    , MODIFY COLUMN registration_status varchar(25) NULL DEFAULT 'unregistered'"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve run_schedule..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE run_schedule
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN name varchar(50) NULL
		    , MODIFY COLUMN Description varchar(50) NULL
		    , MODIFY COLUMN id_gate_group int(11) NULL
		    , MODIFY COLUMN id_time_table int(11) NULL
		    , MODIFY COLUMN event_num_splitting int(11) NULL DEFAULT '0'"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve section..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE section
		    MODIFY COLUMN id int(11) NOT NULL auto_increment
		    , MODIFY COLUMN name varchar(45) NULL
		    , MODIFY COLUMN description varchar(55) NULL
		    , MODIFY COLUMN id_gate_start int(11) NOT NULL
		    , MODIFY COLUMN id_gate_end int(11) NOT NULL
		    , MODIFY COLUMN road_length float NOT NULL
		    , MODIFY COLUMN road_speed_limit float NOT NULL
		    , MODIFY COLUMN road_speed_limit_unit varchar(30) NULL
		    , MODIFY COLUMN road_speed_threshold float NOT NULL
		    , MODIFY COLUMN discard_delta float NOT NULL
		    , MODIFY COLUMN final_discard_delta float NOT NULL
		    , MODIFY COLUMN last_event_id int(11) NULL
		    , MODIFY COLUMN min_speed float NULL
		    , MODIFY COLUMN max_speed float NULL
		    , MODIFY COLUMN default_speed float NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve section_event..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE section_event
		    MODIFY COLUMN id int(11) NOT NULL auto_increment
		    , MODIFY COLUMN vehicleid varchar(30) NOT NULL
		    , MODIFY COLUMN uuid varchar(40) NOT NULL
		    , MODIFY COLUMN ref_offset float NOT NULL
		    , MODIFY COLUMN ref_timestamp varchar(30) NOT NULL
		    , MODIFY COLUMN ref_line_from_pole float NOT NULL
		    , MODIFY COLUMN speed float NOT NULL
		    , MODIFY COLUMN image_bw varchar(255) NULL
		    , MODIFY COLUMN image_col varchar(255) NULL
		    , MODIFY COLUMN image_extra varchar(255) NULL
		    , MODIFY COLUMN id_gate int(11) NOT NULL
		    , MODIFY COLUMN class varchar(25) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve section_limits..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE section_limits
		    MODIFY COLUMN road_speed_limit float NOT NULL
		    , MODIFY COLUMN road_speed_threshold float NOT NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve special_day..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE special_day
		    MODIFY COLUMN name varchar(25) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve statstable..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE statstable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN Gate int(11) NULL
		    , MODIFY COLUMN Classe varchar(25) NULL
		    , MODIFY COLUMN lengthTimeSec int(11) NULL
		    , MODIFY COLUMN WeekDay varchar(5) NULL
		    , MODIFY COLUMN Counter int(11) NULL
		    , MODIFY COLUMN MeanSpeed float NULL
		    , MODIFY COLUMN SpeedLimit float NULL
		    , MODIFY COLUMN Mean float NULL
		    , MODIFY COLUMN Variance float NULL
		    , MODIFY COLUMN GroupID int(11) NULL
		    , MODIFY COLUMN Comments varchar(25) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve statsvaluestable..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE statsvaluestable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN StatID int(11) NULL
		    , MODIFY COLUMN ValueID int(11) NULL
		    , MODIFY COLUMN Counter int(11) NULL
		    , MODIFY COLUMN StartValue float NULL
		    , MODIFY COLUMN EndValue float NULL
		    , MODIFY COLUMN Description varchar(50) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve storicotable..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE storicotable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN UserID int(11) NULL
		    , MODIFY COLUMN EventType varchar(255) NULL
		    , MODIFY COLUMN EventMode varchar(255) NULL
		    , MODIFY COLUMN ModifiedBy varchar(50) NULL
		    , MODIFY COLUMN EventValid varchar(25) NULL
		    , MODIFY COLUMN ValidatedBy varchar(50) NULL
		    , MODIFY COLUMN Protocol varchar(30) NULL
		    , MODIFY COLUMN NextID int(11) NULL
		    , MODIFY COLUMN PreviousID int(11) NULL
		    , MODIFY COLUMN TicketID int(11) NULL
		    , MODIFY COLUMN Ticket varchar(50) NULL
		    , MODIFY COLUMN AreaID int(11) NULL
		    , MODIFY COLUMN PositionID int(11) NULL
		    , MODIFY COLUMN Direction tinyint(4) NULL
		    , MODIFY COLUMN Speed float NULL
		    , MODIFY COLUMN Classe varchar(25) NULL
		    , MODIFY COLUMN Height float NULL
		    , MODIFY COLUMN Width float NULL
		    , MODIFY COLUMN Length float NULL
		    , MODIFY COLUMN LaneID int(11) NULL
		    , MODIFY COLUMN IsBoxComputed int(4) NULL
		    , MODIFY COLUMN Gate int(11) NULL
		    , MODIFY COLUMN Plate varchar(50) NULL
		    , MODIFY COLUMN ExtPlate varchar(50) NULL
		    , MODIFY COLUMN Nationality varchar(50) NULL
		    , MODIFY COLUMN NetworkID int(20) NULL
		    , MODIFY COLUMN ImageLength int(11) NULL
		    , MODIFY COLUMN Comments varchar(100) NULL
		    , MODIFY COLUMN ExtraDataLength int(11) NULL
		    , MODIFY COLUMN SignatureLength int(11) NULL
		    , MODIFY COLUMN UUID varchar(50) NULL
		    , MODIFY COLUMN ExtraInfoID int(11) NULL
		    , MODIFY COLUMN MatchMeasure float NULL
		    , MODIFY COLUMN GateDescription varchar(250) NULL
		    , MODIFY COLUMN TransitComments varchar(250) NULL
		    , MODIFY COLUMN GateType varchar(20) NULL
		    , MODIFY COLUMN Kemler varchar(20) NULL
		    , MODIFY COLUMN PlateCheck int(11) NULL
		    , MODIFY COLUMN BlobFileName varchar(250) NULL
		    , MODIFY COLUMN Color varchar(250) NULL
		    , MODIFY COLUMN id_run int(11) NULL
		    , MODIFY COLUMN id_vehicle_color int(11) NULL
		    , MODIFY COLUMN id_data_check_user int(11) NULL
		    , MODIFY COLUMN id_validate_user int(11) NULL
		    , MODIFY COLUMN validation_result varchar(25) NULL
		    , MODIFY COLUMN ext_code varchar(30) NULL
		    , MODIFY COLUMN speed_limit int(11) NULL
		    , MODIFY COLUMN custom_plate_type varchar(25) NULL
		    , MODIFY COLUMN custom_property_type varchar(25) NULL
		    , MODIFY COLUMN custom_vehicle_type varchar(25) NULL
		    , MODIFY COLUMN custom_vehicle_property varchar(15) NULL
		    , MODIFY COLUMN speed_limit_signs varchar(30) NULL
		    , MODIFY COLUMN truck_bar_type varchar(15) NULL
		    , MODIFY COLUMN custom_nationality varchar(50) NULL
		    , MODIFY COLUMN measured_speed float NULL
		    , MODIFY COLUMN ocr_quality float NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve system_status..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE system_status
		    MODIFY COLUMN id int(11) NOT NULL auto_increment
		    , MODIFY COLUMN name varchar(50) NULL
		    , MODIFY COLUMN description varchar(50) NULL
		    , MODIFY COLUMN status varchar(25) NULL
		    , MODIFY COLUMN update_timeout int(11) NULL
		    , MODIFY COLUMN last_error_log varchar(150) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve teb_table..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE teb_table
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN EventID int(11) NULL
		    , MODIFY COLUMN BlobDataLength int(11) NULL
		    , MODIFY COLUMN type varchar(25) NULL
		    , MODIFY COLUMN BlobID int(11) NULL
		    , MODIFY COLUMN BlobIDSelected int(11) NULL
		    , MODIFY COLUMN Description varchar(50) NULL
		    , MODIFY COLUMN FullTime varchar(50) NULL
		    , MODIFY COLUMN BlobFileName varchar(250) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve timetable..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE timetable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN Descrizione varchar(150) NULL
		    , MODIFY COLUMN icon varchar(55) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve timezonetable..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE timezonetable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN Descrizione varchar(50) NULL
		    , MODIFY COLUMN WeekDay varchar(25) NULL
		    , MODIFY COLUMN YearDay varchar(25) NULL
		    , MODIFY COLUMN TimeID int(11) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve transitextrainfotable..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE transitextrainfotable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN Length float NULL
		    , MODIFY COLUMN FrontPlateHeight float NULL
		    , MODIFY COLUMN RearPlateHeight float NULL
		    , MODIFY COLUMN BlobDataLength int(11) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve user_tracking_table..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE user_tracking_table
		    MODIFY COLUMN action varchar(25) NULL
		    , MODIFY COLUMN table_name varchar(55) NULL
		    , MODIFY COLUMN primary_key varchar(155) NULL
		    , MODIFY COLUMN controller varchar(105) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve usertable..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE usertable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN Nome varchar(100) NULL
		    , MODIFY COLUMN Cognome varchar(150) NULL
		    , MODIFY COLUMN Note varchar(150) NULL
		    , MODIFY COLUMN ID1 int(11) NULL
		    , MODIFY COLUMN ID2 int(11) NULL
		    , MODIFY COLUMN Categoria int(11) NULL
		    , MODIFY COLUMN list_code int(11) NULL
		    , MODIFY COLUMN email varchar(155) NULL
		    , MODIFY COLUMN address varchar(155) NULL
		    , MODIFY COLUMN city varchar(155) NULL
		    , MODIFY COLUMN phone varchar(55) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve vehicle_category..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE vehicle_category
		    MODIFY COLUMN tag varchar(55) NULL
		    , MODIFY COLUMN name varchar(55) NULL
		    , MODIFY COLUMN description varchar(155) NULL
		    , MODIFY COLUMN color varchar(25) NULL
		    , MODIFY COLUMN priority tinyint(4) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve vehiclecolor..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE vehiclecolor
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN c01 varchar(20) NULL
		    , MODIFY COLUMN c02 varchar(20) NULL
		    , MODIFY COLUMN c03 varchar(20) NULL
		    , MODIFY COLUMN c04 varchar(20) NULL
		    , MODIFY COLUMN c05 varchar(20) NULL
		    , MODIFY COLUMN c06 varchar(20) NULL
		    , MODIFY COLUMN c07 varchar(20) NULL
		    , MODIFY COLUMN c08 varchar(20) NULL
		    , MODIFY COLUMN c09 varchar(20) NULL
		    , MODIFY COLUMN c10 varchar(20) NULL
		    , MODIFY COLUMN c11 varchar(20) NULL
		    , MODIFY COLUMN c12 varchar(20) NULL
		    , MODIFY COLUMN c13 varchar(20) NULL
		    , MODIFY COLUMN c14 varchar(20) NULL
		    , MODIFY COLUMN c15 varchar(20) NULL
		    , MODIFY COLUMN c16 varchar(20) NULL
		    , MODIFY COLUMN c17 varchar(20) NULL
		    , MODIFY COLUMN scw01 float NULL
		    , MODIFY COLUMN scw02 float NULL
		    , MODIFY COLUMN scw03 float NULL
		    , MODIFY COLUMN scw04 float NULL
		    , MODIFY COLUMN scw05 float NULL
		    , MODIFY COLUMN scw06 float NULL
		    , MODIFY COLUMN scw07 float NULL
		    , MODIFY COLUMN scw08 float NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve vehicletable..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE vehicletable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN Descrizione varchar(100) NULL
		    , MODIFY COLUMN Classe varchar(80) NULL
		    , MODIFY COLUMN Abilitato tinyint(4) NULL
		    , MODIFY COLUMN AreaID tinyint(4) NULL
		    , MODIFY COLUMN Targa varchar(50) NULL
		    , MODIFY COLUMN Nationality varchar(50) NULL
		    , MODIFY COLUMN NetworkID int(11) NULL
		    , MODIFY COLUMN UserID int(11) NULL
		    , MODIFY COLUMN ID1 int(11) NULL
		    , MODIFY COLUMN ID2 int(11) NULL
		    , MODIFY COLUMN ID3 int(11) NULL
		    , MODIFY COLUMN ID4 int(11) NULL
		    , MODIFY COLUMN ID5 int(11) NULL
		    , MODIFY COLUMN source varchar(250) NULL
		    , MODIFY COLUMN privacy_level tinyint(4) NULL
		    , MODIFY COLUMN list_code int(11) NULL
		    , MODIFY COLUMN type varchar(100) NULL
		    , MODIFY COLUMN category varchar(25) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve vehicletracetable..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE vehicletracetable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN VehicleID varchar(40) NULL
		    , MODIFY COLUMN VehicleUUID varchar(50) NULL
		    , MODIFY COLUMN Speed float NULL
		    , MODIFY COLUMN MeanSpeed float NULL
		    , MODIFY COLUMN Height float NULL
		    , MODIFY COLUMN Width float NULL
		    , MODIFY COLUMN Length float NULL
		    , MODIFY COLUMN LaneID int(11) NULL
		    , MODIFY COLUMN IsBoxComputed tinyint(4) NOT NULL
		    , MODIFY COLUMN DetectionLength float NULL
		    , MODIFY COLUMN MinimumCameraDistance float NULL
		    , MODIFY COLUMN MaximumCameraDistance float NULL
		    , MODIFY COLUMN FullStartTime varchar(50) NULL
		    , MODIFY COLUMN FullEndTime varchar(50) NULL
		    , MODIFY COLUMN InterDistance float NULL
		    , MODIFY COLUMN ClassName varchar(20) NULL
		    , MODIFY COLUMN KemlerCode varchar(20) NULL
		    , MODIFY COLUMN Color varchar(250) NULL
		    , MODIFY COLUMN Brightness float NULL
		    , MODIFY COLUMN Direction varchar(5) NULL
		    , MODIFY COLUMN WorkingMode varchar(250) NULL
		    , MODIFY COLUMN GateID int(11) NULL
		    , MODIFY COLUMN ImageBNLength int(11) NULL
		    , MODIFY COLUMN ImageBNTick varchar(50) NULL
		    , MODIFY COLUMN ImageBNExtraInfo varchar(50) NULL
		    , MODIFY COLUMN ImageCOLLength int(11) NULL
		    , MODIFY COLUMN ImageCOLTick varchar(50) NULL
		    , MODIFY COLUMN ImageCOLExtraInfo varchar(50) NULL
		    , MODIFY COLUMN BlobFileNameBN varchar(150) NULL
		    , MODIFY COLUMN BlobFileNameCOL varchar(150) NULL
		    , MODIFY COLUMN Nationality varchar(50) NULL
		    , MODIFY COLUMN NetworkID int(11) NULL
		    , MODIFY COLUMN id_vehicle_color int(11) NULL
		    , MODIFY COLUMN speed_limit_signs varchar(50) NULL
		    , MODIFY COLUMN truck_bar_type varchar(50) NULL
		    , MODIFY COLUMN custom_vehicle_type varchar(50) NULL
		    , MODIFY COLUMN custom_nationality varchar(50) NULL
		    , MODIFY COLUMN video_file_name varchar(250) NULL
		    , MODIFY COLUMN ocr_quality float NULL DEFAULT -1"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve violation_codes..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE violation_codes
		    MODIFY COLUMN name varchar(50) NOT NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve violation_document..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE violation_document
		    MODIFY COLUMN id int(11) NOT NULL auto_increment
		    , MODIFY COLUMN id_event_behavior int(11) NULL
		    , MODIFY COLUMN status varchar(25) NULL
		    , MODIFY COLUMN document_size int(11) NULL
		    , MODIFY COLUMN document_filename varchar(150) NULL
		    , MODIFY COLUMN document_ext_size int(11) NULL
		    , MODIFY COLUMN document_ext_filename varchar(150) NULL
		    , MODIFY COLUMN document_web_size int(11) NULL
		    , MODIFY COLUMN document_web_filename varchar(150) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve whitelisttable..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE whitelisttable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN Descrizione varchar(250) NULL
		    , MODIFY COLUMN Transito varchar(20) NULL
		    , MODIFY COLUMN VehicleID int(11) NULL
		    , MODIFY COLUMN GateID int(11) NULL
		    , MODIFY COLUMN TimeID int(11) NULL
		    , MODIFY COLUMN UserID int(11) NULL
		    , MODIFY COLUMN AbbonamentoID int(11) NULL
		    , MODIFY COLUMN Speciale int(11) NULL
		    , MODIFY COLUMN Category varchar(10) NULL
		    , MODIFY COLUMN Note varchar(250) NULL
		    , MODIFY COLUMN list_code int(11) NULL
		    , MODIFY COLUMN type varchar(30) NULL
		    , MODIFY COLUMN action varchar(200) NULL
		    , MODIFY COLUMN GateID_type varchar(15) NOT NULL DEFAULT 'gate'
		    , MODIFY COLUMN insert_id int(11) NULL
		    , MODIFY COLUMN request_code varchar(20) NULL
		    , MODIFY COLUMN authorization_code varchar(20) NULL
		    , MODIFY COLUMN id_create_user int(11) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve work_periods..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE work_periods
		    MODIFY COLUMN registration_status varchar(25) NULL DEFAULT 'unregistered'"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve yii_session..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE yii_session
		    MODIFY COLUMN id varchar(32) NOT NULL DEFAULT ''"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve ztltable..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE ztltable
		    MODIFY COLUMN ID int(11) NOT NULL auto_increment
		    , MODIFY COLUMN Descrizione varchar(150) NULL
		    , MODIFY COLUMN GateID int(11) NULL
		    , MODIFY COLUMN TimeID int(11) NULL
		    , MODIFY COLUMN Transito varchar(25) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve bookmark..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE bookmark
		    MODIFY COLUMN type varchar(55) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve crossing_pairs..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE crossing_pairs
		    MODIFY COLUMN id int(11) NOT NULL auto_increment
		    , MODIFY COLUMN pair varchar(6) NULL
		    , MODIFY COLUMN gate_start_id int(11) NOT NULL
		    , MODIFY COLUMN gate_end_id int(11) NOT NULL
		    , MODIFY COLUMN elapsed float NOT NULL
		    , MODIFY COLUMN section_id int(11) NOT NULL
		    , MODIFY COLUMN speed float NOT NULL
		    , MODIFY COLUMN plate varchar(20) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve crossing_times..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE crossing_times
		    MODIFY COLUMN id int(11) NOT NULL auto_increment
		    , MODIFY COLUMN `range` float NULL
		    , MODIFY COLUMN id_gate_start int(11) NOT NULL
		    , MODIFY COLUMN id_gate_end int(11) NOT NULL
		    , MODIFY COLUMN ref_section int(11) NULL
		    , MODIFY COLUMN duration_avg float NULL
		    , MODIFY COLUMN duration_stddev float NULL
		    , MODIFY COLUMN duration_min float NULL
		    , MODIFY COLUMN duration_max float NULL
		    , MODIFY COLUMN duration_count float NULL
		    , MODIFY COLUMN result_code int(11) NOT NULL
		    , MODIFY COLUMN result float NULL
		    , MODIFY COLUMN reliability float NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve life_signal..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE life_signal
		    MODIFY COLUMN id int(11) NOT NULL auto_increment
		    , MODIFY COLUMN id_gate int(11) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve plate_authorization_action..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE plate_authorization_action
		    MODIFY COLUMN id int(11) NOT NULL auto_increment
		    , MODIFY COLUMN id_plate_authorization int(11) NOT NULL
		    , MODIFY COLUMN id_user int(11) NOT NULL
		    , MODIFY COLUMN action varchar(32) NULL
		    , MODIFY COLUMN list_code int(11) NULL"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve report_archive..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE report_archive
		    MODIFY COLUMN UserID int(11) NOT NULL
		    , MODIFY COLUMN PeriodID int(11) NULL
		    , MODIFY COLUMN GroupID int(11) NOT NULL
		    , MODIFY COLUMN MinExtcode int(11) NOT NULL
		    , MODIFY COLUMN MaxExtcode int(11) NOT NULL
		    , MODIFY COLUMN serviceID int(11) NULL
		    , MODIFY COLUMN registration_status varchar(25) NULL DEFAULT 'unregistered'"
		    )->execute();
		    echo "\n done";
    		    
    		echo "\n improve users..";
    		Yii::app()->db->createCommand(		    
		    "ALTER TABLE users
		    MODIFY COLUMN username varchar(26) NOT NULL
		    , MODIFY COLUMN email varchar(254) NOT NULL
		    , MODIFY COLUMN superuser tinyint(4) NOT NULL DEFAULT 0
		    , MODIFY COLUMN status varchar(25) NOT NULL
		    , MODIFY COLUMN first_name varchar(55) NULL
		    , MODIFY COLUMN last_name varchar(55) NULL
		    , MODIFY COLUMN matriculation_number varchar(254) NULL
		    , MODIFY COLUMN qualification varchar(254) NOT NULL
		    , MODIFY COLUMN apikey varchar(55) NULL"
		    )->execute();
		    echo "\n done";
    		    
		    
		    
		
		
		echo "\n done";

		
		return 0;
		
	}
	
}
?>