Class: Rails::Sequel::Storage::Jdbc
Instance Attribute Summary
#config
Instance Method Summary
collapse
#charset, #create, create_all, create_environment, #database, #drop, drop_all, drop_environment, #host, #initialize, new, #owner, #password, #port, #username
Instance Method Details
#_create ⇒ Object
224
225
226
227
228
229
230
|
# File 'lib/sequel-rails/storage.rb', line 224
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
|
#_drop ⇒ Object
232
233
234
235
236
237
238
|
# File 'lib/sequel-rails/storage.rb', line 232
def _drop
if _is_mysql?
::Sequel.connect("#{_root_url}#{_params}") do |db|
db.execute("DROP DATABASE IF EXISTS `#{db_name}`")
end
end
end
|
#_is_mysql? ⇒ Boolean
208
209
210
|
# File 'lib/sequel-rails/storage.rb', line 208
def _is_mysql?
database.match(/^jdbc:mysql/)
end
|
#_params ⇒ Object
220
221
222
|
# File 'lib/sequel-rails/storage.rb', line 220
def _params
database.scan /\?.*$/
end
|
#_root_url ⇒ Object
212
213
214
|
# File 'lib/sequel-rails/storage.rb', line 212
def _root_url
database.scan /^jdbc:mysql:\/\/\w*:?\d*/
end
|
#db_name ⇒ Object
216
217
218
|
# File 'lib/sequel-rails/storage.rb', line 216
def db_name
database.scan(/^jdbc:mysql:\/\/\w+:?\d*\/(\w+)/).flatten.first
end
|