diff --git a/bin/entrypoint b/bin/entrypoint index e6d53a9..e46c5df 100755 --- a/bin/entrypoint +++ b/bin/entrypoint @@ -24,9 +24,7 @@ def run_database_seeds end def load_db - if Rails.env.production? && ENV['DEPLOY_NAME'] == 'production' - Municipality.count.zero? && (bundle exec rake 'data:load') - end + system('rails data:load') end set_given_or_default_command diff --git a/lib/tasks/data.rake b/lib/tasks/data.rake index ec99a9f..bb8d1b7 100644 --- a/lib/tasks/data.rake +++ b/lib/tasks/data.rake @@ -8,8 +8,10 @@ namespace :data do desc 'Sync data batch' task load: %i[environment] do - load_db = LoadCsvToDatabase.new - load_db.on_load_progress { |message, _data| print_flush message } - load_db.perform! + if Rails.env.production? && ENV['DEPLOY_NAME'] == 'production' && Municipality.count.zero? + load_db = LoadCsvToDatabase.new + load_db.on_load_progress { |message, _data| print_flush message } + load_db.perform! + end end -end \ No newline at end of file +end