ae_check_migrations_load_silently 0.0.0 → 1.0.0

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
  SHA256:
3
- metadata.gz: b76540091b20bf219a815f5ee7dde9272d4f8029435a36c0b3fd7294131e671f
4
- data.tar.gz: db2f412966f0b86194aff16b74d7e678a1dd48194de28cc1480c1fc27a9e26c5
3
+ metadata.gz: d80a2f0567fb52e873f2b9f700d25f3232a2fea0f654b6dc7e236a5aaa189184
4
+ data.tar.gz: 53d1061e8f0e2e45a6b05a14770e071aa46dabc12fec555efae0fa333d800181
5
5
  SHA512:
6
- metadata.gz: 63ed8730d210bf7a9f6666be23071767f21de6dbe0805f5d908bec64178ba0418edea1e33d0c107c7ff7aefe83f68955bd12dee6b0c236842098b3b8ab757e46
7
- data.tar.gz: b0afb5b34055d1b08ee1a19ebad5ab67214cd831037e9d57770b3611998124c1cb7b3393206002341eca3f8420c34aac86e23291954673b54f2da957d666a00c
6
+ metadata.gz: 2548ce477dda76555c83e33a8e11f49f509e8d3f60fad6f440726ee1194d28ca7cc3c8559710e270a7dcc7f06645330d96b21d7d25f9fd7f23ba6704b4460917
7
+ data.tar.gz: eb6e65ca0173736fd59d387ef9205fd7747f50e988463047b9c1f140d715eee87e057fa7a735cc3769b60101bf0f2265215d08632586c88ae1edf439aec06231
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2020-2022 AppFolio, Inc
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/ae_check_migrations_load_silently/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'ae_check_migrations_load_silently'
7
+ spec.version = AeCheckMigrationsLoadSilently::VERSION
8
+ spec.platform = Gem::Platform::RUBY
9
+ spec.author = 'AppFolio'
10
+ spec.email = 'opensource@appfolio.com'
11
+ spec.description = 'Check migrations do not affect database on load.'
12
+ spec.summary = spec.description
13
+ spec.homepage = 'https://github.com/appfolio/ae_check_migrations_load_silently'
14
+ spec.license = 'MIT'
15
+ spec.files = Dir['**/*'].select { |f| f[%r{^(lib/|LICENSE.txt|.*gemspec)}] }
16
+ spec.require_paths = ['lib']
17
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.6.3')
18
+
19
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
20
+
21
+ spec.add_dependency('activerecord', ['>= 6', '< 7.1'])
22
+ spec.add_dependency('minitest', ['>= 5.8', '< 6'])
23
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module AeCheckMigrationsLoadSilently
4
+ VERSION = '1.0.0'
5
+ end
@@ -1,55 +1,56 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  require 'active_record'
3
-
4
- class AeCheckMigrationsLoadSilently
5
- class << self
6
-
7
- def run
8
- before_checksums = get_database_checksums
9
- load_all_migrations
10
- after_checksums = get_database_checksums
11
-
12
- tables_modified = (
13
- (before_checksums - after_checksums).map(&:first) +
14
- (after_checksums - before_checksums).map(&:first)
15
- ).uniq
16
-
17
- if tables_modified.present?
18
- error_message = <<~MSG
19
- The following tables were modified when the migration classes were
20
- loaded. This is not compatable with our release process. This is likely
21
- because the migration has database modifiying code on the
22
- class rather than inside a method.
23
-
24
- #{tables_modified.sort.join("\n")}
25
- MSG
26
-
27
- flunk error_message
28
- end
4
+ require 'minitest'
5
+
6
+ module AeCheckMigrationsLoadSilently
7
+ include Minitest::Assertions
8
+
9
+ def check_all_migrations_load_silently
10
+ before_checksums = get_database_checksums
11
+ load_all_migrations
12
+ after_checksums = get_database_checksums
13
+
14
+ tables_modified = (
15
+ (before_checksums - after_checksums).map(&:first) +
16
+ (after_checksums - before_checksums).map(&:first)
17
+ ).uniq
18
+
19
+ if tables_modified.present?
20
+ error_message = <<~MSG
21
+ The following tables were modified when the migration classes were
22
+ loaded. This is not compatible with our release process. This is likely
23
+ because the migration has database modifying code on the
24
+ class rather than inside a method.
25
+ #{tables_modified.sort.join("\n")}
26
+ MSG
27
+
28
+ flunk error_message
29
29
  end
