update DESIGNPROJECT set VersionNumber = '2.6';

update DESIGNPROJECT set reliabilityFatigueTop = '25';

ALTER TABLE ASPHALT ADD percentAsphaltContentByWeightOfMix FLOAT;
ALTER TABLE ASPHALT ADD aggregateGradationParameter FLOAT;
ALTER TABLE ASPHALT ADD isAggregateGradationParameterCalculated BIT;

update ASPHALT set percentAsphaltContentByWeightOfMix = 4.5 where percentAsphaltContentByWeightOfMix is NULL;
update ASPHALT set aggregateGradationParameter = 0.402 where aggregateGradationParameter is NULL;
update ASPHALT set isAggregateGradationParameterCalculated = 1 where isAggregateGradationParameterCalculated is NULL;

update CALIBRATION set calibrationValue = 2.5219 where calibrationName = 'TopC1';
update CALIBRATION set calibrationValue = 0.8069 where calibrationName = 'TopC2';
update CALIBRATION set calibrationValue = 1 where calibrationName = 'TopC3';
update CALIBRATION set calibrationFactor = '0.3657 * TOP + 3.6563' where calibrationName = 'AlphaTop';

delete from CALIBRATION where calibrationName = 'TopC4';

insert into CALIBRATION
(
	objectId,
	calibrationType,
	calibrationName,
	calibrationFactor,
	calibrationValue
)
select existingProject.objectId, existingProject.calibrationType, 'TopKL1', '0', 64271618
from (select distinct objectId, calibrationType from CALIBRATION where calibrationType = 4 OR calibrationType = 5) as existingProject;

insert into CALIBRATION
(
	objectId,
	calibrationType,
	calibrationName,
	calibrationFactor,
	calibrationValue
)
select existingProject.objectId, existingProject.calibrationType, 'TopKL2', '0', 0.2855
from (select distinct objectId, calibrationType from CALIBRATION where calibrationType = 4 OR calibrationType = 5) as existingProject;

insert into CALIBRATION
(
	objectId,
	calibrationType,
	calibrationName,
	calibrationFactor,
	calibrationValue
)
select existingProject.objectId, existingProject.calibrationType, 'TopKL3', '0', 0.011
from (select distinct objectId, calibrationType from CALIBRATION where calibrationType = 4 OR calibrationType = 5) as existingProject;

insert into CALIBRATION
(
	objectId,
	calibrationType,
	calibrationName,
	calibrationFactor,
	calibrationValue
)
select existingProject.objectId, existingProject.calibrationType, 'TopKL4', '0', 0.01488
from (select distinct objectId, calibrationType from CALIBRATION where calibrationType = 4 OR calibrationType = 5) as existingProject;

insert into CALIBRATION
(
	objectId,
	calibrationType,
	calibrationName,
	calibrationFactor,
	calibrationValue
)
select existingProject.objectId, existingProject.calibrationType, 'TopKL5', '0', 3.266
from (select distinct objectId, calibrationType from CALIBRATION where calibrationType = 4 OR calibrationType = 5) as existingProject;
	

