Class: Metka::Generators::Strategies::IndexGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/metka/strategies/index/index_generator.rb

Overview

:nodoc:

Constant Summary collapse

DEFAULT_SOURCE_COLUMNS =
[ "tags" ].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dir) ⇒ Object



71
72
73
# File 'lib/generators/metka/strategies/index/index_generator.rb', line 71

def self.next_migration_number(dir)
  ::ActiveRecord::Generators::Base.next_migration_number(dir)
end

Instance Method Details

#generate_migrationObject



38
39
40
41
42
43
44
45
46
47
# File 'lib/generators/metka/strategies/index/index_generator.rb', line 38

def generate_migration
  unless sqlite?
    say_status :skipped,
      "the index strategy targets SQLite; PostgreSQL GIN indexes already serve tag queries",
      :yellow
    return
  end

  migration_template "migration.rb.erb", "db/migrate/#{migration_name}.rb"
end