OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
check migrations in initializer to speed up boot process
Markus Kahlc31bf728d08b
diff --git a/config/initializers/06-pending_migrations_check.rb b/config/initializers/06-pending_migrations_check.rbnew file mode 100644index 00000000000..0f1d90e9e56--- /dev/null+++ b/config/initializers/06-pending_migrations_check.rb@@ -0,0 +1,40 @@+#-- encoding: UTF-8++#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2012-2021 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See docs/COPYRIGHT.rdoc for more details.+#++++# We want to abort booting when there are missing migrations by default+# since it can lead to runtime schema cache issues.+# Refusing to boot will encourage admins to fix missing migrations.++exceptions = %w(db:create db:drop db:migrate db:structure:load db:schema:load)+is_console = Rails.const_defined? 'Console'++if Rails.env.production? && !is_console && (exceptions & ARGV).empty?+ ActiveRecord::Migration.check_pending! # will raise an exception and abort boot+enddiff --git a/docker/prod/migration_status b/docker/prod/migration_statusdeleted file mode 100755index 04a413aa421..00000000000--- a/docker/prod/migration_status+++ /dev/null@@ -1,4 +0,0 @@-#!/bin/bash -e--echo "Checking migration status..."-bundle exec rails runner 'ActiveRecord::Migration.check_pending!'diff --git a/docker/prod/web b/docker/prod/webindex 802f29a6292..92d70da0170 100755--- a/docker/prod/web+++ b/docker/prod/web@@ -15,8 +15,6 @@ fiif [ "$MIGRATE" = "true" ]; thenecho "Migrating database..."bundle exec rake db:migrate-else- $APP_PATH/docker/prod/migration_status # abort if there are pending migrationsfi# see `config/puma.rb` for configurationdiff --git a/docker/prod/worker b/docker/prod/workerindex 33783889fc0..bc4d194cbaa 100755--- a/docker/prod/worker+++ b/docker/prod/worker@@ -5,6 +5,4 @@ if [ "$1" = "--seed" ]; then$APP_PATH/docker/prod/seeder "$@"fi-$APP_PATH/docker/prod/migration_status # abort if there are pending migrations-QUIET=true bundle exec rake jobs:work