ninja-deploy 2.1.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/lib/ninja_deploy/recipes/database.rb +32 -6
- data/lib/ninja_deploy/version.rb +1 -1
- metadata +5 -5
data/README.rdoc
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
Capistrano::Configuration.instance( :must_exist ).load do
|
2
|
+
|
2
3
|
namespace :db do
|
4
|
+
|
3
5
|
namespace :dump do
|
6
|
+
|
4
7
|
desc 'Dump a remote database, fetch the dump file to local and then load it to the development database'
|
5
8
|
task :to_local_db, :roles => :db, :only => { :primary => true } do
|
6
9
|
local_file_full_path = dump_database_to_local
|
@@ -36,7 +39,8 @@ Capistrano::Configuration.instance( :must_exist ).load do
|
|
36
39
|
ssh.exec! "rm #{staging_file_full_path}"
|
37
40
|
end
|
38
41
|
end
|
39
|
-
|
42
|
+
|
43
|
+
end # namespace :dump
|
40
44
|
|
41
45
|
def dump_database_to_local
|
42
46
|
prepare_for_database_dump
|
@@ -54,7 +58,7 @@ Capistrano::Configuration.instance( :must_exist ).load do
|
|
54
58
|
|
55
59
|
local_file_full_path
|
56
60
|
end
|
57
|
-
|
61
|
+
|
58
62
|
def dump_database_to_staging
|
59
63
|
prepare_for_database_dump
|
60
64
|
|
@@ -91,7 +95,23 @@ Capistrano::Configuration.instance( :must_exist ).load do
|
|
91
95
|
|
92
96
|
def dump_database( password )
|
93
97
|
puts "*** Dumping #{environment_database} database..."
|
94
|
-
run
|
98
|
+
run dump_database_cmd( password )
|
99
|
+
end
|
100
|
+
|
101
|
+
def dump_database_cmd( password )
|
102
|
+
"mysqldump --add-drop-table -u #{environment_db_user} -h #{environment_db_host.gsub('-master', '-replica')} -p#{password} #{environment_database} #{tables_to_dump} | bzip2 -c > #{dump_file_bz2_full_path}"
|
103
|
+
end
|
104
|
+
|
105
|
+
def tables_to_dump
|
106
|
+
require 'rubygems'
|
107
|
+
require 'active_record'
|
108
|
+
except = ENV['EXCEPT']
|
109
|
+
except = except.nil? ? nil : Array( except.split( ',' ) )
|
110
|
+
ActiveRecord::Base.establish_connection( local_database_config_hash['development'] )
|
111
|
+
|
112
|
+
except.nil? ?
|
113
|
+
nil :
|
114
|
+
(ActiveRecord::Base.connection.tables - except).join( ' ' )
|
95
115
|
end
|
96
116
|
|
97
117
|
def remove_dump_file
|
@@ -99,12 +119,16 @@ Capistrano::Configuration.instance( :must_exist ).load do
|
|
99
119
|
run "rm #{dump_file_bz2_full_path}"
|
100
120
|
end
|
101
121
|
|
122
|
+
def local_database_config_hash
|
123
|
+
YAML::load_file( 'config/database.yml' )
|
124
|
+
end
|
125
|
+
|
102
126
|
# Reads the database credentials from the local config/database.yml file
|
103
127
|
# +db+ the name of the environment to get the credentials for
|
104
128
|
# Returns username, password, database
|
105
129
|
#
|
106
130
|
def database_config( db )
|
107
|
-
database =
|
131
|
+
database = local_database_config_hash
|
108
132
|
return database["#{db}"]['username'], database["#{db}"]['password'], database["#{db}"]['database'], database["#{db}"]['host']
|
109
133
|
end
|
110
134
|
|
@@ -117,7 +141,7 @@ Capistrano::Configuration.instance( :must_exist ).load do
|
|
117
141
|
database = YAML::load( remote_config )
|
118
142
|
return database["#{db}"]['username'], database["#{db}"]['password'], database["#{db}"]['database'], database["#{db}"]['host']
|
119
143
|
end
|
120
|
-
|
144
|
+
|
121
145
|
def host_database_config( host, user, db )
|
122
146
|
remote_config = nil
|
123
147
|
|
@@ -129,5 +153,7 @@ Capistrano::Configuration.instance( :must_exist ).load do
|
|
129
153
|
|
130
154
|
return database["#{db}"]['username'], database["#{db}"]['password'], database["#{db}"]['database'], database["#{db}"]['host']
|
131
155
|
end
|
156
|
+
|
132
157
|
end
|
133
|
-
|
158
|
+
|
159
|
+
end
|
data/lib/ninja_deploy/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ninja-deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 5
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
+
- 2
|
8
9
|
- 1
|
9
|
-
|
10
|
-
version: 2.1.0
|
10
|
+
version: 2.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jason Harrelson
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2012-
|
19
|
+
date: 2012-11-29 00:00:00 Z
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
22
|
name: cape
|
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
121
|
requirements: []
|
122
122
|
|
123
123
|
rubyforge_project:
|
124
|
-
rubygems_version: 1.8.
|
124
|
+
rubygems_version: 1.8.10
|
125
125
|
signing_key:
|
126
126
|
specification_version: 3
|
127
127
|
summary: Common shared deployment recipes for your pleasure.
|