FIX: Don't optimize icons during db:migrate when restoring backup

Uploads are extracted after the DB migration, so this could lead to a failure during the restore. Site icons get optimized after extracting uploads.
This commit is contained in:
Gerhard Schlager 2020-03-04 16:57:16 +01:00
parent 5c581b475a
commit 8fa8bab9ff
3 changed files with 3 additions and 2 deletions

View File

@ -134,7 +134,7 @@ module BackupRestore
log "Migrating the database..." log "Migrating the database..."
log Discourse::Utils.execute_command( log Discourse::Utils.execute_command(
{ "SKIP_POST_DEPLOYMENT_MIGRATIONS" => "0" }, { "SKIP_POST_DEPLOYMENT_MIGRATIONS" => "0", "SKIP_OPTIMIZE_ICONS" => "1" },
"rake db:migrate", "rake db:migrate",
failure_message: "Failed to migrate database.", failure_message: "Failed to migrate database.",
chdir: Rails.root chdir: Rails.root

View File

@ -77,7 +77,7 @@ task 'db:migrate' => ['load_config', 'environment', 'set_locale'] do |_, args|
SeedFu.seed(DiscoursePluginRegistry.seed_paths) SeedFu.seed(DiscoursePluginRegistry.seed_paths)
if !Discourse.skip_post_deployment_migrations? if !Discourse.skip_post_deployment_migrations? && ENV['SKIP_OPTIMIZE_ICONS'] != '1'
puts puts
print "Optimizing site icons... " print "Optimizing site icons... "
SiteIconManager.ensure_optimized! SiteIconManager.ensure_optimized!

View File

@ -37,6 +37,7 @@ describe BackupRestore::DatabaseRestorer do
def expect_db_migrate def expect_db_migrate
Discourse::Utils.expects(:execute_command).with do |env, command, options| Discourse::Utils.expects(:execute_command).with do |env, command, options|
env["SKIP_POST_DEPLOYMENT_MIGRATIONS"] == "0" && env["SKIP_POST_DEPLOYMENT_MIGRATIONS"] == "0" &&
env["SKIP_OPTIMIZE_ICONS"] == "1" &&
command == "rake db:migrate" && command == "rake db:migrate" &&
options[:chdir] == Rails.root options[:chdir] == Rails.root
end.once end.once