Class: Migflow::Services::ScopedMigrationWarnings
- Inherits:
-
Object
- Object
- Migflow::Services::ScopedMigrationWarnings
- Defined in:
- lib/migflow/services/scoped_migration_warnings.rb
Constant Summary collapse
- MIGRATION_LEVEL_RULES =
%w[ dangerous_migration_rule null_column_without_default_rule ].freeze
- NOOP_INFO_RULE =
"no_schema_change_migration_rule"
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(snapshot:, migration:, diff: nil) ⇒ ScopedMigrationWarnings
constructor
A new instance of ScopedMigrationWarnings.
Constructor Details
#initialize(snapshot:, migration:, diff: nil) ⇒ ScopedMigrationWarnings
Returns a new instance of ScopedMigrationWarnings.
21 22 23 24 25 |
# File 'lib/migflow/services/scoped_migration_warnings.rb', line 21 def initialize(snapshot:, migration:, diff: nil) @snapshot = snapshot @migration = migration @diff = diff end |
Class Method Details
.call(snapshot:, migration:, diff: nil) ⇒ Object
17 18 19 |
# File 'lib/migflow/services/scoped_migration_warnings.rb', line 17 def self.call(snapshot:, migration:, diff: nil) new(snapshot: snapshot, migration: migration, diff: diff).call end |
Instance Method Details
#call ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/migflow/services/scoped_migration_warnings.rb', line 27 def call warnings = Analyzers::AuditAnalyzer.call(snapshot: @snapshot, raw_migrations: [@migration]) touched_tables = TouchedTablesFromMigration.call(raw_content: @migration[:raw_content]) if touched_tables.empty? result = warnings.select { migration_level_warning?(_1) } result << noop_migration_warning if noop_migration?(@migration[:raw_content].to_s) return result end warnings.select do |warning| migration_level_warning?(warning) || relevant_schema_warning?(warning, touched_tables) end end |