capistrano-detect-migrations 0.5

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/LICENSE ADDED
@@ -0,0 +1,26 @@
1
+ Copyright (c) 2012 MyDrive Solutions Limited, All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions
5
+ are met:
6
+
7
+ * Redistributions of source code must retain the above copyright
8
+ notice, this list of conditions and the following disclaimer.
9
+
10
+ * Redistributions in binary form must reproduce the above
11
+ copyright notice, this list of conditions and the following
12
+ disclaimer in the documentation and/or other materials provided
13
+ with the distribution.
14
+
15
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18
+ FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19
+ COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
25
+ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
+ POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,51 @@
1
+ Capistrano Detect Migrations
2
+ ============================
3
+ This plugin to Capistrano leverages the capistrano-detect-migrations plugin
4
+ to have Git identify Rails migrations before you deploy code to any
5
+ remote systems. This is handy in an environment where you deploy
6
+ often and want to release the newest code but only if it's not
7
+ complicated by running migrations. You may also just want a list
8
+ of migrations that will need to be run before deploying and this
9
+ plugin makes that easy.
10
+
11
+ What It Does
12
+ ------------
13
+ It makes it automatic to detect pending migrations in any environment.
14
+ You won't be surprised by deploying code that doesn't work until
15
+ the migrations have been run. If I were to issue the command:
16
+
17
+ `cap production deploy`
18
+
19
+ This would compare the current changes with the most recent deployment
20
+ tag for the environment (here: production) and look for any migrations
21
+ that have appeared or changed in the code since the last run. You
22
+ are then presented with a prompt allowing you to cancel the deployment
23
+ after reviewing the list of migrations.
24
+
25
+ Usage
26
+ -----
27
+ capistrano-detect-migrations is available on
28
+ [rubygems.org](https://rubygems.org/gems/capistrano-detect-migrations).
29
+ You can install it from there with:
30
+
31
+ `gem install capistrano-detect-migrations`
32
+
33
+ If you use Bundler, be sure to add the gem to your Gemfile.
34
+ In your Capistrano `config/deploy.rb` you should add:
35
+
36
+ `require 'capistrano-detect-migrations'`
37
+
38
+ This will create one task that hooks into one of the tasks installed
39
+ by the capistrano-deploytags gem. You can always review tasks that
40
+ have been added by running `cap -T` from your application directory.
41
+
42
+ Credits
43
+ -------
44
+ This software was written by [Karl Matthias](https://github.com/relistan)
45
+ with help from [Gavin Heavyside](https://github.com/hgavin) and the
46
+ support of [MyDrive Solutions Limited](http://mydrivesolutions.com).
47
+
48
+ License
49
+ -------
50
+ This plugin is released under the BSD two clause license which is
51
+ available in both the Ruby Gem and the source repository.
@@ -0,0 +1,3 @@
1
+ Dir[File.join(File.dirname(__FILE__), 'capistrano', '*')].each do |file|
2
+ require file
3
+ end
@@ -0,0 +1,47 @@
1
+ require 'capistrano-deploytags'
2
+
3
+ module Capistrano
4
+ module DetectMigrations
5
+
6
+ def pending_migrations?
7
+ !(`git diff --shortstat #{cdt.last_git_tag_for(stage)} #{branch} db/migrate`.strip.empty?)
8
+ end
9
+
10
+ def show_pending_migrations
11
+ cdt.safe_run 'git', 'diff', '--summary', '--color', cdt.last_git_tag_for(stage), branch, 'db/migrate'
12
+ end
13
+
14
+ def approved?
15
+ $stdin.gets.strip == 'Y'
16
+ end
17
+
18
+ def self.load_into(configuration)
19
+ configuration.load do
20
+ after 'git:prepare_tree', 'git:detection_migrations'
21
+
22
+ desc 'check for pending Rails migrations with git'
23
+ namespace :git do
24
+ task :detect_migrations do
25
+ cdt.validate_git_vars
26
+ if cdm.pending_migrations?
27
+ logger.log Logger::IMPORTANT, "Pending migrations!!!"
28
+ cdm.show_pending_migrations
29
+
30
+ $stdout.puts "Do you want to continue deployment? (Y/N)"
31
+ unless cdm.approved?
32
+ logger.log Logger::IMPORTANT, "Aborting deployment!"
33
+ raise 'aborted deployment'
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ Capistrano.plugin :cdm, Capistrano::DetectMigrations
44
+
45
+ if Capistrano::Configuration.instance
46
+ Capistrano::DetectMigrations.load_into(Capistrano::Configuration.instance(:must_exist))
47
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-detect-migrations
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.5'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Karl Matthias
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capistrano
16
+ requirement: &70144143571400 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70144143571400
25
+ - !ruby/object:Gem::Dependency
26
+ name: capistrano-ext
27
+ requirement: &70144143570540 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70144143570540
36
+ - !ruby/object:Gem::Dependency
37
+ name: capistrano-deploytags
38
+ requirement: &70144143569840 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70144143569840
47
+ description: ! ' Capistrano Detect Migrations lets you detect pending Rails migrations
48
+ before you deploy to any remote hosts. It leverages Git tagging to determine changes
49
+ that have happened since the last deployment. At deployment time you can choose
50
+ to continue to deploy or not after being presented with a list of pending migrations.
51
+
52
+ '
53
+ email: relistan@gmail.com
54
+ executables: []
55
+ extensions: []
56
+ extra_rdoc_files: []
57
+ files:
58
+ - lib/capistrano/detect_migrations.rb
59
+ - lib/capistrano-detect-migrations.rb
60
+ - README.md
61
+ - LICENSE
62
+ homepage: http://github.com/mydrive/capistrano-detect-migrations
63
+ licenses: []
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ! '>='
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 1.8.11
83
+ signing_key:
84
+ specification_version: 3
85
+ summary: Detect pending Rails migrations with Git before you deploy.
86
+ test_files: []