Class: OkComputer::ActiveRecordMigrationsCheck
- Defined in:
- lib/ok_computer/built_in_checks/active_record_migrations_check.rb
Constant Summary
Constants inherited from Check
Instance Attribute Summary
Attributes inherited from Check
#failure_occurred, #message, #registrant_name, #time
Instance Method Summary collapse
-
#check ⇒ Object
Public: Check if migrations are pending or not.
- #needs_migration? ⇒ Boolean
- #supported? ⇒ Boolean
Methods inherited from Check
#<=>, #clear, #mark_failure, #mark_message, #run, #success?, #to_json, #to_text, #with_benchmarking
Instance Method Details
#check ⇒ Object
Public: Check if migrations are pending or not
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/ok_computer/built_in_checks/active_record_migrations_check.rb', line 4 def check return unsupported unless supported? if needs_migration? mark_failure "Pending migrations" else "NO pending migrations" end end |
#needs_migration? ⇒ Boolean
15 16 17 18 19 20 21 |
# File 'lib/ok_computer/built_in_checks/active_record_migrations_check.rb', line 15 def needs_migration? if ActiveRecord::Migrator.respond_to?(:needs_migration?) # Rails <= 5.1 ActiveRecord::Migrator.needs_migration? else # Rails >= 5.2 ActiveRecord::Base.connection.migration_context.needs_migration? end end |
#supported? ⇒ Boolean
23 24 25 26 27 |
# File 'lib/ok_computer/built_in_checks/active_record_migrations_check.rb', line 23 def supported? ActiveRecord::Migrator.respond_to?(:needs_migration?) || (ActiveRecord::Base.connection.respond_to?(:migration_context) && ActiveRecord::Base.connection.migration_context.respond_to?(:needs_migration?)) end |