From 665c5489f015f3e87e74f9abc1098e3544a98c84 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 3 Jun 2019 17:29:03 +0300 Subject: [PATCH] mina: allow running specified data_migration rake task in deploy before db:migrate --- config/deploy-example.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/config/deploy-example.rb b/config/deploy-example.rb index 536775727..a6f0d179b 100644 --- a/config/deploy-example.rb +++ b/config/deploy-example.rb @@ -222,6 +222,7 @@ task deploy: :environment do invoke :'deploy:link_shared_paths' invoke :'bundle:install' + invoke :'data_migration' invoke :'rails:db_migrate' invoke :'rails:assets_precompile' to :launch do @@ -232,6 +233,18 @@ task deploy: :environment do end end +# data_migrate=some_data_migration mina deploy env +desc 'Run data migrations if any set with ENV[data_migrate]' +task data_migration: :environment do + if ENV['data_migrate'] + queue! %(echo "Running data migration #{ENV['data_migrate']}") + queue! %[cd #{current}] + queue! %[bundle exec rake data_migrations:#{ENV['data_migrate']} RAILS_ENV=#{rails_env}] + else + puts "No data migration specified" + end +end + desc 'Loads current commit hash' task load_commit_hash: :environment do queue! %(