Prevent ERROR 1008 in mysql_database provider

Check for database existence when dropping to prevent

  ERROR 1008 (HY000): Can't drop database 'test'; database doesn't exist

Signed-off-by: Ray Lehtiniemi <rayl@mail.com>
This commit is contained in:
Ray Lehtiniemi 2014-07-23 14:12:00 -06:00
parent 70cafdc283
commit 548952a6f9
2 changed files with 2 additions and 2 deletions

View file

@ -41,7 +41,7 @@ Puppet::Type.type(:mysql_database).provide(:mysql, :parent => Puppet::Provider::
end
def destroy
mysql([defaults_file, '-NBe', "drop database `#{@resource[:name]}`"].compact)
mysql([defaults_file, '-NBe', "drop database if exists `#{@resource[:name]}`"].compact)
@property_hash.clear
exists? ? (return false) : (return true)

View file

@ -64,7 +64,7 @@ test
describe 'destroy' do
it 'removes a database if present' do
provider.expects(:mysql).with([defaults_file, '-NBe', "drop database `#{resource[:name]}`"])
provider.expects(:mysql).with([defaults_file, '-NBe', "drop database if exists `#{resource[:name]}`"])
provider.expects(:exists?).returns(false)
provider.destroy.should be_truthy
end