Class: ArJdbc::Tasks::HSQLDBDatabaseTasks
Instance Attribute Summary
#configuration
Instance Method Summary
collapse
#charset, #collation, #expand_path, #initialize, #resolve_database, #resolve_database_from_url, #structure_dump, #structure_load
Instance Method Details
#create ⇒ Object
7
8
9
10
|
# File 'lib/arjdbc/tasks/hsqldb_database_tasks.rb', line 7
def create
establish_connection(config)
ActiveRecord::Base.connection
end
|
#delete_database_files(config) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/arjdbc/tasks/hsqldb_database_tasks.rb', line 38
def delete_database_files(config)
return unless db_base = database_base_name(config)
Dir.glob("#{db_base}.*").each do |file|
if File.directory?(file)
FileUtils.rm_r(file)
FileUtils.rmdir(file)
else
FileUtils.rm(file)
end
end
if File.exist?(db_base)
FileUtils.rm_r(db_base)
FileUtils.rmdir(db_base)
end
end
|
#do_drop_database(config) ⇒ Object
33
34
35
36
|
# File 'lib/arjdbc/tasks/hsqldb_database_tasks.rb', line 33
def do_drop_database(config)
connection.drop_database resolve_database(config)
connection.shutdown
end
|
#drop ⇒ Object
Also known as:
purge
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/arjdbc/tasks/hsqldb_database_tasks.rb', line 12
def drop
error = nil
begin
establish_connection(config)
do_drop_database(config)
rescue => e
error = e
raise error
ensure
begin
keep_db_files = ENV['KEEP_DB_FILES'] && ENV['KEEP_DB_FILES'] != 'false'
delete_database_files(config) unless keep_db_files
rescue => e
raise e unless error
end
end
end
|