Sha256: 16e6df7122ec0165535f9a8e5d095c0b7310329dbd8896648b93fefc156d4a69
Contents?: true
Size: 990 Bytes
Versions: 4
Compression:
Stored size: 990 Bytes
Contents
module SequelRails module Storage class Jdbc < Abstract def _is_mysql? database.match(/^jdbc:mysql/) end def _root_url database.scan(/^jdbc:mysql:\/\/\w*:?\d*/) end def db_name database.scan(/^jdbc:mysql:\/\/\w+:?\d*\/(\w+)/).flatten.first end def _params database.scan(/\?.*$/) end def _create if _is_mysql? ::Sequel.connect("#{_root_url}#{_params}") do |db| db.execute("CREATE DATABASE IF NOT EXISTS `#{db_name}` DEFAULT CHARACTER SET #{charset} DEFAULT COLLATE #{collation}") end end end def _drop if _is_mysql? ::Sequel.connect("#{_root_url}#{_params}") do |db| db.execute("DROP DATABASE IF EXISTS `#{db_name}`") end end end private def collation @collation ||= config['collation'] || ENV['COLLATION'] || 'utf8_unicode_ci' end end end end
Version data entries
4 entries across 4 versions & 1 rubygems