Class: ActiveRecord::Tasks::FbDatabaseTasks

Inherits:
Object
  • Object
show all
Defined in:
lib/active_record/tasks/fb_database_tasks.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(configuration, root = ::ActiveRecord::Tasks::DatabaseTasks.root) ⇒ FbDatabaseTasks

Returns a new instance of FbDatabaseTasks.



6
7
8
# File 'lib/active_record/tasks/fb_database_tasks.rb', line 6

def initialize(configuration, root = ::ActiveRecord::Tasks::DatabaseTasks.root)
  @root, @configuration = root, fb_connection_config(configuration)
end

Instance Method Details

#createObject



10
11
12
13
14
15
16
# File 'lib/active_record/tasks/fb_database_tasks.rb', line 10

def create
  fb_database.create
  establish_connection configuration
rescue ::Fb::Error => e
  raise unless e.message.include?('database or file exists')
  raise DatabaseAlreadyExists
end

#dropObject



18
19
20
21
22
# File 'lib/active_record/tasks/fb_database_tasks.rb', line 18

def drop
  fb_database.drop
rescue ::Fb::Error => e
  raise ::ActiveRecord::ConnectionNotEstablished, e.message
end

#purgeObject



24
25
26
27
# File 'lib/active_record/tasks/fb_database_tasks.rb', line 24

def purge
  drop rescue nil
  create
end

#structure_dump(filename) ⇒ Object



29
30
31
# File 'lib/active_record/tasks/fb_database_tasks.rb', line 29

def structure_dump(filename)
  isql :extract, output: filename
end

#structure_load(filename) ⇒ Object



33
34
35
# File 'lib/active_record/tasks/fb_database_tasks.rb', line 33

def structure_load(filename)
  isql input: filename
end