wanderung 0.2.0 → 0.3.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 +4 -4
- data/.github/workflows/ruby.yml +1 -0
- data/.gitignore +3 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +5 -1
- data/README.md +35 -4
- data/lib/wanderung.rb +28 -3
- data/lib/wanderung/database.rb +20 -0
- data/lib/wanderung/version.rb +2 -2
- data/wanderung.gemspec +3 -0
- metadata +30 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c50050f423109944ef2d38ef50113f028fc1aa5f47a40c1bc0ec3424e99055f8
|
4
|
+
data.tar.gz: 8304f2f0ed3db7900be692b76c35300d7bd2f763f02f9312f9e97c5ea09fedd1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72e2ffc2214accf4564c071bda133803e775ac0815b9ae72f31ff2be37861ecf158c15716b3d25a1bc888bc863f8443081bb10c5038ed9a360444404e511f3f9
|
7
|
+
data.tar.gz: 81d67dd10f11c6a7356d8238a429fe412b82269467cfad54efd9298dd775418e3e766dd77339990ee44257c14dcd7151c2a259c42aded66477af14541d9174c3
|
data/.github/workflows/ruby.yml
CHANGED
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -5,3 +5,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
|
+
|
9
|
+
## [0.3.0] - 2019-10-01
|
10
|
+
|
11
|
+
### Added
|
12
|
+
|
13
|
+
- Capabilities to run multiple migrations
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
wanderung (0.
|
4
|
+
wanderung (0.2.0)
|
5
|
+
sequel (~> 5.25)
|
5
6
|
|
6
7
|
GEM
|
7
8
|
remote: https://rubygems.org/
|
@@ -25,6 +26,8 @@ GEM
|
|
25
26
|
ruby-progressbar (~> 1.7)
|
26
27
|
unicode-display_width (>= 1.4.0, < 1.7)
|
27
28
|
ruby-progressbar (1.10.1)
|
29
|
+
sequel (5.25.0)
|
30
|
+
sqlite3 (1.4.1)
|
28
31
|
thor (0.20.3)
|
29
32
|
unicode-display_width (1.6.0)
|
30
33
|
|
@@ -37,6 +40,7 @@ DEPENDENCIES
|
|
37
40
|
minitest (~> 5.0)
|
38
41
|
rake (~> 10.0)
|
39
42
|
rubocop (= 0.75.0)
|
43
|
+
sqlite3 (~> 1.4)
|
40
44
|
wanderung!
|
41
45
|
|
42
46
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -1,8 +1,15 @@
|
|
1
1
|
# Wanderung
|
2
2
|
|
3
|
-
|
3
|
+
Wanderung helps you to manage multiple migrations within the same repository
|
4
4
|
|
5
|
-
|
5
|
+
It uses [Sequel](https://github.com/jeremyevans/sequel) internally to manage the migrations. Therefore, the same syntax is expected
|
6
|
+
|
7
|
+
## Motivation
|
8
|
+
|
9
|
+
As part of a project that we were working on, we had to orchestrate multiple databases, whenever these started to grow,
|
10
|
+
it became troublesome to have to run several migrations for the micro-services to work together properly.
|
11
|
+
|
12
|
+
We wanted to have all of our migrations in a single place, run a single command and have them all executed.
|
6
13
|
|
7
14
|
## Installation
|
8
15
|
|
@@ -22,7 +29,31 @@ Or install it yourself as:
|
|
22
29
|
|
23
30
|
## Usage
|
24
31
|
|
25
|
-
|
32
|
+
```ruby
|
33
|
+
# Simple Migration
|
34
|
+
Wanderung.new(
|
35
|
+
database: 'artists', connection_uri: 'sqlite://artists.db'
|
36
|
+
).run
|
37
|
+
|
38
|
+
# Path of the folder where the migrations are is assumed from the db name, but it can also be specified
|
39
|
+
|
40
|
+
Wanderung.new(
|
41
|
+
database: 'artists', connection_uri: 'sqlite://artists.db', path: 'my_migrations/artists'
|
42
|
+
).run
|
43
|
+
|
44
|
+
# Multiple databases can also be passed in as an array
|
45
|
+
Wanderung.new(
|
46
|
+
{ database: 'artists', connection_uri: 'sqlite://artists.db', path: 'my_migrations/artists' },
|
47
|
+
{ database: 'not_artists', connection_uri: 'sqlite://not_artists.db' }
|
48
|
+
).run
|
49
|
+
|
50
|
+
# A logger can be supplied so that the migrations are logged
|
51
|
+
Wanderung.new(database: 'artists', connection_uri: 'sqlite://artists.db').tap { |w| w.logger = Logger.new(STDOUT) }.run
|
52
|
+
```
|
53
|
+
|
54
|
+
It supports all of the [adapters that Sequel supports](https://github.com/jeremyevans/sequel#sequel-the-database-toolkit-for-ruby)
|
55
|
+
|
56
|
+
A simple example can be found in the test folder
|
26
57
|
|
27
58
|
## Development
|
28
59
|
|
@@ -32,4 +63,4 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
63
|
|
33
64
|
## Contributing
|
34
65
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
66
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/belfazt/wanderung.
|
data/lib/wanderung.rb
CHANGED
@@ -1,8 +1,33 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'wanderung/version'
|
4
|
+
require 'wanderung/database'
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
6
|
+
require 'sequel'
|
7
|
+
|
8
|
+
##
|
9
|
+
# Allows you to create multiple database schemas
|
10
|
+
class Wanderung
|
11
|
+
def initialize(database_configs)
|
12
|
+
@database_configs = database_configs.is_a?(Hash) ? [database_configs] : database_configs
|
13
|
+
end
|
14
|
+
|
15
|
+
def run
|
16
|
+
databases.map(&:migrate)
|
17
|
+
end
|
18
|
+
|
19
|
+
attr_writer :logger
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def databases
|
24
|
+
@databases ||= @database_configs.map do |database_config|
|
25
|
+
path = database_config.fetch(:path, database_config.fetch(:database))
|
26
|
+
Database.new(
|
27
|
+
path: [Dir.pwd, path].join('/'),
|
28
|
+
connection_uri: database_config.fetch(:connection_uri),
|
29
|
+
logger: @logger
|
30
|
+
)
|
31
|
+
end
|
32
|
+
end
|
8
33
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'sequel'
|
4
|
+
|
5
|
+
class Wanderung
|
6
|
+
##
|
7
|
+
# Object to represent a database, with its migration counterpart
|
8
|
+
class Database
|
9
|
+
Sequel.extension :migration
|
10
|
+
def initialize(connection_uri:, path:, logger:)
|
11
|
+
@logger = logger
|
12
|
+
@db = Sequel.connect(connection_uri).tap { |db| db.logger = logger }.freeze
|
13
|
+
@path = path
|
14
|
+
end
|
15
|
+
|
16
|
+
def migrate
|
17
|
+
Sequel::Migrator.run(@db, @path)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/wanderung/version.rb
CHANGED
data/wanderung.gemspec
CHANGED
@@ -31,4 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_development_dependency 'minitest', '~> 5.0'
|
32
32
|
spec.add_development_dependency 'rake', '~> 10.0'
|
33
33
|
spec.add_development_dependency 'rubocop', '0.75.0'
|
34
|
+
spec.add_development_dependency 'sqlite3', '~> 1.4'
|
35
|
+
|
36
|
+
spec.add_runtime_dependency 'sequel', '~> 5.25'
|
34
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wanderung
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Diego Camargo
|
@@ -80,6 +80,34 @@ dependencies:
|
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.75.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sqlite3
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.4'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.4'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: sequel
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '5.25'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '5.25'
|
83
111
|
description:
|
84
112
|
email:
|
85
113
|
- dicamargov@gmail.com
|
@@ -100,6 +128,7 @@ files:
|
|
100
128
|
- bin/console
|
101
129
|
- bin/setup
|
102
130
|
- lib/wanderung.rb
|
131
|
+
- lib/wanderung/database.rb
|
103
132
|
- lib/wanderung/version.rb
|
104
133
|
- wanderung.gemspec
|
105
134
|
homepage: https://github.com/belfazt/wanderung
|