Class: Karo::Db

Inherits:
Thor
  • Object
show all
Includes:
Common
Defined in:
lib/karo/db.rb

Instance Method Summary collapse

Methods included from Common

#branch_exists?, #checkout_branch, #create_and_checkout_branch, #create_branch, #current_branch, #git_repo, #make_command, #run_it

Instance Method Details

#consoleObject



38
39
40
41
42
43
44
45
46
47
48
# File 'lib/karo/db.rb', line 38

def console
  configuration = Config.load_configuration(options)

  path = File.join(configuration["path"], "current")
  ssh  = "ssh #{configuration["user"]}@#{configuration["host"]}"
  ssh << " -t" if options[:tty]

  command  = "cd #{path} && $SHELL --login -c \"bundle exec rails dbconsole -p\""

  run_it "#{ssh} '#{command}'", options[:verbose]
end

#pullObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/karo/db.rb', line 12

def pull
  @configuration = Config.load_configuration(options)

   local_db_config  = load_local_db_config
   server_db_config = load_server_db_config

   drop_and_create_local_database(local_db_config)

   sync_server_to_local_database(server_db_config, local_db_config)

   if options[:migrate]
     say "Running rake db:migrations", :green
     run_it "bundle exec rake db:migrate", options[:verbose]
   end

   say "Database sync complete", :green
end

#pushObject



31
32
33
# File 'lib/karo/db.rb', line 31

def push
   say "Pending Implementation...", :yellow
end