diff options
author | Gabriel Mazetto <brodock@gmail.com> | 2017-05-25 17:16:25 +0300 |
---|---|---|
committer | Gabriel Mazetto <brodock@gmail.com> | 2017-05-31 15:33:03 +0300 |
commit | 13e88c93956b5b350515b919ef7217a3dccf28ff (patch) | |
tree | 7ed964642da19c553697a7c737e11f55d058829e /lib/system_check/app/migrations_are_up_check.rb | |
parent | 45378bdd3aae75cb155677d91be61e3d39f5f515 (diff) |
Refactor gitlab:app:checks to use SystemCheck
Diffstat (limited to 'lib/system_check/app/migrations_are_up_check.rb')
-rw-r--r-- | lib/system_check/app/migrations_are_up_check.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/system_check/app/migrations_are_up_check.rb b/lib/system_check/app/migrations_are_up_check.rb new file mode 100644 index 00000000000..5eedbacce77 --- /dev/null +++ b/lib/system_check/app/migrations_are_up_check.rb @@ -0,0 +1,20 @@ +module SystemCheck + module App + class MigrationsAreUpCheck < SystemCheck::BaseCheck + set_name 'All migrations up?' + + def check? + migration_status, _ = Gitlab::Popen.popen(%w(bundle exec rake db:migrate:status)) + + migration_status !~ /down\s+\d{14}/ + end + + def show_error + try_fixing_it( + sudo_gitlab('bundle exec rake db:migrate RAILS_ENV=production') + ) + fix_and_rerun + end + end + end +end |