DELIMITER //

CREATE DEFINER=`root`@`localhost` PROCEDURE `sp_AddColumn`(
	IN `DatabaseName` VARCHAR(128),
	IN `TableName` VARCHAR(128),
	IN `ColumnName` VARCHAR(128),
	IN `ColumnType` VARCHAR(128),
	IN `ColumnSize` VARCHAR(128)
)
LANGUAGE SQL
NOT DETERMINISTIC
CONTAINS SQL
SQL SECURITY DEFINER
COMMENT ''
BEGIN
	IF NOT EXISTS(
		SELECT *
		FROM INFORMATION_SCHEMA.COLUMNS
		WHERE table_schema = DatabaseName AND
		table_name = TableName AND
		column_name = ColumnName
	) THEN
		CASE
		WHEN ColumnType == 'INT' THEN
			ALTER TABLE TableName ADD ColumnName INT NOT NULL DEFAULT 0;
		ELSE
			ALTER TABLE TableName ADD ColumnName TEXT NOT NULL default '';		
		END CASE;
	END IF;
END

//