Class: Heroku::Command::Db

Inherits:
BaseWithApp show all
Defined in:
lib/heroku/commands/db.rb

Instance Attribute Summary

Attributes inherited from BaseWithApp

#app

Attributes inherited from Base

#args, #autodetected_app

Instance Method Summary collapse

Methods inherited from Base

#app_urls, #ask, #display, #error, #escape, #extract_app, #extract_app_in_dir, #extract_option, #format_date, #git_remotes, #git_url, #heroku, #shell, #web_url

Methods included from Helpers

#home_directory, #running_on_a_mac?, #running_on_windows?

Instance Method Details

#pullObject

Raises:



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/heroku/commands/db.rb', line 3

def pull
	database_url = args.shift.strip rescue ''
	if database_url == ''
		database_url = parse_database_yml
		display "Auto-detected local database: #{database_url}" if database_url != ''
	end
	raise(CommandFailed, "Invalid database url") if database_url == ''

	taps_client(database_url) do |client|
		client.cmd_receive
	end
end

#pushObject



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

def push
	display("Warning: All data in the the remote database will be overwritten and will not be recoverable.")
	display("Are you sure you wish to push to the remote database? (y/n)? ", false)
	if ask.downcase == 'y'
			database_url = args.shift.strip rescue ''
			if database_url == ''
				database_url = parse_database_yml
				display "Auto-detected local database: #{database_url}" if database_url != ''
			end
			raise(CommandFailed, "Invalid database url") if database_url == ''

			taps_client(database_url) do |client|
				client.cmd_send
			end
	end
end

#resetObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/heroku/commands/db.rb', line 33

def reset
	if !autodetected_app
		info = heroku.info(app)
		url  = info[:domain_name] || "http://#{info[:name]}.#{heroku.host}/"

		display("Warning: All data in the '#{app}' database will be erased and will not be recoverable.")
		display("Are you sure you wish to continue? (y/n)? ", false)
		if ask.downcase == 'y'
			heroku.database_reset(app)
			display "Database reset for '#{app}' (#{url})"
		end
	else
		display "Set the app you want to reset the database for by adding --app <app name> to this command"
	end
end