1

I'm building a SAAS platform with heroku and Rails. For these, I'm managing the tenant with apartment gem.

In my local development this found without issues, but when I tried to use into heroku appear the next error:

/app/db/schema.rb doesn't exist yet

This error is produced it when run the next command:

Apartment::Tenant.create('foo_schema')

I'm going to write the main steps to setting up a heroku with subdomains + apartment configuration.

  1. Setting up a wildcard domain (This configuration it's ok).
  2. I'm using postgresql in production and development
  3. Setting up apartment.rb file into initializer directory.

my apartment.rb

require 'apartment/elevators/subdomain'

Apartment.configure do |config|
  config.excluded_models = %w{Account Company App Acteco Country Currency Price}
  config.tenant_names = lambda { Company.pluck(:slug) }
  config.use_schemas = true
end

Rails.application.config.middleware.insert_before Warden::Manager, Apartment::Elevators::Subdomain

Any suggestion ?

  • Did you try running db:migrate? there are some posts with the same issue which suggest to run this task as a workaround. https://www.reddit.com/r/rails/comments/2y4bdt/how_to_implement_tdd/ https://github.com/CartoDB/cartodb/issues/331 – Mauricio Mora Oct 10 '18 at 02:00
  • Do you have a working app currently on Heroku? Do you have the DB configured on Heroku? Have any migrations been run there? Are you deploying with `git push heroku master` ? – lacostenycoder Oct 10 '18 at 03:14

1 Answers1

5

Add db/schema.rb to your repository and push again?

hd1
  • 33,938
  • 5
  • 80
  • 91