Feature #36933 » 0001-In-production-mode-check-for-pending-migration-on-bo.patch
| config/additional_environment.rb.example | ||
|---|---|---|
| 13 | 13 |
# # set up external systems like Sidekiq and Redis. |
| 14 | 14 |
# config.active_job.queue_adapter = :inline |
| 15 | 15 |
# |
| 16 |
# Halt boot if there are pending migrations |
|
| 17 |
# config.redmine_halt_on_pending_migrations = true |
|
| 16 | 18 |
# ... |
| 17 | 19 |
# |
| 18 | 20 | |
| config/application.rb | ||
|---|---|---|
| 107 | 107 |
:same_site => :lax |
| 108 | 108 |
) |
| 109 | 109 | |
| 110 |
# Configure redmine_halt_on_pending_migrations only for production so that additional environment file |
|
| 111 |
# can change it (environments/ENV.rb would take precedence over it) |
|
| 112 |
config.redmine_halt_on_pending_migrations = false if Rails.env.production? |
|
| 113 | ||
| 110 | 114 |
if File.exist?(File.join(File.dirname(__FILE__), 'additional_environment.rb')) |
| 111 | 115 |
instance_eval File.read(File.join(File.dirname(__FILE__), 'additional_environment.rb')) |
| 112 | 116 |
end |
| config/initializers/05-check_pending_migrations.rb | ||
|---|---|---|
| 1 |
if Rails.env.production? && (defined?(Rails::Server) || defined?(Rails::Console)) |
|
| 2 |
begin |
|
| 3 |
ActiveRecord::Migration.check_all_pending! |
|
| 4 | ||
| 5 |
rescue ActiveRecord::PendingMigrationError |
|
| 6 |
if Rails.configuration.redmine_halt_on_pending_migrations |
|
| 7 |
error_message = "\e[31m[HALT] Pending migrations found. Boot process is stopping.\e[0m" |
|
| 8 | ||
| 9 |
puts "\n#{'=' * 60}\n"
|
|
| 10 |
puts error_message |
|
| 11 |
puts "Please run `bundle exec rake db:migrate` to apply migrations." |
|
| 12 |
puts "#{'=' * 60}\n\n"
|
|
| 13 | ||
| 14 |
# Abort the process with a non-zero exit code to indicate failure. |
|
| 15 |
abort |
|
| 16 |
else |
|
| 17 |
warning_message = "\e[33m[WARNING] You have pending migrations. Run `bundle exec rake db:migrate` to apply them.\e[0m" |
|
| 18 | ||
| 19 |
puts "\n#{'=' * 60}\n"
|
|
| 20 |
puts warning_message |
|
| 21 |
puts "#{'=' * 60}\n\n"
|
|
| 22 |
end |
|
| 23 |
end |
|
| 24 |
end |
|
- « Previous
- 1
- 2
- Next »