Module: AeCheckMigrationsLoadSilently

Includes:
Minitest::Assertions
Defined in:
lib/ae_check_migrations_load_silently.rb,
lib/ae_check_migrations_load_silently/version.rb

Constant Summary collapse

VERSION =
'1.3.0'

Instance Method Summary collapse

Instance Method Details

#check_all_migrations_load_silentlyObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/ae_check_migrations_load_silently.rb', line 9

def check_all_migrations_load_silently
  before_checksums = get_database_checksums
  load_all_migrations
  after_checksums = get_database_checksums

  tables_modified = (
  (before_checksums - after_checksums).map(&:first) +
    (after_checksums - before_checksums).map(&:first)
  ).uniq

  if tables_modified.present?
    error_message = <<~MSG
      The following tables were modified when the migration classes were
      loaded. This is not compatible with our release process. This is likely
      because the migration has database modifying code on the
      class rather than inside a method.
      #{tables_modified.sort.join("\n")}
    MSG

    flunk error_message
  end
end