galera_cluster_migrations 0.0.1.alpha1
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 +24 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/galera_cluster_migrations.gemspec +25 -0
- data/lib/galera_cluster_migrations.rb +39 -0
- data/lib/galera_cluster_migrations/capistrano.rb +55 -0
- data/lib/galera_cluster_migrations/railtie.rb +10 -0
- data/lib/galera_cluster_migrations/version.rb +3 -0
- data/lib/tasks/galera_cluster_migrations.rake +11 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e24f85effe38b4e4fc180c833284be6fefab16d5
|
4
|
+
data.tar.gz: 216ac2decfb6691d8f78f6a55a0eba7e9158e275
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f784f267d056c4db43a3aede6245d94034761bf91234a6bbd118830ed6e2ec00da82bf6d0b6e5f5f97b60b9c622a70ae0a0ab8fdde66a1c97d5a79ce7daeaaf4
|
7
|
+
data.tar.gz: 5e76db6a96bf068af0529d4a0b3c2e4c0c1419f2f2d3d9fc7a9eaf06cd4860187a13e422f3a4a8aa98dcf1545afcbd4cafd9f3fd81ed333bcc85ff6724fab4eb
|
data/.gitignore
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
23
|
+
.ruby-version
|
24
|
+
.ruby-gemset
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Bryan Traywick
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# GaleraClusterMigrations
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'galera_cluster_migrations'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install galera_cluster_migrations
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( https://github.com/railsmachine/galera_cluster_migrations/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'galera_cluster_migrations/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "galera_cluster_migrations"
|
8
|
+
spec.version = GaleraClusterMigrations::VERSION
|
9
|
+
spec.authors = ["Bryan Traywick"]
|
10
|
+
spec.email = ["bryan@railsmachine.com"]
|
11
|
+
spec.summary = %q{RSU database migrations for MariaDB Galera Cluster.}
|
12
|
+
spec.description = %q{Rolling Schema Upgrade (RSU) database migrations for MariaDB Galera Cluster.}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "activesupport", ">= 3.0.0"
|
22
|
+
spec.add_runtime_dependency "activerecord", ">= 3.0.0"
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
24
|
+
spec.add_development_dependency "rake"
|
25
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require "galera_cluster_migrations/version"
|
2
|
+
require 'active_support/concern'
|
3
|
+
|
4
|
+
module GaleraClusterMigrations
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
require 'galera_cluster_migrations/railtie' if defined?(Rails)
|
8
|
+
|
9
|
+
included do
|
10
|
+
def set_db_to_rsu
|
11
|
+
say "Setting wsrep_OSU_method to RSU"
|
12
|
+
unless [:development, :test].include?(Rails.env)
|
13
|
+
execute "SET GLOBAL wsrep_OSU_method=RSU"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def with_rsu
|
18
|
+
unless [:development, :test].include?(Rails.env)
|
19
|
+
execute "SET GLOBAL wsrep_OSU_method=RSU"
|
20
|
+
execute "SET GLOBAL wsrep_desync=ON"
|
21
|
+
execute "SET wsrep_on=OFF"
|
22
|
+
end
|
23
|
+
|
24
|
+
yield
|
25
|
+
|
26
|
+
unless [:development, :test].include?(Rails.env)
|
27
|
+
execute "SET GLOBAL wsrep_desync=OFF"
|
28
|
+
execute "SET GLOBAL wsrep_OSU_method=TOI"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def set_db_to_toi
|
33
|
+
say "Setting wsrep_OSU_method to TOI"
|
34
|
+
unless [:development, :test].include?(Rails.env)
|
35
|
+
execute "SET GLOBAL wsrep_OSU_method=TOI"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
|
3
|
+
module GaleraClusterMigrations
|
4
|
+
class Capistrano
|
5
|
+
TASKS = [
|
6
|
+
'galera:migrate'
|
7
|
+
]
|
8
|
+
|
9
|
+
def self.load_into(capistrano_config)
|
10
|
+
capistrano_config.load do
|
11
|
+
|
12
|
+
before(Capistrano::TASKS) do
|
13
|
+
Config.load(self)
|
14
|
+
end
|
15
|
+
|
16
|
+
namespace :galera do
|
17
|
+
desc <<-DESC
|
18
|
+
Run the migrate rake task. By default, it runs this in most recently \
|
19
|
+
deployed version of the app. However, you can specify a different release \
|
20
|
+
via the migrate_target variable, which must be one of :latest (for the \
|
21
|
+
default behavior), or :current (for the release indicated by the \
|
22
|
+
`current' symlink). Strings will work for those values instead of symbols, \
|
23
|
+
too. You can also specify additional environment variables to pass to rake \
|
24
|
+
via the migrate_env variable. Finally, you can specify the full path to the \
|
25
|
+
rake executable by setting the rake variable. The defaults are:
|
26
|
+
|
27
|
+
set :rake, "rake"
|
28
|
+
set :rails_env, "production"
|
29
|
+
set :migrate_env, ""
|
30
|
+
set :migrate_target, :latest
|
31
|
+
DESC
|
32
|
+
task :migrate, :roles => :db do
|
33
|
+
rake = fetch(:rake, "rake")
|
34
|
+
rails_env = fetch(:rails_env, "production")
|
35
|
+
migrate_env = fetch(:migrate_env, "")
|
36
|
+
migrate_target = fetch(:migrate_target, :latest)
|
37
|
+
|
38
|
+
directory = case migrate_target.to_sym
|
39
|
+
when :current then current_path
|
40
|
+
when :latest then latest_release
|
41
|
+
else raise ArgumentError, "unknown migration target #{migrate_target.inspect}"
|
42
|
+
end
|
43
|
+
|
44
|
+
run "cd #{directory} && #{rake} RAILS_ENV=#{rails_env} #{migrate_env} galera:db:alter[db:migrate]"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
if Capistrano::Configuration.instance
|
54
|
+
GaleraClusterMigrations::Capistrano.load_into(Capistrano::Configuration.instance)
|
55
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
namespace :galera do
|
2
|
+
namespace :db do
|
3
|
+
desc "Alters the database settings for the specified task"
|
4
|
+
task :alter, [:task] => [:environment] do |t, args|
|
5
|
+
configuration = ActiveRecord::Base.configurations[Rails.env]
|
6
|
+
configuration['host'] = 'localhost'
|
7
|
+
ActiveRecord::Base.establish_connection(configuration)
|
8
|
+
Rake::Task[args.task].invoke
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: galera_cluster_migrations
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1.alpha1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bryan Traywick
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activerecord
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.0.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Rolling Schema Upgrade (RSU) database migrations for MariaDB Galera Cluster.
|
70
|
+
email:
|
71
|
+
- bryan@railsmachine.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE.txt
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- galera_cluster_migrations.gemspec
|
82
|
+
- lib/galera_cluster_migrations.rb
|
83
|
+
- lib/galera_cluster_migrations/capistrano.rb
|
84
|
+
- lib/galera_cluster_migrations/railtie.rb
|
85
|
+
- lib/galera_cluster_migrations/version.rb
|
86
|
+
- lib/tasks/galera_cluster_migrations.rake
|
87
|
+
homepage: ''
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - '>'
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 1.3.1
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.2.2
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: RSU database migrations for MariaDB Galera Cluster.
|
111
|
+
test_files: []
|