ae_check_migrations_load_silently 0.0.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +20 -0
- data/ae_check_migrations_load_silently.gemspec +23 -0
- data/lib/ae_check_migrations_load_silently/version.rb +5 -0
- data/lib/ae_check_migrations_load_silently.rb +46 -45
- metadata +47 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d80a2f0567fb52e873f2b9f700d25f3232a2fea0f654b6dc7e236a5aaa189184
|
4
|
+
data.tar.gz: 53d1061e8f0e2e45a6b05a14770e071aa46dabc12fec555efae0fa333d800181
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
@@ -1,55 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
|
2
3
|
require 'active_record'
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
).
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
32
|
+
private
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
8
|
-
autorequire:
|
7
|
+
- AppFolio
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
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: '
|
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: '
|
27
|
-
|
28
|
-
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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:
|
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.
|
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: []
|