pronto-rails_migrations 0.10.0 → 0.10.1

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
  SHA256:
3
- metadata.gz: c14def6d1a703c9074387da0c4398291c423d1094cb2a47772fc6da38772962b
4
- data.tar.gz: 57bd0237d5f8bc2c66386afbaaca71be7bb8aca1e7c292008f1c62245558c939
3
+ metadata.gz: 8759567be612ea98f5a55432236144a570fb0d577a94669a97544b214e21cd56
4
+ data.tar.gz: 70de473bffef3c43636888990c98c4d7089d09a7b7afc88dc1ecb97ffda11a39
5
5
  SHA512:
6
- metadata.gz: 5d1f9576333d4384d6b9c4604effe89df5d760ffe5bf023fa71615d84e277692c525df86826eb37afbefe09df997d93291d39b8e162bf669153da9dd4117f6ab
7
- data.tar.gz: da86a5d3346f79af9cd556f93974b3f8e3138477a770ec9b79f2192732f19a218ea3a46902b47a316004699084748b3b89206f4f4a4df418b53ff29a40331fbf
6
+ metadata.gz: 0b8298cff6bffcbe03b1d9dbe07e7927bca866dbfebb879a793da4c141ebf04ace7d11b6a5da506d2747368292de7c64a42cb81305f5199feb73832d756f1f25
7
+ data.tar.gz: 80a5db5dd0a0f7f6abee5724902142179b5104ff49c13eaf4c7ab8ce02e13e63c0dd6499ff597ec9aa316af467aa615803eb718df8a51f1529029b7201a533ca
@@ -0,0 +1 @@
1
+ 2.6.3
@@ -1,20 +1,19 @@
1
1
  module Pronto
2
2
  class RailsMigrations < Runner
3
3
  def run
4
- if migration_patches? && other_patches?
5
- migration_patches.take(1).map do |patch|
6
- Message.new(
7
- patch.delta.new_file[:path],
8
- nil,
9
- :warning,
10
- "Run migrations in a separate PR from application code changes.",
11
- nil,
12
- self.class
13
- )
14
- end
15
- else
16
- []
4
+ return [] unless migration_patches?
5
+
6
+ messages = []
7
+
8
+ if other_patches?
9
+ patch = migration_patches.first
10
+ messages << message(
11
+ patch.delta.new_file[:path],
12
+ 'Run migrations in a separate PR from application code changes.'
13
+ )
17
14
  end
15
+
16
+ messages + bad_structure_sql_messages
18
17
  end
19
18
 
20
19
  private
@@ -31,6 +30,48 @@ module Pronto
31
30
  @patches.reject { |patch| migration_patch?(patch) }.any?
32
31
  end
33
32
 
33
+ def bad_structure_sql_messages
34
+ patch = structure_sql_patches.first
35
+ return false unless patch
36
+
37
+ path = patch.delta.new_file[:path]
38
+ structure_sql = File.read(patch.new_file_full_path)
39
+ inserts = structure_sql.split("\n").grep(/\('\d+'\)/)
40
+ unordered_inserts = (inserts.sort != inserts)
41
+
42
+ *all_but_tail, tail = inserts
43
+ bad_semicolons = all_but_tail.any? { |line| line.end_with?(';') } || !tail.end_with?(';')
44
+
45
+ bad_ending = structure_sql[-4, 4] !~ /[^\n]\n\n\n/
46
+
47
+ messages = []
48
+
49
+ if unordered_inserts
50
+ messages << message(
51
+ path,
52
+ '`schema_migrations` insert values are not ordered by timestamp.'
53
+ )
54
+ end
55
+ if bad_semicolons
56
+ messages << message(
57
+ path,
58
+ '`schema_migrations` inserts must end with comma (`,`), ' \
59
+ 'last insert must end with semicolon (`;`).'
60
+ )
61
+ end
62
+ messages << message(path, '`db/structure.sql` must end with 2 empty lines.') if bad_ending
63
+
64
+ messages
65
+ end
66
+
67
+ def message(path, text)
68
+ Message.new(path, nil, :warning, text, nil, self.class)
69
+ end
70
+
71
+ def structure_sql_patches
72
+ @patches.select { |patch| patch.new_file_full_path.to_s =~ /structure\.sql/ }
73
+ end
74
+
34
75
  def migration_patch?(patch)
35
76
  path = patch.new_file_full_path.to_s
36
77
  /db.(schema.rb|structure.sql|migrate)/ =~ path
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "pronto-rails_migrations"
7
- spec.version = '0.10.0'
7
+ spec.version = '0.10.1'
8
8
  spec.authors = ["Tomas Varneckas"]
9
9
  spec.email = ["t.varneckas@gmail.com"]
10
10
 
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_dependency('pronto', '~> 0.10.0')
23
+ spec.add_dependency('pronto', '>= 0.10.0')
24
24
 
25
25
  spec.add_development_dependency "bundler", ">= 1.15"
26
26
  spec.add_development_dependency "rake", "~> 12.0"
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pronto-rails_migrations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Varneckas
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-08 00:00:00.000000000 Z
11
+ date: 2020-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pronto
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.10.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.10.0
27
27
  - !ruby/object:Gem::Dependency
@@ -61,6 +61,7 @@ extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
63
  - ".gitignore"
64
+ - ".ruby-version"
64
65
  - Gemfile
65
66
  - LICENSE.txt
66
67
  - README.md