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
196
197
198
199
200
201
202
|
# File 'lib/sequel-rails/storage.rb', line 196
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
204
205
206
207
208
209
210
|
# File 'lib/sequel-rails/storage.rb', line 204
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
180
181
182
|
# File 'lib/sequel-rails/storage.rb', line 180
def _is_mysql?
database.match(/^jdbc:mysql/)
end
|
#_params ⇒ Object
192
193
194
|
# File 'lib/sequel-rails/storage.rb', line 192
def _params
database.scan /\?.*$/
end
|
#_root_url ⇒ Object
184
185
186
|
# File 'lib/sequel-rails/storage.rb', line 184
def _root_url
database.scan /^jdbc:mysql:\/\/\w*:?\d*/
end
|
#db_name ⇒ Object
188
189
190
|
# File 'lib/sequel-rails/storage.rb', line 188
def db_name
database.scan(/^jdbc:mysql:\/\/\w+:?\d*\/(\w+)/).flatten.first
end
|