Open jean-francois-labbe opened 4 years ago
How are you able to use it with Rails 6? I installed the gem but then the application crashed and I can't even run the apartment generator
@cristianrosu this repo is no more maintained. You need to use this one now.
Use gem 'ros-apartment', require: 'apartment'
in your Gemfile and it should be working
Ps: If you're working on a new project, you may think twice before use this gem, it may not be the best solution, if you have a lot of tenants, as the creators themselves explain here.
I use it with Postgresql schemas and few tenants, it's working great.
@jean-francois-labbe I was not aware of that fork, thanks a lot, looks promising!
I won't have many tenants but it's important to separate data per account. It will work good for now. Thanks!
Above link is dead, working link is here: https://medium.com/infinite-monkeys/our-multi-tenancy-journey-with-postgres-schemas-and-apartment-6ecda151a21f
Steps to reproduce
I'm trying to use apartment with rails 6.1.alpha (rails-master) tests are failing and I don't understand the issue yet.
The error is:
When I try to debug the application the only difference I see between rails-6.0 and rails-master is during migrations
With Rails-6.0 it executes:
with Rails-6.1.alpha (master) it executes:
That would justify the error, but I don't understand why it doesn't create the schema_migrations database
use_schemas
:true
During tests 2 dbs are created, the first one is perfectly created, but the second one is missing the tables
schema_migrations
andar_internal_metadata
.After some debugging here is what I found.
This is the sql log of the first database creation. It is here just to ease comparison between the two dbs creation.
Second db is where troubles are.
create_table
is defined in schema_migration.rbtable_exists?
implementation is in model_schema.rbIn rails 6.0 schema_migration.rb had a method table_exists? defined in it, the implementation was:
It was removed in this commit https://github.com/rails/rails/commit/c5ecc338e863e771adcbcd87d5c23ae5e7ca7894#diff-a15c218db8b9dd9f84a75d9a3894db56