diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-01-18 18:59:01 -0200 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-01-18 19:13:43 -0200 |
commit | 0105dbc84fc814ff61662ee402d8b35ae3fa8ab1 (patch) | |
tree | 1c4a11bfc1ae1c06fa354466479f67aa579d7d6b | |
parent | 1d5f96cf971d44a3c0f6ca650c755f820bfd74bb (diff) | |
download | gitlab-ce-warning-pending-migrations.tar.gz |
Warn users about pending migrations on development modewarning-pending-migrations
-rw-r--r-- | app/controllers/application_controller.rb | 7 | ||||
-rw-r--r-- | app/views/errors/pending_migration.html.haml | 5 |
2 files changed, 12 insertions, 0 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index bf99b2e777d..01dc23b6ed7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,6 +8,7 @@ class ApplicationController < ActionController::Base PER_PAGE = 20 + before_action :check_pending_migration! before_action :authenticate_user_from_token! before_action :authenticate_user! before_action :validate_user_service_ticket! @@ -41,6 +42,12 @@ class ApplicationController < ActionController::Base protected + def check_pending_migration! + if Rails.env.development? && ActiveRecord::Migrator.needs_migration? + render "errors/pending_migration", layout: "errors", status: 424 + end + end + # From https://github.com/plataformatec/devise/wiki/How-To:-Simple-Token-Authentication-Example # https://gist.github.com/josevalim/fb706b1e933ef01e4fb6 def authenticate_user_from_token! diff --git a/app/views/errors/pending_migration.html.haml b/app/views/errors/pending_migration.html.haml new file mode 100644 index 00000000000..783823d273e --- /dev/null +++ b/app/views/errors/pending_migration.html.haml @@ -0,0 +1,5 @@ +- page_title "Migrations are pending" +%h1 500 +%h3 Migrations are pending +%hr +%p To resolve, run: bin/rake db:migrate RAILS_ENV=#{Rails.env} |