sql_migrations 2.1.0 → 2.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3702a8ae9daa08ef8d63fff9cde70358adea5bc8
4
- data.tar.gz: 8b081cb7388452a405898aac0a72e1d01c70222b
3
+ metadata.gz: fc164b4988352478c077939a9ed77564a15d52eb
4
+ data.tar.gz: 7c8dd94fd00064b7888154aa374568131813d3e9
5
5
  SHA512:
6
- metadata.gz: 4e69925c88ca6bdcec48b4422c86b80b87899469ac06e7ecc84d5f0c068eb1b10f5847d59d64a366a0ba6d02960f180569a71d9e88542c19d2d1b7ea33ab6287
7
- data.tar.gz: 82a75cd5b16f8b02ab6dc7de8384add3c3e401e5468104c7c9a94763e2af9cfdc19072c2af3ffa25c491cbac3c1238eae26414809494f8241fee0844ef32e9b8
6
+ metadata.gz: 43bfdee3da5cdd107dd72cd2eef9ef57a65a87abcb76c04b4735915b3ade80dae99e92880294eed5ac6c20a6abddab8c195085b0a44e03763ffed3517b8063e0
7
+ data.tar.gz: 55bf6583e6875822d9bec006c6027001f111d235621210715a837607e515db9cea4de462828f918231c312f16412cfc021c346a518b2b5c877d56a1549d01604
data/README.md CHANGED
@@ -105,7 +105,7 @@ For example, if you work on old Zend 1 project, and you want to take benefit fro
105
105
  If you have multi-statement migrations you should provide `separator` configuration variable in `options` block. `options` key is optional in YAML.
106
106
 
107
107
 
108
- 4. Migrations/seed/fixtures can be executed using rake tasks. So you will need to create `Rakefile`:
108
+ 4. Migrations/seeds/fixtures can be executed using rake tasks. So you will need to create `Rakefile`:
109
109
 
