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:
parent
70cafdc283
commit
548952a6f9
2 changed files with 2 additions and 2 deletions
|
@ -41,7 +41,7 @@ Puppet::Type.type(:mysql_database).provide(:mysql, :parent => Puppet::Provider::
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
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
|
@property_hash.clear
|
||||||
exists? ? (return false) : (return true)
|
exists? ? (return false) : (return true)
|
||||||
|
|
|
@ -64,7 +64,7 @@ test
|
||||||
|
|
||||||
describe 'destroy' do
|
describe 'destroy' do
|
||||||
it 'removes a database if present' 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.expects(:exists?).returns(false)
|
||||||
provider.destroy.should be_truthy
|
provider.destroy.should be_truthy
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue