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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4cd2f64f3d6c5864d8a53ee00437de877d31c07d
4
- data.tar.gz: 3975b9223a91de17766cb2deb74c733de7717422
3
+ metadata.gz: 1ada137d424bcf2634439ef471c2ee95f247f259
4
+ data.tar.gz: f2f5d71624ea736656e769de54b1951af85584b9
5
5
  SHA512:
6
- metadata.gz: e24cc1c8994f34a3c6238a6a7b838a405e4f21c92964671c3b6554d774663df12a140125bc17214d4623aef2da55588c3b814ebe910208424dc11fd2b391701c
7
- data.tar.gz: 840fa00ad8010e4c9911328a05d53287660f3f7266598b5e91278eb215c9fea651ec928da23fdb04728766edf24bf848be225e8abc8c3ad8b80bf5016f08422a
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
- if is_new && !last.nil?
77
- if last[:time] > @datetime
78
- raise "#{@type.capitalize} #{@name} has time BEFORE last one recorded !"
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 " #{type.capitalize} file: #{@date}_#{@time}_#{@name}.sql"
84
+ puts " Info: #{self}"
87
85
  puts " Benchmark: #{@benchmark}"
88
86
 
89
87
  @database.history.insert(time: @datetime, name: @name,
@@ -1,5 +1,5 @@
1
1
  # SqlMigrations
2
2
  #
3
3
  module SqlMigrations
4
- VERSION = '2.4.0'
4
+ VERSION = '2.5.0'
5
5
  end
@@ -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 # Catch STDOUT do variable
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 # Reassign STDOUT
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.0
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-08-27 00:00:00.000000000 Z
11
+ date: 2015-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec