drush-deploy 1.0.1.beta5 → 1.0.1.beta6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
- version 1.0.1.beta5
1
+ version 1.0.1.beta6
2
2
 
3
3
  ## DESCRIPTION
4
4
 
5
5
  Provides capistrano deployment strategy for Drupal.
6
6
 
7
+ For documentation please checkout the [wiki](https://github.com/xforty/drush-deploy/wiki)
8
+
7
9
  ## REQUIREMENTS
8
10
 
9
11
  * Capistrano
@@ -19,3 +21,5 @@ On remote servers you must have
19
21
  ## USAGE
20
22
 
21
23
  # gem install drush-deploy
24
+ cd <Drupal root>
25
+ drush-deploy TARGET=<drush alias>
data/drush-deploy.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'drush-deploy'
3
- s.version = '1.0.1.beta5'
3
+ s.version = '1.0.1.beta6'
4
4
  s.summary = "Deployment strategy for Drupal using Drush"
5
5
  s.description = "Utilizes capistrano to allow for doing intellegent deployments of drupal projects."
6
6
  s.authors = ["Matt Edlefsen"]
@@ -16,6 +16,7 @@ module DrushDeploy
16
16
  def initialize(config)
17
17
  @config = config
18
18
  @seen_paths = {}
19
+ @db_status = {}
19
20
  end
20
21
 
21
22
  def method_missing(sym, *args, &block)
@@ -161,6 +162,21 @@ module DrushDeploy
161
162
  end
162
163
  end
163
164
 
165
+ def db_empty?(db = nil)
166
+ conf = config
167
+ conf[:database] = db if db
168
+ db = conf[:database]
169
+ if @db_status[db].nil?
170
+ logger.info "Fetching status of db #{conf[:database]}"
171
+ sql = %q{SELECT count(*) FROM information_schema.tables
172
+ WHERE table_schema = '%{database}' LIMIT 1} % conf
173
+ conf[:database] = 'information_schema'
174
+ res = remote_sql(sql, :config => conf, :capture => true)
175
+ @db_status[db] = res.split(/\n/)[1].to_i == 0
176
+ end
177
+ @db_status[db]
178
+ end
179
+
164
180
  def db_versions
165
181
  conf = config(:admin => true)
166
182
  logger.info "Getting list of databases versions"
@@ -181,13 +197,16 @@ module DrushDeploy
181
197
  def db_tables(db = nil)
182
198
  conf = config(:admin => true)
183
199
  conf[:database] = db if db
200
+ db = conf[:database]
184
201
  logger.info "Fetching table list of #{conf[:database]}"
185
202
  db_tables_query = %q{SELECT table_name FROM information_schema.tables
186
203
  WHERE table_schema = '%{database}'
187
204
  AND table_type = 'BASE TABLE'};
188
205
  sql = db_tables_query % conf
189
206
  conf[:database] = 'information_schema'
190
- remote_sql(sql, :config => conf, :capture => true).split(/\n/)[1..-1] || []
207
+ tables = remote_sql(sql, :config => conf, :capture => true).split(/\n/)[1..-1] || []
208
+ @db_status[db] = tables.size == 0
209
+ tables
191
210
  end
192
211
 
193
212
  def copy_database(from,to)
@@ -204,6 +223,7 @@ module DrushDeploy
204
223
  END
205
224
  end
206
225
  remote_sql(sql, :config => conf)
226
+ @db_status.delete(to)
207
227
  end
208
228
 
209
229
  def rename_database(from,to)
@@ -220,12 +240,14 @@ module DrushDeploy
220
240
  sql += "ALTER TABLE #{from} RENAME TO #{to};"
221
241
  end
222
242
  remote_sql(sql, :config => conf)
243
+ @db_status.delete(to)
223
244
  end
224
245
 
225
246
  def drop_database(db)
226
247
  logger.info "Dropping database #{db}"
227
248
  conf = config(:database => db, :admin => true)
228
249
  remote_sql("DROP DATABASE #{db};", :config => conf)
250
+ @db_status[db] = false
229
251
  end
230
252
 
231
253
  # Should split these out
@@ -1,6 +1,5 @@
1
1
  require 'drush_deploy/database'
2
2
 
3
- drupal_db = DrushDeploy::Database.new(self)
4
3
 
5
4
  after "deploy:update_code", "db:drupal:update_settings"
6
5
  after "deploy:update_code", "db:version:create"
@@ -19,7 +18,9 @@ namespace :db do
19
18
  namespace :drupal do
20
19
  desc "Run update scripts for Drupal"
21
20
  task :update, :roles => :web do
22
- drupal_db.updatedb
21
+ unless drupal_db.db_empty?
22
+ drupal_db.updatedb
23
+ end
23
24
  end
24
25
 
25
26
  desc "Determine database settings"
@@ -69,7 +70,7 @@ namespace :db do
69
70
  if releases.size > 1
70
71
  current = drupal_db.config[:database]
71
72
  backup = "#{current}_#{releases[-2]}"
72
- unless drupal_db.db_exists? backup
73
+ unless drupal_db.db_empty? or drupal_db.db_exists? backup
73
74
  on_rollback do
74
75
  drupal_db.drop_database backup
75
76
  end
@@ -15,7 +15,9 @@ namespace :drupal do
15
15
 
16
16
  desc "Clear all Drupal cache"
17
17
  task :clearcache, :roles => :web do
18
- run "#{drush_bin} -r #{current_path} cache-clear all"
18
+ unless drupal_db.db_empty?
19
+ run "#{drush_bin} -r #{latest_release} cache-clear all"
20
+ end
19
21
  end
20
22
 
21
23
  desc "Protect system files"
@@ -37,6 +37,7 @@ set :configured, false
37
37
 
38
38
 
39
39
  set :drush_cap, DrushDeploy::Capistrano.new
40
+ set :drupal_db, DrushDeploy::Database.new(self)
40
41
 
41
42
  if exists? :target
42
43
  target.split(/ *, */).each {|t| drush_cap.load_target t }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: drush-deploy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1.beta5
4
+ version: 1.0.1.beta6
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-05-09 00:00:00.000000000 Z
12
+ date: 2012-05-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
16
- requirement: &8576060 !ruby/object:Gem::Requirement
16
+ requirement: &10561000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *8576060
24
+ version_requirements: *10561000
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: railsless-deploy
27
- requirement: &8575340 !ruby/object:Gem::Requirement
27
+ requirement: &10560460 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *8575340
35
+ version_requirements: *10560460
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: php_serialize
38
- requirement: &8574600 !ruby/object:Gem::Requirement
38
+ requirement: &10559980 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '1.2'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *8574600
46
+ version_requirements: *10559980
47
47
  description: Utilizes capistrano to allow for doing intellegent deployments of drupal
48
48
  projects.
49
49
  email: matt@xforty.com