db_patch 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +2 -0
- data/Rakefile +32 -0
- data/lib/db_patch/migration.rb +19 -0
- data/lib/db_patch/patch_version.rb +4 -0
- data/lib/db_patch/railtie.rb +12 -0
- data/lib/db_patch/version.rb +3 -0
- data/lib/db_patch.rb +3 -0
- data/lib/tasks/db_patch_tasks.rake +68 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 574c88472862d4a828ca55feb1b037cc00784834
|
4
|
+
data.tar.gz: 6e2ecc460b59a842ade2b965cdcb4167041e8100
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 190cf6515397883790e7a8356bda18d9356f359739a3d5015e93cb19e494073bdd15d95676b6b81573386350cedd5f8f25dc4f09fc2c0ae0219e76c3d5a6a79a
|
7
|
+
data.tar.gz: b24613ad9ee14fe45537adc7bb9f45c800639d25d4e5eb0776b528abc2ad4914b4e91bd2930d75a58b0773b0f76c23c17e0dc53a49d70268056724be223d822b
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 YOURNAME
|
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
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
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 = 'DbPatch'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
Bundler::GemHelper.install_tasks
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
|
24
|
+
Rake::TestTask.new(:test) do |t|
|
25
|
+
t.libs << 'lib'
|
26
|
+
t.libs << 'test'
|
27
|
+
t.pattern = 'test/**/*_test.rb'
|
28
|
+
t.verbose = false
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
task default: :test
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module DbPatch
|
2
|
+
module Migration
|
3
|
+
|
4
|
+
class CreatePatchVersions < ActiveRecord::Migration
|
5
|
+
def self.up
|
6
|
+
create_table :patch_versions do |t|
|
7
|
+
t.string :version
|
8
|
+
end
|
9
|
+
|
10
|
+
add_index :patch_versions, :version, :unique => true
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :patch_versions
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/lib/db_patch.rb
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
require "active_record"
|
2
|
+
require "db_patch/migration"
|
3
|
+
require "db_patch/patch_version"
|
4
|
+
|
5
|
+
|
6
|
+
namespace :db do
|
7
|
+
namespace :patch do
|
8
|
+
|
9
|
+
desc "initialize database"
|
10
|
+
task :init => :environment do
|
11
|
+
DbPatch::Migration::CreatePatchVersions.new.up
|
12
|
+
Dir.mkdir patch_root
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
desc "clear database"
|
17
|
+
task :clear => :environment do
|
18
|
+
DbPatch::Migration::CreatePatchVersions.down
|
19
|
+
FileUtils.rm_rf patch_root
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
desc "create new patch file"
|
24
|
+
task :new => :environment do
|
25
|
+
patch_name = "#{patch_root}/#{Time.now.strftime("%Y%m%d%H%M%S")}.rb"
|
26
|
+
File.open(patch_name, "w").close
|
27
|
+
p patch_name
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
desc "execute path"
|
32
|
+
task :execute => :environment do
|
33
|
+
patches = Dir.glob("#{patch_root}/*.rb")
|
34
|
+
patches.each do |patch|
|
35
|
+
basename = File.basename(patch, ".rb")
|
36
|
+
require patch
|
37
|
+
|
38
|
+
if DbPatch::PatchVersion.find_by(version: basename).nil?
|
39
|
+
DbPatch::PatchVersion.create!(
|
40
|
+
version: basename
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
44
|
+
p "#{basename} executed."
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def patch_root
|
51
|
+
"#{Rails.root}/db/patch"
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
class PatchVersion < ActiveRecord::Migration
|
56
|
+
def self.up
|
57
|
+
create_table :patch_versions do |t|
|
58
|
+
t.string :version
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.down
|
63
|
+
drop_table :patch_versions
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: db_patch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Yuto Ogi
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-04 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: 4.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: 4.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: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Manage tool for ruby script which executed to DB only once.
|
42
|
+
email:
|
43
|
+
- jacoyutorius@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- MIT-LICENSE
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
51
|
+
- lib/db_patch.rb
|
52
|
+
- lib/db_patch/migration.rb
|
53
|
+
- lib/db_patch/patch_version.rb
|
54
|
+
- lib/db_patch/railtie.rb
|
55
|
+
- lib/db_patch/version.rb
|
56
|
+
- lib/tasks/db_patch_tasks.rake
|
57
|
+
homepage: https://github.com/jacoyutorius/rails_db_patch
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.2.2
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Manage tool for ruby script which executed to DB only once.
|
81
|
+
test_files: []
|