 
 		select 'Updating obs' AS '*** Step: ***', new_db_version from dual;
 
-		ALTER TABLE `obs` ADD COLUMN `concept_name_id` int(11) AFTER `concept_id`;
 		ALTER TABLE `obs` ADD COLUMN `value_coded_name_id` int(11) AFTER `value_coded`;
 
 		select '***' AS '...done' from dual;


		select 'Constraining obs' AS '*** Step: ***', new_db_version from dual;
		
		ALTER TABLE `obs` ADD CONSTRAINT `obs_concept_name_used` FOREIGN KEY (`concept_name_id`) 
			REFERENCES `concept_name` (`concept_name_id`);
		ALTER TABLE `obs` ADD CONSTRAINT `obs_name_of_coded_value` FOREIGN KEY (`value_coded_name_id`) 
			REFERENCES `concept_name` (`concept_name_id`);


//
delimiter ;
call diff_procedure('1.4.0.18');

#-----------------------------------------------------------
# OpenMRS Datamodel version 1.4.0.19
# Andreas Kollegger   Oct 16th, 2008
#
# a dummy update to ensure that the db version bumps up
# after the previous call possibly failed
#-----------------------------------------------------------
DROP PROCEDURE IF EXISTS diff_procedure;
delimiter //
CREATE PROCEDURE diff_procedure (IN new_db_version VARCHAR(10))
BEGIN
	IF (SELECT REPLACE(property_value, '.', '0') < REPLACE(new_db_version, '.', '0') FROM global_property WHERE property = 'database_version') THEN

		UPDATE `global_property` SET property_value=new_db_version WHERE property = 'database_version';

	END IF;
END;
//
delimiter ;
call diff_procedure('1.4.0.19');

#-----------------------------------
# Clean up - Keep this section at the very bottom of diff script
