3

when doing rake db:migrate, I am getting this error:

Migrating alpha tenant One of the following schema(s) is invalid: "alpha" "public"

My apartment initializer configs:

require 'apartment/elevators/subdomain'
# require 'apartment/elevators/first_subdomain'

#
# Apartment Configuration
#
Apartment.configure do |config|

  config.tenant_names = YAML::load_file('./config/site-settings.yml').symbolize_keys

end 

# Rails.application.config.middleware.use 'Apartment::Elevators::Domain'
Rails.application.config.middleware.use 'Apartment::Elevators::Subdomain'
Ahmad F
  • 30,560
  • 17
  • 97
  • 143
Jaswinder
  • 1,455
  • 14
  • 27

2 Answers2

1

I ran into the same issue, and the solution here helped me

I simply added an after_create callback called create_tenant to the model of the subdomain for my multi-tenant, which is user.rb in app/models/user.rb

Find below a link on Stackoverflow for the detailed answer https://stackoverflow.com/a/57771338/10907864

Jessica Fav
  • 103
  • 6
0

I had the same issue and I solved it by:

  1. logging into Postgres CLI: sudo -u postgres psql
  2. then connecting to the right database: \c databasename; (to view all existing databases, run: \l+)
  3. viewing all existing schemas: \dn+;
  4. After realizing that the schema in question was wrongly named (it had an extra underscore, while the name of the tenant didn't have it), I altered the schema as necessary: ALTER SCHEMA old_name RENAME TO new_name

After this, everything got back to normal.