Class: Testimonials::Generators::TenantGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Testimonials::Generators::TenantGenerator
- Includes:
- ActiveRecord::Generators::Migration
- Defined in:
- lib/generators/testimonials/tenant/tenant_generator.rb
Overview
For apps that installed testimonials before multi-tenancy: adds the
nullable tenant column (and its indexes) to the three tables. A fresh
install already gets these via the install generator — run this one only
to upgrade an existing install. Additive and safe: existing rows keep a
nil tenant (the single global collection), so nothing changes until you
set config.tenant.
bin/rails generate testimonials:tenant && bin/rails db:migrate
Instance Method Summary collapse
Instance Method Details
#create_migration_file ⇒ Object
23 24 25 26 |
# File 'lib/generators/testimonials/tenant/tenant_generator.rb', line 23 def create_migration_file migration_template 'add_tenant_to_testimonials.rb.tt', 'db/migrate/add_tenant_to_testimonials.rb' end |
#post_install ⇒ Object
28 29 30 31 |
# File 'lib/generators/testimonials/tenant/tenant_generator.rb', line 28 def post_install say "\ntenant column queued. Run `rails db:migrate`, then set", :green say 'config.tenant in config/initializers/testimonials.rb to scope per tenant.' end |