110
110
  ```ruby
111
111
  require 'bundler'
@@ -147,7 +147,7 @@ For example, if you work on old Zend 1 project, and you want to take benefit fro
147
147
 
148
148
  ## Usage
149
149
 
150
- 1. Valid migration/seed/fixture file names match against regexp `/(\d{8})_(\d{6})_(.*)?\.sql/`. So valid filenames would be:
150
+ 1. Valid migration/seeds/fixture file names match against regexp `/(\d{8})_(\d{6})_(.*)?\.sql/`. So valid filenames would be:
151
151
 
152
152
 
153
153
  20150303_180100_test_migration.sql
@@ -163,7 +163,7 @@ For example, if you work on old Zend 1 project, and you want to take benefit fro
163
163
  20150303_180100_test_migration.sql
164
164
  fixtures/
165
165
  20150303_180100_fixture1.sql
166
- seed/
166
+ seeds/
167
167
  20150303_180100_whatever_description_of_seed.sql
168
168
 
169
169
  If you want to use multiple databases, create also database directories:
@@ -175,7 +175,7 @@ For example, if you work on old Zend 1 project, and you want to take benefit fro
175
175
  fixtures/
176
176
  default/
177
177
  second_db/
178
- seed/
178
+ seeds/
179
179
  default/
180
180
  second_db/
181
181
 
@@ -14,6 +14,8 @@ module SqlMigrations
14
14
  files
15
15
  end
16
16
 
17
+ private
18
+
17
19
  def match_file(db_dir, type, path)
18
20
  # parent_dir/base_dir/filename_that_matches_regexp.sql
19
21
  _filename, base_dir, parent_dir = path.split(File::SEPARATOR).last(3).reverse
@@ -23,7 +25,7 @@ module SqlMigrations
23
25
  return nil unless file_parameters
24
26
 
25
27
  # Only files that lay in specific directory structure will do
26
- file_database = file_match_directories(parent_dir, base_dir, db_dir, type)
28
+ file_database = file_match_directories(parent_dir, base_dir, db_dir, "#{type}s")
27
29
  return nil unless file_database
28
30
 
29
31
  { date: file_parameters[1], time: file_parameters[2],
@@ -3,7 +3,7 @@ module SqlMigrations
3
3
  #
4
4
  class Migration < SqlScript
5
5
  def self.find(db_name)
6
- super(db_name, :migrations)
6
+ super(db_name, :migration)
7
7
  end
8
8
 
9
9
  def to_s
@@ -1,5 +1,5 @@
1
1
  # SqlMigrations
2
2
  #
3
3
  module SqlMigrations
4
- VERSION = '2.1.0'
4
+ VERSION = '2.1.1'
5
5
  end
@@ -0,0 +1,22 @@
1
+ describe 'fixture' do
2
+ before do
3
+ Dir.mkdir('/migrations')
4
+ File.open('/migrations/20150305_154010_test_migration.sql', 'w') do |f|
5
+ f.puts 'CREATE TABLE test_table_fixture(col_int INTEGER, col_str STRING)'
6
+ end
7
+ Dir.mkdir('/fixtures')
8
+ File.open('/fixtures/20150305_154012_test_fixture.sql', 'w') do |f|
9
+ f.puts 'INSERT INTO test_table_fixture VALUES(12, "test_string_fixture")'
10
+ end
11
+ allow(SqlMigrations::Config).to receive(:databases) { { default: { development: {} } } }
12
+ database = SqlMigrations::Database.new(:default, adapter: :sqlite)
13
+ database.execute_migrations
14
+ database.seed_with_fixtures
15
+ end
16
+
17
+ it 'should be properly executed' do
18
+ expect(@sqlite_db.table_exists?(:test_table_fixture)).to be true
19
+ expect(@sqlite_db[:test_table_fixture].first)
20
+ .to eq(col_int: 12, col_str: 'test_string_fixture')
21
+ end
22
+ end
@@ -15,7 +15,6 @@ describe 'multistatement migration' do
15
15
  end
16
16
 
17
17
  it 'should be properly executed' do
18
- $stdout = StringIO.new
19
18
  database = SqlMigrations::Database.new(:default, adapter: :sqlite)
20
19
  @migration.execute(database)
21
20
  expect(@sqlite_db.table_exists?(:multi_test_table1)).to be true
@@ -1,7 +1,6 @@
1
1
  describe 'migrations valid order support engine' do
2
2
  before do
3
3
  allow(SqlMigrations::Config).to receive(:databases) { { default: { development: {} } } }
4
- $stdout = StringIO.new
5
4
  Dir.mkdir('/migrations')
6
5
  File.open('/migrations/20150305_154010_test_migration.sql', 'w') do |f|
7
6
  f.puts 'CREATE TABLE test_table(col_int INTEGER, col_str STRING)'
@@ -25,9 +25,8 @@ describe 'migration' do
25
25
  end
26
26
 
27
27
  it 'should be properly executed' do
28
- $stdout = StringIO.new
29
28
  database = SqlMigrations::Database.new(:default, adapter: :sqlite)
30
- @migration.execute(database)
29
+ database.execute_migrations
31
30
  expect(@sqlite_db.table_exists?(:test_table)).to be true
32
31
  expect(@sqlite_db[:test_table].columns).to include(:col_int)
33
32
  expect(@sqlite_db[:test_table].columns).to include(:col_str)
@@ -0,0 +1,21 @@
1
+ describe 'seed' do
2
+ before do
3
+ Dir.mkdir('/migrations')
4
+ File.open('/migrations/20150305_154010_test_migration.sql', 'w') do |f|
5
+ f.puts 'CREATE TABLE test_table(col_int INTEGER, col_str STRING)'
6
+ end
7
+ Dir.mkdir('/seeds')
8
+ File.open('/seeds/20150305_154011_test_seed.sql', 'w') do |f|
9
+ f.puts 'INSERT INTO test_table VALUES(10, "test_string")'
10
+ end
11
+ allow(SqlMigrations::Config).to receive(:databases) { { default: { development: {} } } }
12
+ database = SqlMigrations::Database.new(:default, adapter: :sqlite)
13
+ database.execute_migrations
14
+ database.seed_database
15
+ end
16
+
17
+ it 'should be properly execute' do
18
+ expect(@sqlite_db.table_exists?(:test_table)).to be true
19
+ expect(@sqlite_db[:test_table].first).to eq(col_int: 10, col_str: 'test_string')
20
+ end
21
+ end
@@ -2,8 +2,8 @@
2
2
  describe 'sql scripts' do
3
3
  before do
4
4
  Dir.mkdir('/migrations')
5
- Dir.mkdir('/seed')
6
5
  Dir.mkdir('/fixtures')
6
+ Dir.mkdir('/seeds')
7
7
 
8
8
  File.open('/migrations/20150305_154010_first_test_migration.sql', 'w') do |f|
9
9
  f.puts 'CREATE TABLE first_test_table(col_int1 INTEGER, col_str1 STRING)'
@@ -11,11 +11,11 @@ describe 'sql scripts' do
11
11
  File.open('/migrations/20150305_154011_second_test_migration.sql', 'w') do |f|
12
12
  f.puts 'CREATE TABLE second_test_table(col_int2 INTEGER, col_str2 STRING)'
13
13
  end
14
- File.open('/seed/20150305_154010_test_seed.sql', 'w') do |f|
14
+ File.open('/seeds/20150305_154010_test_seed.sql', 'w') do |f|
15
15
  f.puts 'INSERT INTO first_test_table(col_int1, col_str1) VALUES(123, "test_string1")'
16
16
  f.puts 'INSERT INTO second_test_table(col_int2, col_str2) VALUES(456, "test_string2")'
17
17
  end
18
- File.open('/fixtures/20150305_154010_test_test_seed', 'w') do |f|
18
+ File.open('/fixtures/20150518_154012_test_fixture.sql', 'w') do |f|
19
19
  f.puts 'INSERT INTO first_test2_table(col_int1, col_str1) VALUES(2123, "2test_string1")'
20
20
  f.puts 'INSERT INTO second_test2_table(col_int2, col_str2) VALUES(2456, "2test_string2")'
21
21
  end
@@ -39,6 +39,7 @@ describe 'sql scripts' do
39
39
  "Migration second_test_migration for `default` database, datetime: 20150305154011\n" \
40
40
  "Migration default_db_test2_migration for `default` database, datetime: 20150511144100\n" \
41
41
  "Seed data test_seed for `default` database, datetime: 20150305154010\n" \
42
+ "Fixture test_fixture for `default` database, datetime: 20150518154012\n" \
42
43
  "Migration second_db_test_migration for `test2_db` database, datetime: 20150511144000\n"
43
44
  ).to_stdout
44
45
  end
@@ -1,5 +1,8 @@
1
1
  require 'bundler/setup'
2
2
  require 'memfs'
3
+ require 'simplecov'
4
+
5
+ SimpleCov.start
3
6
  Bundler.require
4
7
 
5
8
  RSpec.configure do |config|
@@ -13,9 +16,11 @@ RSpec.configure do |config|
13
16
  MemFs.activate!
14
17
  # Reset configuration for every test suite
15
18
  SqlMigrations::Config.instance_eval('@databases = nil; @options = nil')
19
+ @stdout, $stdout = $stdout, StringIO.new # Catch STDOUT do variable
16
20
  end
17
21
 
18
22
  config.after do
23
+ $stdout, @stdout = @stdout, nil # Reassign STDOUT
19
24
  MemFs.deactivate!
20
25
  end
21
26
  end
@@ -22,8 +22,9 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency 'sqlite3', '~> 1.3.10'
23
23
  spec.add_development_dependency 'memfs', '~> 0.4.3'
24
24
  spec.add_development_dependency 'rubocop', '~> 0.31.0'
25
+ spec.add_development_dependency 'simplecov', '~> 0.10.0'
25
26
  spec.add_dependency 'bundler', '~> 1.7'
26
27
  spec.add_dependency 'rake', '~> 10.0'
27
- spec.add_dependency 'sequel', '~> 4.19.0'
28
+ spec.add_dependency 'sequel', '~> 4.22.0'
28
29
  # rubocop:enable Style/SingleSpaceBeforeFirstArg
29
30
  end
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.1.0
4
+ version: 2.1.1
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-05-14 00:00:00.000000000 Z
11
+ date: 2015-05-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 0.31.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.10.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.10.0
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: bundler
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +114,14 @@ dependencies:
100
114
  requirements:
101
115
  - - "~>"
102
116
  - !ruby/object:Gem::Version
103
- version: 4.19.0
117
+ version: 4.22.0
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
122
  - - "~>"
109
123
  - !ruby/object:Gem::Version
110
- version: 4.19.0
124
+ version: 4.22.0
111
125
  description:
112
126
  email:
113
127
  - grzegorz.bizon@ntsn.pl
@@ -137,10 +151,12 @@ files:
137
151
  - lib/sql_migrations/tasks/seed_test.rake
138
152
  - lib/sql_migrations/version.rb
139
153
  - spec/features/config_spec.rb
154
+ - spec/features/fixture_spec.rb
140
155
  - spec/features/migration_multistatement_spec.rb
141
156
  - spec/features/migration_order_spec.rb
142
157
  - spec/features/migration_spec.rb
143
158
  - spec/features/schema_table_spec.rb
159
+ - spec/features/seed_spec.rb
144
160
  - spec/features/sql_scripts_spec.rb
145
161
  - spec/spec_helper.rb
146
162
  - sql_migrations.gemspec
@@ -170,10 +186,12 @@ specification_version: 4
170
186
  summary: Simple standalone migrations you can use with plain SQL
171
187
  test_files:
172
188
  - spec/features/config_spec.rb
189
+ - spec/features/fixture_spec.rb
173
190
  - spec/features/migration_multistatement_spec.rb
174
191
  - spec/features/migration_order_spec.rb
175
192
  - spec/features/migration_spec.rb
176
193
  - spec/features/schema_table_spec.rb
194
+ - spec/features/seed_spec.rb
177
195
  - spec/features/sql_scripts_spec.rb
178
196
  - spec/spec_helper.rb
179
197
  has_rdoc: