db-migrate 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +10 -0
- data/Gemfile +0 -2
- data/Gemfile.lock +4 -2
- data/README.md +44 -4
- data/{migrate.gemspec → db-migrate.gemspec} +6 -2
- data/lib/migrate.rb +1 -1
- data/lib/migrate/{config.rb → conf.rb} +1 -1
- data/lib/migrate/storage/postgres.rb +0 -1
- data/spec/lib/config_spec.rb +9 -12
- data/spec/spec_helper.rb +6 -6
- metadata +31 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ae9108533b672071c775942824aab96ced8deab
|
4
|
+
data.tar.gz: de210600aaed6da647956f743bddd708f2fdfa88
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0ce6ee5faa4921991d7c65ee3e532e6163358f074c00c61cb0ce9e1a0ca308c9a5c10e019b15ea0c59d3e71ee8580866bfd9d4dc0d1df00502e90b158236f4b
|
7
|
+
data.tar.gz: 9d0da18f6ce6190fd6410d9a9887e4d5a30dad263b877b7c153af2ecbc0fa5f6a9de784f19b244459f6c36ce6827db206cb5a0a427995ae7085ab30dbbd167a2
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
migrate (0.0.
|
4
|
+
db-migrate (0.0.2)
|
5
5
|
colorize (= 0.7.7)
|
6
6
|
highline (= 1.7.8)
|
7
7
|
json (= 1.8.3)
|
8
8
|
mysql2 (= 0.4.2)
|
9
9
|
parseconfig (= 1.0.6)
|
10
10
|
pg (= 0.18.4)
|
11
|
+
terminal-table (= 1.5.2)
|
11
12
|
thor (= 0.19.1)
|
12
13
|
|
13
14
|
GEM
|
@@ -33,13 +34,14 @@ GEM
|
|
33
34
|
diff-lcs (>= 1.2.0, < 2.0)
|
34
35
|
rspec-support (~> 3.4.0)
|
35
36
|
rspec-support (3.4.1)
|
37
|
+
terminal-table (1.5.2)
|
36
38
|
thor (0.19.1)
|
37
39
|
|
38
40
|
PLATFORMS
|
39
41
|
ruby
|
40
42
|
|
41
43
|
DEPENDENCIES
|
42
|
-
migrate!
|
44
|
+
db-migrate!
|
43
45
|
rspec
|
44
46
|
|
45
47
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
# migrate
|
2
|
+
[![Build Status](https://travis-ci.org/ivpusic/migrate.svg?branch=master)](https://travis-ci.org/ivpusic/migrate)
|
2
3
|
|
3
4
|
Tool for managing and executing your database migrations.
|
4
5
|
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
```
|
9
|
+
gem install db-migrate
|
10
|
+
```
|
11
|
+
|
5
12
|
### How it works?
|
6
|
-
It saves metadata about your migrations to database
|
13
|
+
It saves metadata about your migrations to database and uses that metadata for executing and creating new migrations.
|
7
14
|
|
8
15
|
It supports multiple databases and multiple languages for executing migrations.
|
9
16
|
|
@@ -18,7 +25,9 @@ It supports multiple databases and multiple languages for executing migrations.
|
|
18
25
|
- Javascript (Node.js)
|
19
26
|
- Go
|
20
27
|
|
21
|
-
|
28
|
+
## How to use it?
|
29
|
+
|
30
|
+
##### --help
|
22
31
|
```
|
23
32
|
Commands:
|
24
33
|
migrate init # make configuration file
|
@@ -36,19 +45,50 @@ Options:
|
|
36
45
|
# Default: migrate.conf
|
37
46
|
```
|
38
47
|
|
39
|
-
|
40
|
-
|
48
|
+
#### init
|
41
49
|
First thing you have to do is to make initial configuration with **migrate init** command.
|
50
|
+
|
51
|
+
**Demo:**
|
52
|
+
```
|
53
|
+
$ migrate init
|
54
|
+
[INFO] Creating configuration...
|
55
|
+
1. mysql
|
56
|
+
2. pg
|
57
|
+
Which database do you prefer?
|
58
|
+
1
|
59
|
+
1. sql
|
60
|
+
2. ruby
|
61
|
+
3. javascript
|
62
|
+
4. go
|
63
|
+
5. python
|
64
|
+
What language would you like use for your migration scripts?
|
65
|
+
1
|
66
|
+
Host: |localhost|
|
67
|
+
Port: |3306|
|
68
|
+
Database Name: |mydb|
|
69
|
+
User: |root|
|
70
|
+
Password: password
|
71
|
+
Version info table: |version_info|
|
72
|
+
Version number table: |version_number|
|
73
|
+
[SUCCESS] Configuration file created. Location: `./migrate.conf`
|
74
|
+
```
|
75
|
+
|
76
|
+
#### new
|
42
77
|
After that you can start generating migrations by using **migrate new** command. This will generate migration script for you based on your prefered language.
|
43
78
|
|
79
|
+
#### up
|
44
80
|
When you are done with writing your `up` and `down` migration script, you can execute **migrate up** to run up migration script for new version. You can also execute multiple migrations in single call by providing `--to n` argument, where `n` is highest version where you want to navigate.
|
45
81
|
|
82
|
+
#### down
|
46
83
|
You can also use **migrate down** to go one version back. `down` comand also accepts `--to n` argument, but in this case `n` is lowest version where you want to navigate.
|
47
84
|
|
85
|
+
#### version
|
48
86
|
If you are asking yourself about current version, use **migrate version** to find out current version.
|
49
87
|
|
88
|
+
#### delete
|
50
89
|
If you don't need some migration, use **migrate delete n** to remove version `n`.
|
51
90
|
|
91
|
+
#### list
|
52
92
|
You can see list of your migrations by running **migrate list**. This command also provides some additional options for filtering results.
|
53
93
|
|
54
94
|
## Contributing
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'db-migrate'
|
3
|
-
s.version = '0.0.
|
3
|
+
s.version = '0.0.2'
|
4
4
|
s.licenses = ['MIT']
|
5
5
|
s.summary = "Tool for managing and executing your database migrations."
|
6
6
|
s.description = "#{s.summary} It supports multiple databases and multiple languages for writing migration scripts."
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = 'https://github.com/ivpusic/migrate'
|
11
11
|
s.executables << 'migrate'
|
12
12
|
|
13
|
-
# deps
|
13
|
+
# runtime deps
|
14
14
|
s.add_runtime_dependency 'thor', ['0.19.1']
|
15
15
|
s.add_runtime_dependency 'highline', ['1.7.8']
|
16
16
|
s.add_runtime_dependency 'json', ['1.8.3']
|
@@ -18,4 +18,8 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.add_runtime_dependency 'pg', ['0.18.4']
|
19
19
|
s.add_runtime_dependency 'parseconfig', ['1.0.6']
|
20
20
|
s.add_runtime_dependency 'colorize', ['0.7.7']
|
21
|
+
s.add_runtime_dependency 'terminal-table', ['1.5.2']
|
22
|
+
|
23
|
+
# dev deps
|
24
|
+
s.add_development_dependency "rspec"
|
21
25
|
end
|
data/lib/migrate.rb
CHANGED
data/spec/lib/config_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
describe "
|
2
|
-
let(:fixtures) { "spec/lib/fixtures" }
|
3
|
-
let(:config) {
|
4
|
-
let(:config_hash) {
|
1
|
+
describe "Conf" do
|
2
|
+
let!(:fixtures) { "spec/lib/fixtures" }
|
3
|
+
let!(:config) { Conf.new(fixtures, "example.config") }
|
4
|
+
let!(:config_hash) {
|
5
5
|
{
|
6
6
|
host: "localhost",
|
7
7
|
port: ("5432").to_i,
|
@@ -22,21 +22,18 @@ describe "Config" do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should not find file" do
|
25
|
-
config =
|
25
|
+
config = Conf.new(".", "custom_file.conf")
|
26
26
|
expect(config.exists?).to eq(false)
|
27
27
|
end
|
28
28
|
|
29
|
-
it "should find file" do
|
30
|
-
expect(config.exists?).to eq(true)
|
31
|
-
end
|
32
|
-
|
33
29
|
it "should create config file" do
|
34
30
|
config_path = "#{fixtures}/test.config"
|
35
31
|
begin
|
36
32
|
expect(File.exist? config_path).to be false
|
37
33
|
|
38
|
-
config =
|
34
|
+
config = Conf.new(fixtures, "test.config")
|
39
35
|
config.init(config_hash)
|
36
|
+
expect(config.exists?).to eq(true)
|
40
37
|
expect(File.exist? config_path). to be true
|
41
38
|
ensure
|
42
39
|
if File.exist? config_path
|
@@ -44,7 +41,7 @@ describe "Config" do
|
|
44
41
|
end
|
45
42
|
end
|
46
43
|
end
|
47
|
-
|
44
|
+
|
48
45
|
it "should load configuration" do
|
49
46
|
config.init(config_hash)
|
50
47
|
config.load!
|
@@ -62,7 +59,7 @@ describe "Config" do
|
|
62
59
|
begin
|
63
60
|
expect(File.exist? config_path).to be false
|
64
61
|
|
65
|
-
config =
|
62
|
+
config = Conf.new(fixtures, "test.config")
|
66
63
|
config.init(config_hash)
|
67
64
|
expect(File.exist? config_path).to be true
|
68
65
|
config.delete
|
data/spec/spec_helper.rb
CHANGED
@@ -14,12 +14,12 @@ $config_base = {
|
|
14
14
|
$pg_config_hash = $config_base.merge({
|
15
15
|
:storage => "pg",
|
16
16
|
:port => 5432,
|
17
|
-
:user => "
|
18
|
-
:password => "
|
17
|
+
:user => "postgres",
|
18
|
+
:password => ""
|
19
19
|
})
|
20
20
|
|
21
21
|
def load_pg_config
|
22
|
-
config =
|
22
|
+
config = Conf.new("spec/lib/fixtures", "example_pg.config")
|
23
23
|
config.init($pg_config_hash)
|
24
24
|
config.load!
|
25
25
|
return config
|
@@ -28,12 +28,12 @@ end
|
|
28
28
|
$mysql_config_hash = $config_base.merge({
|
29
29
|
:storage => "mysql",
|
30
30
|
:port => 3306,
|
31
|
-
:user => "
|
32
|
-
:password => "
|
31
|
+
:user => "root",
|
32
|
+
:password => ""
|
33
33
|
})
|
34
34
|
|
35
35
|
def load_mysql_config
|
36
|
-
config =
|
36
|
+
config = Conf.new("spec/lib/fixtures", "example_mysql.config")
|
37
37
|
config.init($mysql_config_hash)
|
38
38
|
config.load!
|
39
39
|
return config
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: db-migrate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ivan Pusic
|
@@ -108,6 +108,34 @@ dependencies:
|
|
108
108
|
- - '='
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: 0.7.7
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: terminal-table
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.5.2
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.5.2
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rspec
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
111
139
|
description: Tool for managing and executing your database migrations. It supports
|
112
140
|
multiple databases and multiple languages for writing migration scripts.
|
113
141
|
email: pusic007@gmail.com
|
@@ -124,8 +152,9 @@ files:
|
|
124
152
|
- LICENSE
|
125
153
|
- README.md
|
126
154
|
- bin/migrate
|
155
|
+
- db-migrate.gemspec
|
127
156
|
- lib/migrate.rb
|
128
|
-
- lib/migrate/
|
157
|
+
- lib/migrate/conf.rb
|
129
158
|
- lib/migrate/errors.rb
|
130
159
|
- lib/migrate/lang.rb
|
131
160
|
- lib/migrate/lang/go.rb
|
@@ -140,9 +169,7 @@ files:
|
|
140
169
|
- lib/migrate/storage/db.rb
|
141
170
|
- lib/migrate/storage/mysql.rb
|
142
171
|
- lib/migrate/storage/postgres.rb
|
143
|
-
- migrate.gemspec
|
144
172
|
- spec/lib/config_spec.rb
|
145
|
-
- spec/lib/fixtures/example.config
|
146
173
|
- spec/lib/fixtures/go/down.go
|
147
174
|
- spec/lib/fixtures/go/up.go
|
148
175
|
- spec/lib/fixtures/js/down.js
|