Class: DbAgent::DbHandler::MySQL
Instance Attribute Summary
#backup_folder, #config, #data_folder, #migrations_folder, #schema_folder, #superconfig, #viewpoints_folder
Instance Method Summary
collapse
factor, #initialize, #migrate, #ping, #require_viewpoints!, #sequel_db, #sequel_superdb, #system, #wait, #wait_server
Instance Method Details
#backup ⇒ Object
14
15
16
17
|
# File 'lib/db_agent/db_handler/mysql.rb', line 14
def backup
datetime = Time.now.strftime('%Y%m%dT%H%M%S')
shell mysqldump(config[:database], "> #{backup_folder}/backup-#{datetime}.sql")
end
|
#create ⇒ Object
6
7
8
|
# File 'lib/db_agent/db_handler/mysql.rb', line 6
def create
raise
end
|
#drop ⇒ Object
10
11
12
|
# File 'lib/db_agent/db_handler/mysql.rb', line 10
def drop
raise
end
|
#repl ⇒ Object
19
20
21
|
# File 'lib/db_agent/db_handler/mysql.rb', line 19
def repl
shell mysql(config[:database])
end
|
#restore(_t, args) ⇒ Object
29
30
31
32
33
34
35
36
|
# File 'lib/db_agent/db_handler/mysql.rb', line 29
def restore(_t, args)
candidates = backup_folder.glob('*.sql').sort
if args[:pattern] && rx = Regexp.new(args[:pattern])
candidates = candidates.select { |f| f.basename.to_s =~ rx }
end
file = candidates.last
shell mysql(config[:database], '<', file.to_s)
end
|
#spy ⇒ Object
23
24
25
26
27
|
# File 'lib/db_agent/db_handler/mysql.rb', line 23
def spy
jdbc_jar = (Path.dir.parent / 'vendor').glob('mysql*.jar').first
system %(java -jar vendor/schemaSpy_5.0.0.jar -dp #{jdbc_jar} -t mysql -host #{config[:host]} -u #{config[:user]} -p #{config[:password]} -db #{config[:database]} -s public -o #{schema_folder}/spy)
system %(open #{schema_folder}/spy/index.html)
end
|