bird_migration 0.1.2
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/MIT-LICENSE +20 -0
- data/README.md +55 -0
- data/Rakefile +27 -0
- data/lib/bird_migration.rb +5 -0
- data/lib/bird_migration/railtie.rb +7 -0
- data/lib/bird_migration/version.rb +3 -0
- data/lib/tasks/bird_migration_tasks.rake +29 -0
- metadata +85 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: abaee9dfc5601d515e515ad62fa984df9c73c7b491f86b6b73d655030c9a637d
|
4
|
+
data.tar.gz: 6dc6a996d3916bd4cfdbe1b30fd31a67952f6bf61815a757a64ab5bae0c9afdb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0e15b9788b01d32ec31972f5e4e7d43e69d7d0102db9b49c593084c51e6edbcaf0acafd709b26cfbc6652e3cf57702d1053ac04d12e3573b107af8fbc1d79fc3
|
7
|
+
data.tar.gz: 23c37058fa26cbde066b796e3d31fe47b7677fa7c77a00d47c6158db416240e5d28b79421fdd3490754b79a75cf9a11915da34aa856e9b04519ddd157f8899d2
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2018 rafael
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# BirdMigration
|
2
|
+
Let's assume you have 3 pending migrations with no order.
|
3
|
+
|
4
|
+
Status Migration ID Migration Name
|
5
|
+
--------------------------------------------------
|
6
|
+
up 20181029224028 Create users
|
7
|
+
down 20181029224048 Create add surname to users
|
8
|
+
up 20181029224059 Create posts
|
9
|
+
up 20181029224112 Create test los
|
10
|
+
down 20181029224146 Create lalas
|
11
|
+
down 20181029224451 Lololo
|
12
|
+
|
13
|
+
And some of them (let it be '20181029224451 Lololo') is broken.
|
14
|
+
And you are going to deploy that code somewhere.
|
15
|
+
So if you simply run `rake db:migrate` you will have on the server
|
16
|
+
two passed migrations and an error.
|
17
|
+
|
18
|
+
Status Migration ID Migration Name
|
19
|
+
--------------------------------------------------
|
20
|
+
up 20181029224028 Create users
|
21
|
+
up 20181029224048 Create add surname to users
|
22
|
+
up 20181029224059 Create posts
|
23
|
+
up 20181029224112 Create test los
|
24
|
+
up 20181029224146 Create lalas
|
25
|
+
down 20181029224451 Lololo
|
26
|
+
|
27
|
+
So state was not reverted to the same what was before `rake db:migrate` state.
|
28
|
+
|
29
|
+
gem 'birds_migrations' will give you ability to do "all or nothing" migrations.
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
`rake birds:migrate`
|
33
|
+
|
34
|
+
## Installation
|
35
|
+
Add this line to your application's Gemfile:
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
gem 'bird_migration'
|
39
|
+
```
|
40
|
+
|
41
|
+
And then execute:
|
42
|
+
```bash
|
43
|
+
$ bundle
|
44
|
+
```
|
45
|
+
|
46
|
+
Or install it yourself as:
|
47
|
+
```bash
|
48
|
+
$ gem install bird_migration
|
49
|
+
```
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
Contribution directions go here.
|
53
|
+
|
54
|
+
## License
|
55
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'BirdMigration'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.md')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
require 'bundler/gem_tasks'
|
18
|
+
|
19
|
+
require 'rake/testtask'
|
20
|
+
|
21
|
+
Rake::TestTask.new(:test) do |t|
|
22
|
+
t.libs << 'test'
|
23
|
+
t.pattern = 'test/**/*_test.rb'
|
24
|
+
t.verbose = false
|
25
|
+
end
|
26
|
+
|
27
|
+
task default: :test
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# desc "Explaining what the task does"
|
2
|
+
# task :bird_migration do
|
3
|
+
# # Task goes here
|
4
|
+
# end
|
5
|
+
|
6
|
+
namespace :birds do
|
7
|
+
task migrate: :environment do
|
8
|
+
migration_context = ActiveRecord::Base.connection.migration_context
|
9
|
+
|
10
|
+
passed_migration_versions = migration_context.get_all_versions
|
11
|
+
|
12
|
+
pending_migratios = migration_context.migrations.select do |migration|
|
13
|
+
passed_migration_versions.exclude?(migration.version)
|
14
|
+
end
|
15
|
+
|
16
|
+
begin
|
17
|
+
ActiveRecord::Migrator.new(:up, pending_migratios).migrate
|
18
|
+
rescue => e
|
19
|
+
|
20
|
+
puts "Oops, something went wrong! Don't worry, all the changes will be reverted!!!"
|
21
|
+
|
22
|
+
pending_migratios.reverse_each do |migration|
|
23
|
+
ActiveRecord::Migrator.new(:down, [migration]).migrate
|
24
|
+
end
|
25
|
+
|
26
|
+
raise(e)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bird_migration
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- rafael
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-01-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.2'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 5.2.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '5.2'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 5.2.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: sqlite3
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
description: Description of BirdMigration.
|
48
|
+
email:
|
49
|
+
- skcc321@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- MIT-LICENSE
|
55
|
+
- README.md
|
56
|
+
- Rakefile
|
57
|
+
- lib/bird_migration.rb
|
58
|
+
- lib/bird_migration/railtie.rb
|
59
|
+
- lib/bird_migration/version.rb
|
60
|
+
- lib/tasks/bird_migration_tasks.rake
|
61
|
+
homepage: http://github.com
|
62
|
+
licenses:
|
63
|
+
- MIT
|
64
|
+
metadata: {}
|
65
|
+
post_install_message:
|
66
|
+
rdoc_options: []
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
requirements: []
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 2.7.6
|
82
|
+
signing_key:
|
83
|
+
specification_version: 4
|
84
|
+
summary: Summary of BirdMigration.
|
85
|
+
test_files: []
|