Module: ShippingBackupClient::Client::DBConfig

Defined in:
lib/shipping_backup_client/db/shipping_backup_db.rb

Constant Summary collapse

DB_DEFAULTS =
{
    'adapter'   => 'mysql2',
    'reconnect' => true,
    'pool'      => 50
}

Class Method Summary collapse

Class Method Details

.connect_shipping_backup_db(mysql_config) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/shipping_backup_client/db/shipping_backup_db.rb', line 24

def self.connect_shipping_backup_db(mysql_config)
  # Setup our logger
  ActiveRecord::Base.logger = $logger

  # Include Active Record class name as root for JSON serialized output.
  ActiveRecord::Base.include_root_in_json = false

  # Store the full class name (including module namespace) in STI type column.
  ActiveRecord::Base.store_full_sti_class = true

  # Use ISO 8601 format for JSON serialized times and dates.
  ActiveSupport.use_standard_json_time_format = true

  # Don't escape HTML entities in JSON, leave that for the #json_escape helper.
  # if you're including raw json in an HTML page.
  ActiveSupport.escape_html_entities_in_json = false

  # Now we can establish connection with our db
  $logger.info("connecting to shipping_backup db using config : #{DB_DEFAULTS.merge(mysql_config).merge({'password' => '*******'})}") rescue nil
  ShipmentDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
  CustomerDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
  ShippingLiteShipmentDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
  ShipmentSellerMappingDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
  SellerDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
  ReturnSellerDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
  ShipmentReturnSellerMappingsDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
  PostalAddressDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
  ElectronicAddressDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
  TelecomNumberDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
  ShipmentStatusHistoryDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
  ShipmentScanAuditDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
  ShipmentNoteDAO.establish_connection(DB_DEFAULTS.merge(mysql_config))
end