From 443bebf8caac3d5d4b102176a0419670e629bd88 Mon Sep 17 00:00:00 2001 From: Rui Baltazar Date: Mon, 1 Jun 2020 18:57:55 +0800 Subject: [PATCH] Excluding default schema from tasks --- lib/tasks/apartment.rake | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/tasks/apartment.rake b/lib/tasks/apartment.rake index d8353821..6af72b1e 100644 --- a/lib/tasks/apartment.rake +++ b/lib/tasks/apartment.rake @@ -121,11 +121,15 @@ apartment_namespace = namespace :apartment do end def each_tenant(&block) - Parallel.each(tenants, in_threads: Apartment.parallel_migration_threads) do |tenant| + Parallel.each(tenants_without_default, in_threads: Apartment.parallel_migration_threads) do |tenant| block.call(tenant) end end + def tenants_without_default + tenants - [Apartment.default_schema] + end + def tenants ENV['DB'] ? ENV['DB'].split(',').map(&:strip) : Apartment.tenant_names || [] end