30
+ end
30
31
 
31
- private
32
+ private
32
33
 
33
- def get_database_checksums
34
- tables_sql = ActiveRecord::Base.connection.tables.sort.join(", ")
35
- checksum_sql = "CHECKSUM TABLE #{tables_sql}"
36
- ActiveRecord::Base.connection.execute(checksum_sql).to_a
37
- end
34
+ def get_database_checksums
35
+ tables_sql = ActiveRecord::Base.connection.tables.sort.join(", ")
36
+ checksum_sql = "CHECKSUM TABLE #{tables_sql}"
37
+ ActiveRecord::Base.connection.execute(checksum_sql).to_a
38
+ end
38
39
 
39
- def load_all_migrations
40
- migrations_to_process = Dir['db/migrate/20*.rb']
41
- migrations_to_process.each do |migration|
42
- begin
43
- load migration
44
- rescue StandardError => e
45
- msg = <<~MSG
46
- #{self.class.name}: #{migration} failed to load. This is likely because the migration has code that is defined
47
- on the top level class, instead of in a method.
48
- #{e.message}
49
- MSG
50
- flunk msg
51
- end
40
+ def load_all_migrations
41
+ migrations_to_process = Dir['db/migrate/20*.rb']
42
+ migrations_to_process.each do |migration|
43
+ begin
44
+ load migration
45
+ rescue StandardError => e
46
+ msg = <<~MSG
47
+ #{self.class.name}: #{migration} failed to load. This is likely because the migration has code that is defined
48
+ on the top level class, instead of in a method.
49
+ #{e.message}
50
+ MSG
51
+ flunk msg
52
52
  end
53
53
  end
54
54
  end
55
55
  end
56
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ae_check_migrations_load_silently
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Appfolio
8
- autorequire:
7
+ - AppFolio
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-12 00:00:00.000000000 Z
11
+ date: 2022-02-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,25 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '6'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '7.1'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '6'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '7.1'
33
+ - !ruby/object:Gem::Dependency
34
+ name: minitest
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '5.8'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '6'
20
43
  type: :runtime
21
44
  prerelease: false
22
45
  version_requirements: !ruby/object:Gem::Requirement
23
46
  requirements:
24
47
  - - ">="
25
48
  - !ruby/object:Gem::Version
26
- version: '0'
27
- description: Check migrations do not affect database on load
28
- email:
49
+ version: '5.8'
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '6'
53
+ description: Check migrations do not affect database on load.
54
+ email: opensource@appfolio.com
29
55
  executables: []
30
56
  extensions: []
31
57
  extra_rdoc_files: []
32
58
  files:
59
+ - LICENSE.txt
60
+ - ae_check_migrations_load_silently.gemspec
33
61
  - lib/ae_check_migrations_load_silently.rb
34
- homepage:
35
- licenses: []
36
- metadata: {}
37
- post_install_message:
62
+ - lib/ae_check_migrations_load_silently/version.rb
63
+ homepage: https://github.com/appfolio/ae_check_migrations_load_silently
64
+ licenses:
65
+ - MIT
66
+ metadata:
67
+ allowed_push_host: https://rubygems.org
68
+ post_install_message:
38
69
  rdoc_options: []
39
70
  require_paths:
40
71
  - lib
@@ -42,15 +73,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
42
73
  requirements:
43
74
  - - ">="
44
75
  - !ruby/object:Gem::Version
45
- version: '0'
76
+ version: 2.6.3
46
77
  required_rubygems_version: !ruby/object:Gem::Requirement
47
78
  requirements:
48
79
  - - ">="
49
80
  - !ruby/object:Gem::Version
50
81
  version: '0'
51
82
  requirements: []
52
- rubygems_version: 3.0.8
53
- signing_key:
83
+ rubygems_version: 3.1.4
84
+ signing_key:
54
85
  specification_version: 4
55
- summary: Check migrations do not affect database on load
86
+ summary: Check migrations do not affect database on load.
56
87
  test_files: []