sql_migrations 2.0.0 → 2.1.0.pre1
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/README.md +13 -11
- data/lib/sql_migrations/config.rb +1 -3
- data/lib/sql_migrations/version.rb +1 -1
- data/spec/features/config_spec.rb +16 -0
- data/spec/features/migration_order_spec.rb +1 -0
- data/spec/features/migration_spec.rb +1 -0
- data/spec/features/schema_table_spec.rb +3 -1
- data/spec/features/sql_scripts_spec.rb +1 -0
- data/spec/spec_helper.rb +0 -1
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c557edf1205471dd615b56dee7ca0afccc72e856
|
4
|
+
data.tar.gz: 2b7490a12ee7fae0ae74dc36d236f2ed17a05b23
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90e584fecf119bd71eb61a731531e984461e52804f32975697e3f305ad8284c93500a92123349221d32bd0ac221573d93bb33456ca061236fb97549703891c5a
|
7
|
+
data.tar.gz: e5e0cb7a19408dc930d333013e384217cb73b881a0a147687b83cd802409506fc4e301d11229108d84d41c76170f72e42ae32bd8de2bd88771616fe9bf59c655
|
data/README.md
CHANGED
@@ -10,10 +10,10 @@ This gives you possibility to execute migrations, seed datebase (on production a
|
|
10
10
|
|
11
11
|
## Why ?
|
12
12
|
|
13
|
-
This is particularly useful in old projects that don't have migration support, and you really want to use
|
13
|
+
This is particularly useful in old projects that don't have migration support, and you really want to use Continuous Delivery strategy.
|
14
14
|
Without migrations you wouldn't be able to setup your test environment for automated testing (functional tests, unit tests, integration tests).
|
15
15
|
|
16
|
-
For example, if you work on old Zend 1 project, and you want to take benefit from using
|
16
|
+
For example, if you work on old Zend 1 project, and you want to take benefit from using Continuous Deployment/Continuous Integration mechanisms - you may find this project useful.
|
17
17
|
|
18
18
|
## Install
|
19
19
|
|
@@ -55,14 +55,13 @@ For example, if you work on old Zend 1 project, and you want to take benefit fro
|
|
55
55
|
username: test_user
|
56
56
|
password: test_pass
|
57
57
|
host: 192.168.1.1
|
58
|
-
|
58
|
+
test:
|
59
59
|
adapter: mysql2
|
60
60
|
encoding: utf8
|
61
|
-
database:
|
62
|
-
username:
|
63
|
-
password:
|
64
|
-
host:
|
65
|
-
|
61
|
+
database: <%= ENV['DB_NAME'] %>
|
62
|
+
username: <%= ENV['DB_USER'] %>
|
63
|
+
password: <%= ENV['DB_PASS'] %>
|
64
|
+
host: <%= ENV['DB_HOST'] %>
|
66
65
|
production:
|
67
66
|
adapter: mysql2
|
68
67
|
encoding: utf8
|
@@ -70,7 +69,8 @@ For example, if you work on old Zend 1 project, and you want to take benefit fro
|
|
70
69
|
username: test_user
|
71
70
|
password: test_pass
|
72
71
|
host: 192.168.1.100
|
73
|
-
|
72
|
+
|
73
|
+
second_db:
|
74
74
|
development:
|
75
75
|
adapter: mysql2
|
76
76
|
encoding: utf8
|
@@ -78,7 +78,7 @@ For example, if you work on old Zend 1 project, and you want to take benefit fro
|
|
78
78
|
username: test_user
|
79
79
|
password: test_pass
|
80
80
|
host: 127.0.0.1
|
81
|
-
|
81
|
+
test:
|
82
82
|
adapter: mysql2
|
83
83
|
encoding: utf8
|
84
84
|
database: second_db_test
|
@@ -89,7 +89,9 @@ For example, if you work on old Zend 1 project, and you want to take benefit fro
|
|
89
89
|
|
90
90
|
Note that you need to define `default` database configuration.
|
91
91
|
|
92
|
-
|
92
|
+
As shown above, it is possible to use ERB-like syntax to use environment variables in config.
|
93
|
+
|
94
|
+
4. Migrations/seed/fixtures can be executed using rake tasks. So you will need to create `Rakefile`:
|
93
95
|
|
94
96
|
```ruby
|
95
97
|
require 'bundler'
|
@@ -1,11 +1,10 @@
|
|
1
1
|
module SqlMigrations
|
2
2
|
class Config
|
3
|
-
|
4
3
|
class << self
|
5
4
|
attr_reader :options
|
6
5
|
|
7
6
|
def load!(config_file)
|
8
|
-
@options = YAML
|
7
|
+
@options = YAML.load(ERB.new(File.new(config_file).read).result)
|
9
8
|
end
|
10
9
|
end
|
11
10
|
|
@@ -33,6 +32,5 @@ module SqlMigrations
|
|
33
32
|
end
|
34
33
|
databases
|
35
34
|
end
|
36
|
-
|
37
35
|
end
|
38
36
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
describe 'loadable configuration file' do
|
2
|
+
before do
|
3
|
+
File.open('databases.yml', 'w') do |f|
|
4
|
+
f.puts 'default:'
|
5
|
+
f.puts ' test:'
|
6
|
+
f.puts ' adapter: sqlite3'
|
7
|
+
f.puts ' database: <%= ENV["DB_NAME"] %>'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should use environment variables in config' do
|
12
|
+
ENV['DB_NAME'] = 'test_database'
|
13
|
+
SqlMigrations::Config.load! 'databases.yml'
|
14
|
+
expect(SqlMigrations::Config.options['default']['test']['database']).to eq 'test_database'
|
15
|
+
end
|
16
|
+
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
describe 'migrations valid order support engine' do
|
2
2
|
before do
|
3
|
+
allow(SqlMigrations::Config).to receive(:options) { { "default" => { "development" => {}}} }
|
3
4
|
$stdout = StringIO.new
|
4
5
|
Dir.mkdir('/migrations')
|
5
6
|
File.open('/migrations/20150305_154010_test_migration.sql', 'w') do |f|
|
@@ -4,6 +4,7 @@ describe 'migration' do
|
|
4
4
|
File.open('/migrations/20150305_154010_test_migration.sql', 'w') do |f|
|
5
5
|
f.puts "CREATE TABLE test_table(col_int INTEGER, col_str STRING)"
|
6
6
|
end
|
7
|
+
allow(SqlMigrations::Config).to receive(:options) { { "default" => { "development" => {}}} }
|
7
8
|
@migration = SqlMigrations::Migration.find([ :default ]).first
|
8
9
|
end
|
9
10
|
|
@@ -1,4 +1,7 @@
|
|
1
1
|
describe 'schema table in database' do
|
2
|
+
before do
|
3
|
+
allow(SqlMigrations::Config).to receive(:options) { { "default" => { "development" => {}}} }
|
4
|
+
end
|
2
5
|
|
3
6
|
it 'should be created if it does not exist' do
|
4
7
|
expect do
|
@@ -22,5 +25,4 @@ describe 'schema table in database' do
|
|
22
25
|
end.to output("[+] Connected to database using sqlite adapter\n").to_stdout
|
23
26
|
expect(@database.db.table_exists?(:sqlmigrations_schema)).to be true
|
24
27
|
end
|
25
|
-
|
26
28
|
end
|
@@ -18,6 +18,7 @@ describe 'sql scripts' do
|
|
18
18
|
f.puts "INSERT INTO first_test2_table(col_int1, col_str1) VALUES(2123, '2test_string1')"
|
19
19
|
f.puts "INSERT INTO second_test2_table(col_int2, col_str2) VALUES(2456, '2test_string2')"
|
20
20
|
end
|
21
|
+
allow(SqlMigrations::Config).to receive(:options) { { "default" => { "development" => {}}} }
|
21
22
|
end
|
22
23
|
|
23
24
|
it 'should be found' do
|
data/spec/spec_helper.rb
CHANGED
@@ -6,7 +6,6 @@ RSpec.configure do |config|
|
|
6
6
|
config.before do
|
7
7
|
@sqlite_db = Sequel.sqlite
|
8
8
|
allow(SqlMigrations::Database).to receive(:connect) { @sqlite_db }
|
9
|
-
allow(SqlMigrations::Config).to receive(:options) { { "default" => { "development" => {}}} }
|
10
9
|
MemFs.activate!
|
11
10
|
end
|
12
11
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sql_migrations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.1.0.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Grzegorz Bizon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- lib/sql_migrations/tasks/seed.rake
|
121
121
|
- lib/sql_migrations/tasks/seed_test.rake
|
122
122
|
- lib/sql_migrations/version.rb
|
123
|
+
- spec/features/config_spec.rb
|
123
124
|
- spec/features/migration_order_spec.rb
|
124
125
|
- spec/features/migration_spec.rb
|
125
126
|
- spec/features/schema_table_spec.rb
|
@@ -141,9 +142,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
141
142
|
version: '0'
|
142
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
144
|
requirements:
|
144
|
-
- - "
|
145
|
+
- - ">"
|
145
146
|
- !ruby/object:Gem::Version
|
146
|
-
version:
|
147
|
+
version: 1.3.1
|
147
148
|
requirements: []
|
148
149
|
rubyforge_project:
|
149
150
|
rubygems_version: 2.4.5
|
@@ -151,8 +152,10 @@ signing_key:
|
|
151
152
|
specification_version: 4
|
152
153
|
summary: Simple standalone migrations you can use with plain SQL
|
153
154
|
test_files:
|
155
|
+
- spec/features/config_spec.rb
|
154
156
|
- spec/features/migration_order_spec.rb
|
155
157
|
- spec/features/migration_spec.rb
|
156
158
|
- spec/features/schema_table_spec.rb
|
157
159
|
- spec/features/sql_scripts_spec.rb
|
158
160
|
- spec/spec_helper.rb
|
161
|
+
has_rdoc:
|