Class: FastSchemaDumper::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/fast_schema_dumper/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.runObject



11
12
13
# File 'lib/fast_schema_dumper/cli.rb', line 11

def self.run(...)
  new.run(...)
end

Instance Method Details

#run(_argv) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fast_schema_dumper/cli.rb', line 15

def run(_argv)
  env = ENV['RAILS_ENV'] || 'development'

  database_yml_path = File.join(Dir.pwd, 'config', 'database.yml')
  database_yml = Psych.safe_load(ERB.new(File.read(database_yml_path)).result, aliases: true)
  config = database_yml[env]
  # Override pool size to 1 for faster startup
  config['pool'] = 1

  # Prepare the ActiveRecord connection configuration
  hash_config = ActiveRecord::DatabaseConfigurations::HashConfig.new(env, 'primary', config)
  ActiveRecord::Base.establish_connection(hash_config)

  SchemaDumper.dump

  0
end