Class: Database::Local
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #dump ⇒ Object
-
#initialize(cap_instance) ⇒ Local
constructor
A new instance of Local.
-
#load(file, cleanup) ⇒ Object
cleanup = true removes the mysqldump file after loading, false leaves it in db/.
- #upload ⇒ Object
Methods inherited from Base
#credentials, #database, #mysql?
Constructor Details
#initialize(cap_instance) ⇒ Local
Returns a new instance of Local.
59 60 61 62 |
# File 'lib/mysql.rb', line 59 def initialize(cap_instance) super(cap_instance) @config = YAML.load_file(File.join('config', 'database.yml'))[@cap.local_rails_env] end |
Instance Method Details
#dump ⇒ Object
71 72 73 74 |
# File 'lib/mysql.rb', line 71 def dump system "#{dump_cmd} | bzip2 - - > #{output_file}" self end |
#load(file, cleanup) ⇒ Object
cleanup = true removes the mysqldump file after loading, false leaves it in db/
65 66 67 68 69 |
# File 'lib/mysql.rb', line 65 def load(file, cleanup) unzip_file = File.join(File.dirname(file), File.basename(file, '.bz2')) system("bunzip2 -f #{file} && #{rake} db:drop db:create && #{import_cmd(unzip_file)} && #{rake} db:migrate") File.unlink(unzip_file) if cleanup end |
#upload ⇒ Object
76 77 78 79 |
# File 'lib/mysql.rb', line 76 def upload remote_file = "#{@cap.current_path}/#{output_file}" @cap.upload output_file, remote_file end |