migrate 0.0.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/migrate/controller.rb +20 -34
- data/lib/migrate/migration.rb +14 -17
- data/lib/migrate/provider.rb +28 -0
- data/lib/migrate/version.rb +1 -1
- metadata +36 -28
- data/.gitignore +0 -12
- data/.rspec +0 -5
- data/.travis.yml +0 -5
- data/Gemfile +0 -8
- data/README.md +0 -55
- data/Rakefile +0 -6
- data/migrate.gemspec +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '068edcb37106f1848382dbe09a797743785b6ce15a3f3fd774b0026e272cd967'
|
4
|
+
data.tar.gz: 179111bfdcb3a20bd0f051eca9d8ddf0766fb5e11971e118d441ffd6db33dce1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbfd24c35f7405d2b182a77edfb5e66fe9f543738b4b64b76c39ae0e064d6bc83768f004bed53ba112ea4f251332d370587a2a6caa951e2f4f5b2cae42be4bb3
|
7
|
+
data.tar.gz: 7ba48b03e573813efe4e88f34c13c333a385890b38a938100c1f624e838fd349ffd2d43ce56e9d13fdfb2e3787e5d0e0d0dad1e46f34e9911d3f244564a70aa7
|
data/lib/migrate/controller.rb
CHANGED
@@ -18,52 +18,38 @@
|
|
18
18
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
19
|
# THE SOFTWARE.
|
20
20
|
|
21
|
+
require 'console'
|
22
|
+
require 'build/files'
|
23
|
+
|
24
|
+
require_relative 'migration'
|
25
|
+
|
21
26
|
module Migrate
|
22
27
|
class Controller
|
23
|
-
|
24
|
-
@migrations = {}
|
25
|
-
end
|
28
|
+
ROOT = Build::Files::Path.current / "migrate"
|
26
29
|
|
27
|
-
|
28
|
-
|
29
|
-
# Apply the given migration.
|
30
|
-
def apply(migration)
|
31
|
-
start_time = Time.now
|
32
|
-
|
33
|
-
yield
|
34
|
-
|
35
|
-
duration = Time.now - start_time
|
36
|
-
|
37
|
-
commit(migration)
|
30
|
+
def initialize(root = ROOT)
|
31
|
+
@root = root
|
38
32
|
end
|
39
33
|
|
40
|
-
|
41
|
-
|
42
|
-
@migrations[migration.name] = migration
|
34
|
+
def migrations
|
35
|
+
@root.glob("**/*.rb").map{|path| Migration.new(path)}.sort
|
43
36
|
end
|
44
37
|
|
45
|
-
def
|
38
|
+
def migrate!
|
46
39
|
migrations.each do |migration|
|
47
|
-
|
48
|
-
|
49
|
-
end unless @migrations.include?(migration)
|
40
|
+
Console.logger.debug(self, "Applying #{migration}...")
|
41
|
+
migration.call(self)
|
50
42
|
end
|
51
43
|
end
|
52
|
-
end
|
53
|
-
|
54
|
-
class FileController
|
55
|
-
def initialize(root)
|
56
|
-
@root = root
|
57
|
-
|
58
|
-
super()
|
59
|
-
end
|
60
44
|
|
61
|
-
def
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
45
|
+
def create!(name, &block)
|
46
|
+
prefix = Time.now.strftime("%Y%m%d%H%M%S")
|
47
|
+
path = @root / "#{prefix}-#{name}.rb"
|
48
|
+
path.parent.mkpath
|
49
|
+
|
50
|
+
path.open(File::CREAT|File::TRUNC|File::WRONLY, &block)
|
66
51
|
|
52
|
+
return path
|
67
53
|
end
|
68
54
|
end
|
69
55
|
end
|
data/lib/migrate/migration.rb
CHANGED
@@ -20,30 +20,27 @@
|
|
20
20
|
|
21
21
|
module Migrate
|
22
22
|
class Migration
|
23
|
-
def
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
def initialize(name = self.class.migration_name)
|
28
|
-
@name = name
|
23
|
+
def initialize(path)
|
24
|
+
@path = path
|
25
|
+
@name = path.relative_path
|
29
26
|
end
|
30
27
|
|
31
28
|
attr :name
|
32
29
|
|
33
30
|
def call(controller)
|
31
|
+
self.instance_eval(::File.read(@path), @path)
|
32
|
+
end
|
33
|
+
|
34
|
+
def migrate(target, using:, &block)
|
35
|
+
using.migrate(self.name, target, &block)
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_s
|
39
|
+
@name
|
34
40
|
end
|
35
41
|
|
36
|
-
def
|
37
|
-
|
38
|
-
migration_name = File.basename(path)
|
39
|
-
|
40
|
-
klass.define_singleton_method(:migration_name) do
|
41
|
-
migration_name
|
42
|
-
end
|
43
|
-
|
44
|
-
klass.class_eval(File.read(path), path)
|
45
|
-
|
46
|
-
klass.freeze
|
42
|
+
def <=> other
|
43
|
+
@name <=> other.name
|
47
44
|
end
|
48
45
|
end
|
49
46
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
using.migrate(self.name, target, &block)
|
2
|
+
# Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
# of this software and associated documentation files (the "Software"), to deal
|
6
|
+
# in the Software without restriction, including without limitation the rights
|
7
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
# copies of the Software, and to permit persons to whom the Software is
|
9
|
+
# furnished to do so, subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in
|
12
|
+
# all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
+
# THE SOFTWARE.
|
21
|
+
|
22
|
+
module Migrate
|
23
|
+
class Provider
|
24
|
+
def migrate(migration, target, &block)
|
25
|
+
yield
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/migrate/version.rb
CHANGED
metadata
CHANGED
@@ -1,43 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: migrate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: build-files
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
20
|
-
type: :
|
19
|
+
version: '1.7'
|
20
|
+
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.7'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: bake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '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: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,28 +66,23 @@ dependencies:
|
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '3.0'
|
55
|
-
description:
|
69
|
+
description:
|
56
70
|
email:
|
57
|
-
- samuel.williams@oriontransfer.co.nz
|
58
71
|
executables: []
|
59
72
|
extensions: []
|
60
73
|
extra_rdoc_files: []
|
61
74
|
files:
|
62
|
-
- ".gitignore"
|
63
|
-
- ".rspec"
|
64
|
-
- ".travis.yml"
|
65
|
-
- Gemfile
|
66
|
-
- README.md
|
67
|
-
- Rakefile
|
68
75
|
- lib/migrate.rb
|
69
76
|
- lib/migrate/controller.rb
|
70
77
|
- lib/migrate/migration.rb
|
78
|
+
- lib/migrate/provider.rb
|
71
79
|
- lib/migrate/version.rb
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
metadata:
|
76
|
-
|
80
|
+
homepage: https://github.com/socketry/migrate
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata:
|
84
|
+
funding_uri: https://github.com/sponsors/ioquatix/
|
85
|
+
post_install_message:
|
77
86
|
rdoc_options: []
|
78
87
|
require_paths:
|
79
88
|
- lib
|
@@ -88,9 +97,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
97
|
- !ruby/object:Gem::Version
|
89
98
|
version: '0'
|
90
99
|
requirements: []
|
91
|
-
|
92
|
-
|
93
|
-
signing_key:
|
100
|
+
rubygems_version: 3.2.3
|
101
|
+
signing_key:
|
94
102
|
specification_version: 4
|
95
103
|
summary: Generic library to support migrations.
|
96
104
|
test_files: []
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/README.md
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
# Migrate
|
2
|
-
|
3
|
-
Provides a generic set of tools to implement migrations.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
```ruby
|
10
|
-
gem 'migrate'
|
11
|
-
```
|
12
|
-
|
13
|
-
And then execute:
|
14
|
-
|
15
|
-
$ bundle
|
16
|
-
|
17
|
-
Or install it yourself as:
|
18
|
-
|
19
|
-
$ gem install migrate
|
20
|
-
|
21
|
-
## Usage
|
22
|
-
|
23
|
-
TODO: Write usage instructions here
|
24
|
-
|
25
|
-
## Contributing
|
26
|
-
|
27
|
-
1. Fork it
|
28
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
30
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
-
5. Create new Pull Request
|
32
|
-
|
33
|
-
## License
|
34
|
-
|
35
|
-
Released under the MIT license.
|
36
|
-
|
37
|
-
Copyright, 2017, by [Samuel G. D. Williams](http://www.codeotaku.com/samuel-williams).
|
38
|
-
|
39
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
40
|
-
of this software and associated documentation files (the "Software"), to deal
|
41
|
-
in the Software without restriction, including without limitation the rights
|
42
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
43
|
-
copies of the Software, and to permit persons to whom the Software is
|
44
|
-
furnished to do so, subject to the following conditions:
|
45
|
-
|
46
|
-
The above copyright notice and this permission notice shall be included in
|
47
|
-
all copies or substantial portions of the Software.
|
48
|
-
|
49
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
50
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
51
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
52
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
53
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
54
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
55
|
-
THE SOFTWARE.
|
data/Rakefile
DELETED
data/migrate.gemspec
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require_relative 'lib/migrate/version'
|
3
|
-
|
4
|
-
Gem::Specification.new do |spec|
|
5
|
-
spec.name = "migrate"
|
6
|
-
spec.version = Migrate::VERSION
|
7
|
-
spec.authors = ["Samuel Williams"]
|
8
|
-
spec.email = ["samuel.williams@oriontransfer.co.nz"]
|
9
|
-
|
10
|
-
spec.summary = "Generic library to support migrations."
|
11
|
-
spec.homepage = "https://github.com/ioquatix/migrate"
|
12
|
-
|
13
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
14
|
-
f.match(%r{^(test|spec|features)/})
|
15
|
-
end
|
16
|
-
spec.bindir = "bin"
|
17
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
-
spec.require_paths = ["lib"]
|
19
|
-
|
20
|
-
spec.add_development_dependency "bundler", "~> 1.14"
|
21
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
-
spec.add_development_dependency "rspec", "~> 3.0"
|
23
|
-
end
|