Reputation: 7585
I am trying to write a script to patch our mysql database. Something like this I can run:
If IsTargetVersion(1.1)
THEN
ALTER TABLE t1 ENGINE = InnoDB;
END IF;
The funny thing I found about MySql is: it doesn't support if condition in script. I don't want to create a store procedure, call it and drop it in my script. That looks stupid...
Does anybody have better approach?
Thanks
Upvotes: 1
Views: 3290
Reputation: 121952
This (pattern) solution just a workaround which will help you to use IF condition in the MySQL scripts -
SET @s = IF(IsTargetVersion(1.1), 'ALTER TABLE t1 ENGINE = InnoDB', 'DO SLEEP(0)');
PREPARE stmt1 FROM @s;
EXECUTE stmt1;
Upvotes: 2