Class: ArJdbc::Tasks::HSQLDBDatabaseTasks

Inherits:
JdbcDatabaseTasks show all
Defined in:
lib/arjdbc/tasks/hsqldb_database_tasks.rb

Direct Known Subclasses

H2DatabaseTasks

Instance Attribute Summary

Attributes inherited from JdbcDatabaseTasks

#configuration

Instance Method Summary collapse

Methods inherited from JdbcDatabaseTasks

#charset, #collation, #expand_path, #initialize, #resolve_database, #resolve_database_from_url, #structure_dump, #structure_load

Constructor Details

This class inherits a constructor from ArJdbc::Tasks::JdbcDatabaseTasks

Instance Method Details

#createObject



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 (protected)



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|
    # test.hsqldb.tmp (dir)
    # test.hsqldb.lck
    # test.hsqldb.lobs
    # test.hsqldb.script
    # test.hsqldb.properties
    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 (protected)



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

#dropObject 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