sql_migrations 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sql_migrations/script.rb +4 -6
- data/lib/sql_migrations/version.rb +1 -1
- data/spec/features/migration_spec.rb +14 -0
- data/spec/spec_helper.rb +4 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1ada137d424bcf2634439ef471c2ee95f247f259
|
4
|
+
data.tar.gz: f2f5d71624ea736656e769de54b1951af85584b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb26ec32629ec6be55b5f8dffe891eb1b6e8fbcc16dd2ca377446f7a960fb38be7eb67575d4c6ef578f9879738e92531d4c21e28222b7738d751710716db3133
|
7
|
+
data.tar.gz: e31cebe15689bcd123f6aa1cd3224440b1932d3303df2437a6b28ae15fe5a4d9e1338df841479e74de4d03dffc9fc72e6530b9d27b7074a1aaeeacdca2ffe1d8
|
@@ -73,17 +73,15 @@ module SqlMigrations
|
|
73
73
|
last = history.order(Sequel.asc(:time)).where(type: @type).last
|
74
74
|
is_new = history.where(time: @datetime, type: @type).count == 0
|
75
75
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
end
|
80
|
-
end
|
76
|
+
puts "[!] #{self} datetime BEFORE last one executed !" if
|
77
|
+
is_new && last && last[:time] > @datetime
|
78
|
+
|
81
79
|
is_new
|
82
80
|
end
|
83
81
|
|
84
82
|
def on_success
|
85
83
|
puts "[+] Successfully executed #{@type}, name: #{@name}"
|
86
|
-
puts "
|
84
|
+
puts " Info: #{self}"
|
87
85
|
puts " Benchmark: #{@benchmark}"
|
88
86
|
|
89
87
|
@database.history.insert(time: @datetime, name: @name,
|
@@ -36,6 +36,20 @@ describe 'migration' do
|
|
36
36
|
expect(@sqlite_db[:test_table].columns).to include(:col_str)
|
37
37
|
end
|
38
38
|
|
39
|
+
context 'migration datetime before last one' do
|
40
|
+
before do
|
41
|
+
subject.call
|
42
|
+
File.open('/migrations/20150201_200000_new_before_migration.sql', 'w') do |f|
|
43
|
+
f.puts 'CREATE TABLE before_table(col_int INTEGER, col_str STRING)'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should print warning' do
|
48
|
+
expect { subject.call }
|
49
|
+
.to output(/datetime BEFORE last one executed !/).to_stdout
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
39
53
|
context 'invalid migration' do
|
40
54
|
before do
|
41
55
|
File.open('/migrations/20150825_184010_invalid_migration.sql', 'w') do |f|
|
data/spec/spec_helper.rb
CHANGED
@@ -16,11 +16,13 @@ RSpec.configure do |config|
|
|
16
16
|
MemFs.activate!
|
17
17
|
# Reset configuration for every test suite
|
18
18
|
SqlMigrations::Config.instance_eval('@databases = nil; @options = nil')
|
19
|
-
@stdout, $stdout = $stdout, StringIO.new
|
19
|
+
@stdout, $stdout = $stdout, StringIO.new unless
|
20
|
+
ENV['SQLMIGRATIONS_DEBUG'] # Catch STDOUT do variable
|
20
21
|
end
|
21
22
|
|
22
23
|
config.after do
|
23
|
-
$stdout, @stdout = @stdout, nil
|
24
|
+
$stdout, @stdout = @stdout, nil unless
|
25
|
+
ENV['SQLMIGRATIONS_DEBUG'] # Reassign STDOUT
|
24
26
|
MemFs.deactivate!
|
25
27
|
end
|
26
28
|
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.
|
4
|
+
version: 2.5.0
|
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-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|