Class: ArJdbc::Tasks::MSSQLDatabaseTasks

Inherits:
Object
  • Object
show all
Defined in:
lib/arjdbc/tasks/mssql_database_tasks.rb

Overview

:nodoc:

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(db_config) ⇒ MSSQLDatabaseTasks

Returns a new instance of MSSQLDatabaseTasks.



16
17
18
19
# File 'lib/arjdbc/tasks/mssql_database_tasks.rb', line 16

def initialize(db_config)
  @db_config = db_config
  @configuration_hash = db_config.configuration_hash
end

Class Method Details

.using_database_configurations?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/arjdbc/tasks/mssql_database_tasks.rb', line 12

def self.using_database_configurations?
  true
end

Instance Method Details

#charsetObject



39
40
41
# File 'lib/arjdbc/tasks/mssql_database_tasks.rb', line 39

def charset
  connection.charset
end

#collationObject



43
44
45
# File 'lib/arjdbc/tasks/mssql_database_tasks.rb', line 43

def collation
  connection.collation
end

#createObject



21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/arjdbc/tasks/mssql_database_tasks.rb', line 21

def create
  establish_master_connection
  connection.create_database(db_config.database, creation_options)
  establish_connection(db_config)
rescue ActiveRecord::StatementInvalid => e
  case e.message
  when /database .* already exists/i
    raise ActiveRecord::Tasks::DatabaseAlreadyExists
  else
    raise
  end
end

#dropObject



34
35
36
37
# File 'lib/arjdbc/tasks/mssql_database_tasks.rb', line 34

def drop
  establish_master_connection
  connection.drop_database(db_config.database)
end

#purgeObject



47
48
49
50
51
# File 'lib/arjdbc/tasks/mssql_database_tasks.rb', line 47

def purge
  clear_active_connections!
  drop
  create
end

#structure_dump(filename, _extra_flags) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/arjdbc/tasks/mssql_database_tasks.rb', line 53

def structure_dump(filename, _extra_flags)
  args = prepare_command_options

  args.concat(["-f #{filename}"])

  run_cmd('mssql-scripter', args, 'dumping')
end

#structure_load(filename, _extra_flags) ⇒ Object



61
62
63
64
65
66
67
# File 'lib/arjdbc/tasks/mssql_database_tasks.rb', line 61

def structure_load(filename, _extra_flags)
  args = prepare_command_options

  args.concat(["-i #{filename}"])

  run_cmd('mssql-cli', args, 'loading')
end