Class: Danger::MigrationsAlone

Inherits:
Plugin
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/danger-migrations/migrations_alone.rb

Constant Summary collapse

MIGRATION_DEPENDENT_PATTERNS =
T.let([%r(ar_doc/), %r(db/), %r(\Agems/.*/spec/dummy/db/)].freeze, T::Array[Regexp])
ALLOWED_FOLDERS =
T.let([%r(\Aspec/), %r(\Apacks/.*/spec/), %r(\Agems/.*/spec/), %r(\Asorbet/rails-rbi/), %r(\Asorbet/rbi/dsl/)].freeze, T::Array[Regexp])

Instance Method Summary collapse

Instance Method Details

#checkObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/danger-migrations/migrations_alone.rb', line 15

def check
  return if new_migrations.empty?

  disallowed_changed_files = find_disallowed_changed_files
  if disallowed_changed_files.any?
    file_list = (files - disallowed_changed_files).map { |path| "<li>#{path}</li>" }.join("\n")
    disallowed_files = disallowed_changed_files.map { |path| "<li>#{path}</li>" }.join("\n")

    message = <<~MESSAGE
      <b>Migrations must be checked in alone.</b>
      To ensure application code is not dependent on database migrations taking place
      during the deploys, <i>please separate the schema change along with migration files into a dedicated PR:</i>
      <ul>
        #{file_list}
      </ul>

      <b>List of disallowed files</b>
      <ul>
        #{disallowed_files}
      </ul>
      <a href='https://confluence.gustocorp.com/display/BE/Database+Schema+Migrations+in+Hawaiian+Ice'>More information</a>
    MESSAGE

    fail message
  end
end