heroku-db-sync 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,5 @@
1
1
  require 'heroku-db-sync/task_helper'
2
+ require 'heroku-db-sync/deploy_and_migrate'
2
3
 
3
4
  module HerokuDbSync
4
5
 
@@ -0,0 +1,23 @@
1
+ module HerokuDbSync
2
+ module Deploy
3
+
4
+ def self.deploy arguments
5
+ Bundler.with_clean_env do
6
+ remote = arguments[:remote]
7
+ raise "must specify git remote. 'production' 'staging' or 'heroku'" unless remote
8
+ branch = arguments[:localbranch] || 'master'
9
+
10
+ execute "git push #{remote} #{branch}:master"
11
+ execute "heroku run rake db:migrate --remote #{remote}"
12
+ execute "heroku restart --remote #{remote}"
13
+ puts "\nSUCCESS. Go to your web site for a paranoid sanity check.\nPop a beer\n"
14
+ end
15
+ end
16
+
17
+ def self.execute(cmd)
18
+ puts "===================================================\nExecuting: #{cmd}\n==================================================="
19
+ system(cmd) || raise("\n FAILED FAILED FAILED FAILED \n handle manually!\n Server may be down. Don't panic, remember your towel\n\n========")
20
+ end
21
+
22
+ end
23
+ end
@@ -1,5 +1,6 @@
1
1
 
2
2
  module HerokuDbSync
3
+
3
4
  module TaskHelper
4
5
  def self.perform_sync arguments
5
6
  Bundler.with_clean_env do
@@ -1,3 +1,3 @@
1
1
  module HerokuDbSync
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,7 +1,7 @@
1
1
 
2
- namespace :db do
2
+ namespace :heroku do
3
3
  namespace :sync do
4
- namespace :heroku do
4
+ namespace :db do
5
5
  desc 'sync local DB with heroku. set [from_remote] to pull from other than production'
6
6
  task :local, [:from_remote, :host, :database, :username] => :environment do | task, arguments |
7
7
  HerokuDbSync::TaskHelper.perform_sync arguments.to_hash.merge({to_remote: nil})
@@ -0,0 +1,8 @@
1
+ namespace :heroku do
2
+ namespace :sync do
3
+ desc "deploy to remote heroku deployment branch (git remote -v), migrate and restart"
4
+ task :deploy_migrate, [:remote, :localbranch] do |task, arguments|
5
+ HerokuDbSync::Deploy.deploy arguments
6
+ end
7
+ end
8
+ end
@@ -7,3 +7,12 @@ Connecting to database specified by database.yml
7
7
  Connecting to database specified by database.yml
8
8
   (0.3ms) begin transaction
9
9
   (0.0ms) rollback transaction
10
+ Connecting to database specified by database.yml
11
+  (4.4ms) begin transaction
12
+  (0.1ms) rollback transaction
13
+ Connecting to database specified by database.yml
14
+  (0.3ms) begin transaction
15
+  (0.0ms) rollback transaction
16
+ Connecting to database specified by database.yml
17
+  (0.3ms) begin transaction
18
+  (0.0ms) rollback transaction
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku-db-sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-18 00:00:00.000000000 Z
12
+ date: 2013-12-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -50,10 +50,12 @@ executables: []
50
50
  extensions: []
51
51
  extra_rdoc_files: []
52
52
  files:
53
+ - lib/heroku-db-sync/deploy_and_migrate.rb
53
54
  - lib/heroku-db-sync/task_helper.rb
54
55
  - lib/heroku-db-sync/version.rb
55
56
  - lib/heroku-db-sync.rb
56
- - lib/tasks/heroku-db-sync_tasks.rake
57
+ - lib/tasks/heroku_sync_db_tasks.rake
58
+ - lib/tasks/heroku_sync_deploy.rake
57
59
  - MIT-LICENSE
58
60
  - Rakefile
59
61
  - README.md