Permalink
Browse files

Added IF NOT EXISTS condition to create and drop tables (Mysql and JD…

…BC/Mysql)
  • Loading branch information...
1 parent d200028 commit 941931500904f1087e5954d08d86f8ec02893a96 @brasten committed Aug 6, 2010
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/sequel-rails/storage.rb
@@ -115,7 +115,7 @@ def path
class Mysql < Storage
def _create
- execute("CREATE DATABASE `#{database}` DEFAULT CHARACTER SET #{charset} DEFAULT COLLATE #{collation}")
+ execute("CREATE DATABASE IF NOT EXISTS `#{database}` DEFAULT CHARACTER SET #{charset} DEFAULT COLLATE #{collation}")
end
def _drop
@@ -183,7 +183,7 @@ def _params
def _create
if _is_mysql?
::Sequel.connect("#{_root_url}#{_params}") do |db|
- db.execute("CREATE DATABASE `#{db_name}` DEFAULT CHARACTER SET #{charset} DEFAULT COLLATE #{collation}")
+ db.execute("CREATE DATABASE IF NOT EXISTS `#{db_name}` DEFAULT CHARACTER SET #{charset} DEFAULT COLLATE #{collation}")
end
end
end

0 comments on commit 9419315

Please sign in to comment.