You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make a engine and add the following lets call it Project
Add the following to its lib/project/engine.rb:
class Engine < ::Rails::Engine
isolate_namespace Project
initializer :append_migrations do |app|
unless app.root.to_s.match root.to_s
config.paths["db/migrate"].expanded.each do |expanded_path|
app.config.paths["db/migrate"] << expanded_path
end
end
end
end
end
Add some models in the rails engine e.g. User
now put the rails engine in your Gemfile and do a bundle install
and Add the following to your appartment.rb initializer:
project_models = Project.constants.map{|c| Project.const_get(c) }.select do |const|
const.class == Class && const < ActiveRecord::Base
end
config.excluded_models = project_models
Expected behavior
The migration for Project::User is run once and located in the public search path
Actual behavior
The migration for Project::User located in the public search path but run for every tenant, so you get this error: PG::DuplicateTable: ERROR: relation "project_users" already exists
System configuration
Database: Postgres 11.2
Apartment version: Newest from development branch
Apartment config (in config/initializers/apartment.rb or so):
use_schemas: (true or false): true
Rails (or ActiveRecord) version: 6.0.2.1
Ruby version: 2.3
The text was updated successfully, but these errors were encountered:
Steps to reproduce
Make a engine and add the following lets call it Project
Add the following to its lib/project/engine.rb:
Add some models in the rails engine e.g. User
now put the rails engine in your Gemfile and do a bundle install
and Add the following to your appartment.rb initializer:
Expected behavior
The migration for Project::User is run once and located in the public search path
Actual behavior
The migration for Project::User located in the public search path but run for every tenant, so you get this error: PG::DuplicateTable: ERROR: relation "project_users" already exists
System configuration
Database: Postgres 11.2
Apartment version: Newest from development branch
Apartment config (in
config/initializers/apartment.rb
or so):use_schemas
: (true
orfalse
): trueRails (or ActiveRecord) version: 6.0.2.1
Ruby version: 2.3
The text was updated successfully, but these errors were encountered: