ae_check_migrations_load_silently 0.0.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ae_check_migrations_load_silently.rb +45 -46
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dc4d7a9b05b8695db3c4e8b3f0c18f613118a12fa05582dbb0c1dff89930008
|
4
|
+
data.tar.gz: 68c46a66187aced0398e012a23c61344d886e9cf298b0645be794012d1163dde
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6baba3f5190ebbe9dea450d9cc9059dd80166867e35ffc6e574e6616c201f1a71d77649fae5c8f8418a263f0f0ec57c12c52c1cb278942e528f92ca417146e0a
|
7
|
+
data.tar.gz: 26fadec1e587076366e2f01563d4f1ad348c45fc2e2a41d813de312f7aa2b57deedc200716ad5e578f315fe534055a658f1bb47573e9fa5960015ac80ba2e7ae
|
@@ -1,55 +1,54 @@
|
|
1
|
-
|
2
1
|
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
|
2
|
+
require 'minitest'
|
3
|
+
|
4
|
+
module AeCheckMigrationsLoadSilently
|
5
|
+
include Minitest::Assertions
|
6
|
+
|
7
|
+
def check_all_migrations_load_silently
|
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
|
+
#{tables_modified.sort.join("\n")}
|
24
|
+
MSG
|
25
|
+
|
26
|
+
flunk error_message
|
29
27
|
end
|
28
|
+
end
|
30
29
|
|
31
|
-
|
30
|
+
private
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
32
|
+
def get_database_checksums
|
33
|
+
tables_sql = ActiveRecord::Base.connection.tables.sort.join(", ")
|
34
|
+
checksum_sql = "CHECKSUM TABLE #{tables_sql}"
|
35
|
+
ActiveRecord::Base.connection.execute(checksum_sql).to_a
|
36
|
+
end
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
38
|
+
def load_all_migrations
|
39
|
+
migrations_to_process = Dir['db/migrate/20*.rb']
|
40
|
+
migrations_to_process.each do |migration|
|
41
|
+
begin
|
42
|
+
load migration
|
43
|
+
rescue StandardError => e
|
44
|
+
msg = <<~MSG
|
45
|
+
#{self.class.name}: #{migration} failed to load. This is likely because the migration has code that is defined
|
46
|
+
on the top level class, instead of in a method.
|
47
|
+
#{e.message}
|
48
|
+
MSG
|
49
|
+
flunk msg
|
52
50
|
end
|
53
51
|
end
|
54
52
|
end
|
55
53
|
end
|
54
|
+
|
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Appfolio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|