Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

excluded_models does not works with db:setup #664

Open
kuzukuzu opened this issue Feb 24, 2021 · 1 comment
Open

excluded_models does not works with db:setup #664

kuzukuzu opened this issue Feb 24, 2021 · 1 comment

Comments

@kuzukuzu
Copy link

Steps to reproduce

Configure excluded models.

Apartment.configure do |config|
  config.excluded_models = ["Company"]
end

db/seeds.rb is as below.

Company.create

Apartment::Tenant.create('some_tenant') do
  puts "companies: #{Company.count}"
end

And call db:setup. (assume that 'public' tenant does not exist)

rails db:setup

Outputs this.

companies: 0

Expected behavior

excluded_models have effect also in db:setup.

Actual behavior

excluded_models have no effect in db:setup.

System configuration

  • Database: mysql 5.6

  • Apartment version: 2.2.1

  • Apartment config (in config/initializers/apartment.rb or so):

    • use_schemas: default (true)
    • prepend_environment: true
  • Rails (or ActiveRecord) version: 5.2.4.5

  • Ruby version: 2.5.8

@kuzukuzu
Copy link
Author

kuzukuzu commented Feb 26, 2021

In my project, this resolves the problem.

class SomeApplication < Rails::Application
  rake_tasks do
    Rake::Task['db:create'].enhance do
      Apartment.connection_class.connection_pool.with_connection do
        Apartment::Tenant.init
      end
    end
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant