db6b700da8
Not removing anything, just organizing scripts into subdirectories to make it a bit more readable.
34 lines
840 B
Ruby
Executable File
34 lines
840 B
Ruby
Executable File
#!/usr/bin/env ruby
|
|
|
|
require_relative "../config/environment"
|
|
|
|
tenant_names = []
|
|
|
|
ApplicationRecord.with_each_tenant do |tenant|
|
|
next if tenant == "#{Rails.env}-tenant"
|
|
|
|
account = Account.sole
|
|
queenbee_id = account.queenbee_id
|
|
tenant_names << { from: tenant, to: queenbee_id }
|
|
|
|
ApplicationRecord.remove_connection
|
|
end
|
|
|
|
pp [ "Tenant name changes:", tenant_names ]
|
|
|
|
root_config = ApplicationRecord.tenanted_root_config
|
|
tenant_names.each do |name|
|
|
from_db_path = root_config.database_path_for(name[:from])
|
|
to_db_path = root_config.database_path_for(name[:to])
|
|
|
|
from_path = from_db_path.split("/").take(4).join("/")
|
|
to_path = to_db_path.split("/").take(4).join("/")
|
|
|
|
unless from_path == to_path
|
|
FileUtils.move from_path, to_path, verbose: true
|
|
end
|
|
end
|
|
|
|
puts
|
|
pp [ "Tenants after renaming:", ApplicationRecord.tenants ]
|