Class: RailsAiBridge::Doctor::Checkers::MigrationsChecker

Inherits:
BaseChecker
  • Object
show all
Defined in:
lib/rails_ai_bridge/doctor/checkers/migrations_checker.rb

Overview

Verifies +db/migrate+ contains migration files.

Instance Attribute Summary

Attributes inherited from BaseChecker

#app

Instance Method Summary collapse

Methods inherited from BaseChecker

#initialize

Constructor Details

This class inherits a constructor from RailsAiBridge::Doctor::Checkers::BaseChecker

Instance Method Details

#callDoctor::Check

Returns +:pass+ when migrations exist; +:warn+ otherwise.

Returns:

  • (Doctor::Check)

    +:pass+ when migrations exist; +:warn+ otherwise



9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rails_ai_bridge/doctor/checkers/migrations_checker.rb', line 9

def call
  migrations_path = File.join(app.root, 'db/migrate', '*.rb')
  migrations = Dir.glob(migrations_path)

  check(
    'Migrations',
    migrations.any?,
    pass: { message: "#{migrations.size} migration files found" },
    fail: { status: :warn, message: 'No migrations found in db/migrate/',
            fix: 'Run `rails generate migration` to create one' }
  )
end