capistrano-rails-databases 0.0.0
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.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +45 -0
- data/LICENSE.txt +21 -0
- data/README.md +37 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/capistrano-rails-databases.gemspec +38 -0
- data/lib/capistrano/migrate_all_dbs.rb +1 -0
- data/lib/capistrano/rails/migrate/all_dbs.rb +1 -0
- data/lib/capistrano/tasks/migrate/all_dbs.rake +80 -0
- data/lib/capistrano/tasks/migrate/set_rails_env.rake +9 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 53a7fc87af3961e14e0863300d5c1217cee880111eb8758c12f79e28aa578f23
|
4
|
+
data.tar.gz: 3fc5eb188ee6fdc6baab0722c41584cb92c617e6c8948e9355ef09bd3e1f8f81
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4d0617e6ce0c702330b71a76d1911d0d20baf3f5df2cf7e5a12348343f12f1eedc1cc4e702b74db12207e6846773581d02ced16f299deffc17c6b1d26674f69e
|
7
|
+
data.tar.gz: b715a26cab063f55efe43c7874400bf2ef7464f0a8a42e9cd2db2b363a226e1ac5314c1cc4361b50f6898bc7e9563d26e594f4906fb684d6a8e9cf69ef5bc8b4
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
capistrano-rails-databases (0.0.0)
|
5
|
+
capistrano-rails
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
airbrussh (1.3.0)
|
11
|
+
sshkit (>= 1.6.1, != 1.7.0)
|
12
|
+
capistrano (3.10.0)
|
13
|
+
airbrussh (>= 1.0.0)
|
14
|
+
i18n
|
15
|
+
rake (>= 10.0.0)
|
16
|
+
sshkit (>= 1.9.0)
|
17
|
+
capistrano-bundler (1.3.0)
|
18
|
+
capistrano (~> 3.1)
|
19
|
+
sshkit (~> 1.2)
|
20
|
+
capistrano-rails (1.3.1)
|
21
|
+
capistrano (~> 3.1)
|
22
|
+
capistrano-bundler (~> 1.1)
|
23
|
+
concurrent-ruby (1.0.5)
|
24
|
+
i18n (0.9.1)
|
25
|
+
concurrent-ruby (~> 1.0)
|
26
|
+
minitest (5.10.3)
|
27
|
+
net-scp (1.2.1)
|
28
|
+
net-ssh (>= 2.6.5)
|
29
|
+
net-ssh (4.2.0)
|
30
|
+
rake (10.5.0)
|
31
|
+
sshkit (1.15.1)
|
32
|
+
net-scp (>= 1.1.2)
|
33
|
+
net-ssh (>= 2.8.0)
|
34
|
+
|
35
|
+
PLATFORMS
|
36
|
+
ruby
|
37
|
+
|
38
|
+
DEPENDENCIES
|
39
|
+
bundler (~> 1.16.a)
|
40
|
+
capistrano-rails-databases!
|
41
|
+
minitest (~> 5.0)
|
42
|
+
rake (~> 10.0)
|
43
|
+
|
44
|
+
BUNDLED WITH
|
45
|
+
1.16.0
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 De gentiile carl
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Capistrano::Rails::Migrate:All_Dbs
|
2
|
+
|
3
|
+
It ables you to migrate your databases on all your ruby ENV
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'capistrano-rails-databases'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle server deploy:migrate_all_dbs
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install 'capistrano-rails-databases'
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
28
|
+
|
29
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/quimeo/capistrano-rails-databases.
|
34
|
+
|
35
|
+
## License
|
36
|
+
|
37
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "capistrano/rails/mdbs"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
#require "capistrano/rails/mdbs/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "capistrano-rails-databases"
|
7
|
+
spec.version = '0.0.0'
|
8
|
+
spec.authors = ["carl de gentile"]
|
9
|
+
spec.email = ["carl@quimeo.fr"]
|
10
|
+
|
11
|
+
spec.summary = %q{}
|
12
|
+
spec.description = %q{Add special task or migrate all databases}
|
13
|
+
spec.homepage = %q{https://github.com/quimeo/capistrano-rails-databases}
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
|
19
|
+
# if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
# else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against " \
|
23
|
+
# "public gem pushes."
|
24
|
+
# end
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
27
|
+
f.match(%r{^(test|spec|features)/})
|
28
|
+
end
|
29
|
+
spec.bindir = "exe"
|
30
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
31
|
+
spec.require_paths = ["lib"]
|
32
|
+
|
33
|
+
spec.add_development_dependency "bundler", "~> 1.16.a"
|
34
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
35
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
36
|
+
|
37
|
+
spec.add_dependency 'capistrano-rails'
|
38
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'capistrano/rails/migrate/all_dbs'
|
@@ -0,0 +1 @@
|
|
1
|
+
load File.expand_path("../../../tasks/migrate/all_dbs.rake", __FILE__)
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'byebug'
|
2
|
+
require 'yaml'
|
3
|
+
load File.expand_path("../set_rails_env.rake", __FILE__)
|
4
|
+
|
5
|
+
namespace :deploy do
|
6
|
+
|
7
|
+
def get_all_env host
|
8
|
+
yml_file = "#{fetch :deploy_to}/shared/config/database.yml"
|
9
|
+
# puts "get_all_env/yml_file\t(#{yml_file})"
|
10
|
+
|
11
|
+
cmd = "ssh #{host} \"cat #{yml_file}\""
|
12
|
+
# puts cmd
|
13
|
+
envs = YAML.load(`#{cmd}`)
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Runs rake db:migrate_all_dbs if migrations are set'
|
17
|
+
task :migrate_all_dbs => [:set_rails_env] do
|
18
|
+
on fetch(:migration_servers) do
|
19
|
+
conditionally_migrate = fetch(:conditionally_migrate)
|
20
|
+
info '[deploy:migrate_all_dbs] Checking changes in db' if conditionally_migrate
|
21
|
+
if conditionally_migrate && test(:diff, "-qr #{release_path}/db #{current_path}/db")
|
22
|
+
info '[deploy:migrate_all_dbs] Skip `deploy:migrate_all_dbs` (nothing changed in db)'
|
23
|
+
else
|
24
|
+
info '[deploy:migrate_all_dbs] Run `rake db:migrate_all_dbs`'
|
25
|
+
# NOTE: We access instance variable since the accessor was only added recently. Once capistrano-rails depends on rake 11+, we can revert the following line
|
26
|
+
invoke :'deploy:migrating_all_dbs' unless Rake::Task[:'deploy:migrating_all_dbs'].instance_variable_get(:@already_invoked)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'Runs rake db:migrate'
|
32
|
+
task migrating_all_dbs: [:set_rails_env] do
|
33
|
+
colors = SSHKit::Color.new($stderr)
|
34
|
+
on roles :all do |host|
|
35
|
+
info "Task migrating_all_dbs is invoked for #{host}"
|
36
|
+
envs = get_all_env host
|
37
|
+
envs.each do |rails_env|
|
38
|
+
on fetch(:migration_servers) do
|
39
|
+
# puts fetch(:migration_servers)
|
40
|
+
within release_path do
|
41
|
+
with rails_env: rails_env.first do
|
42
|
+
info colors.colorize("Migration for\t\t\t#{rails_env.first}", :cyan)
|
43
|
+
execute :rake, 'db:migrate'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
desc 'Runs rake db:rollback'
|
52
|
+
task rollback_all_dbs: [:set_rails_env] do
|
53
|
+
colors = SSHKit::Color.new($stderr)
|
54
|
+
on roles :all do |host|
|
55
|
+
info "Task rollback_all_dbs is invoked for #{host}"
|
56
|
+
envs = get_all_env host
|
57
|
+
envs.each do |rails_env|
|
58
|
+
on fetch(:migration_servers) do
|
59
|
+
# puts fetch(:migration_servers)
|
60
|
+
within release_path do
|
61
|
+
with rails_env: rails_env.first do
|
62
|
+
info colors.colorize("Migration for\t\t\t#{rails_env.first}", :cyan)
|
63
|
+
execute :rake, 'db:rollback'
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
after 'deploy:updated', 'deploy:migrate_all_dbs'
|
72
|
+
end
|
73
|
+
|
74
|
+
namespace :load do
|
75
|
+
task :defaults do
|
76
|
+
set :conditionally_migrate, fetch(:conditionally_migrate, false)
|
77
|
+
set :migration_role, fetch(:migration_role, :db)
|
78
|
+
set :migration_servers, -> { primary( fetch(:migration_role)) }
|
79
|
+
end
|
80
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-rails-databases
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- carl de gentile
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-11-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.16.a
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.16.a
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: capistrano-rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Add special task or migrate all databases
|
70
|
+
email:
|
71
|
+
- carl@quimeo.fr
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- capistrano-rails-databases.gemspec
|
86
|
+
- lib/capistrano/migrate_all_dbs.rb
|
87
|
+
- lib/capistrano/rails/migrate/all_dbs.rb
|
88
|
+
- lib/capistrano/tasks/migrate/all_dbs.rake
|
89
|
+
- lib/capistrano/tasks/migrate/set_rails_env.rake
|
90
|
+
homepage: https://github.com/quimeo/capistrano-rails-databases
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.7.2
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: ''
|
114
|
+
test_files: []
|