--
-- Host: localhost    Database: cloud_usage
-- ------------------------------------------------------


--
-- Dumping routines for database 'cloud_usage'
--
/*!50003 DROP PROCEDURE IF EXISTS `IDEMPOTENT_ADD_COLUMN` */;
DELIMITER ;;
CREATE DEFINER=`cloud`@`localhost` PROCEDURE `IDEMPOTENT_ADD_COLUMN`(     IN in_table_name VARCHAR(200) , IN in_column_name VARCHAR(200) , IN in_column_definition VARCHAR(1000) )
BEGIN     DECLARE CONTINUE HANDLER FOR 1060 BEGIN END; SET @ddl = CONCAT('ALTER TABLE ', in_table_name); SET @ddl = CONCAT(@ddl, ' ', 'ADD COLUMN') ; SET @ddl = CONCAT(@ddl, ' ', in_column_name); SET @ddl = CONCAT(@ddl, ' ', in_column_definition); PREPARE stmt FROM @ddl; EXECUTE stmt; DEALLOCATE PREPARE stmt; END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `IDEMPOTENT_ADD_UNIQUE_INDEX` */;
DELIMITER ;;
CREATE DEFINER=`cloud`@`localhost` PROCEDURE `IDEMPOTENT_ADD_UNIQUE_INDEX`(     IN in_table_name VARCHAR(200) , IN in_index_name VARCHAR(200) , IN in_index_definition VARCHAR(1000) )
BEGIN     DECLARE CONTINUE HANDLER FOR 1061 BEGIN END; SET @ddl = CONCAT('ALTER TABLE ', in_table_name); SET @ddl = CONCAT(@ddl, ' ', 'ADD UNIQUE INDEX ', in_index_name); SET @ddl = CONCAT(@ddl, ' ', in_index_definition); PREPARE stmt FROM @ddl; EXECUTE stmt; DEALLOCATE PREPARE stmt; END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `IDEMPOTENT_CHANGE_COLUMN` */;
DELIMITER ;;
CREATE DEFINER=`cloud`@`localhost` PROCEDURE `IDEMPOTENT_CHANGE_COLUMN`(     IN in_table_name VARCHAR(200) , IN in_old_column_name VARCHAR(200) , IN in_new_column_name VARCHAR(200) , IN in_column_definition VARCHAR(1000) )
BEGIN     DECLARE CONTINUE HANDLER FOR 1060 BEGIN END; SET @ddl = CONCAT('ALTER TABLE ', in_table_name); SET @ddl = CONCAT(@ddl, ' ', ' CHANGE COLUMN') ; SET @ddl = CONCAT(@ddl, ' ', in_old_column_name); SET @ddl = CONCAT(@ddl, ' ', in_new_column_name); SET @ddl = CONCAT(@ddl, ' ', in_column_definition); PREPARE stmt FROM @ddl; EXECUTE stmt; DEALLOCATE PREPARE stmt; END ;;
DELIMITER ;
/*!50003 DROP PROCEDURE IF EXISTS `IDEMPOTENT_DROP_INDEX` */;
DELIMITER ;;
CREATE DEFINER=`cloud`@`localhost` PROCEDURE `IDEMPOTENT_DROP_INDEX`(     IN in_index_name VARCHAR(200) , IN in_table_name VARCHAR(200) )
BEGIN     DECLARE CONTINUE HANDLER FOR 1091 BEGIN END; SET @ddl = CONCAT('DROP INDEX ', in_index_name); SET @ddl = CONCAT(@ddl, ' ', ' ON ') ; SET @ddl = CONCAT(@ddl, ' ', in_table_name); PREPARE stmt FROM @ddl; EXECUTE stmt; DEALLOCATE PREPARE stmt; END ;;
DELIMITER ;


