Class: Ideasbugs::Generators::TenantGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ActiveRecord::Generators::Migration
Defined in:
lib/generators/ideasbugs/tenant/tenant_generator.rb

Overview

For apps that installed ideasbugs before multi-tenancy: adds the nullable tenant column (and its index) to ideasbugs_feedbacks. A fresh install already gets it 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 board), so nothing changes until you set config.tenant.

bin/rails generate ideasbugs:tenant && bin/rails db:migrate

Instance Method Summary collapse

Instance Method Details

#create_migration_fileObject



22
23
24
25
# File 'lib/generators/ideasbugs/tenant/tenant_generator.rb', line 22

def create_migration_file
  migration_template 'add_tenant_to_ideasbugs_feedbacks.rb.tt',
                     'db/migrate/add_tenant_to_ideasbugs_feedbacks.rb'
end

#post_installObject



27
28
29
30
# File 'lib/generators/ideasbugs/tenant/tenant_generator.rb', line 27

def post_install
  say "\ntenant column queued. Run `rails db:migrate`, then set", :green
  say 'config.tenant in config/initializers/ideasbugs.rb to scope per tenant.'
end