Sha256: 589e3a365a28a5e7fac82e418ebaf5aa6d8e6e02059c99f3bd771b39fff95c54
Contents?: true
Size: 762 Bytes
Versions: 3
Compression:
Stored size: 762 Bytes
Contents
require "rails/generators/active_record" class IndexGenerator < Rails::Generators::Base include ActiveRecord::Generators::Migration source_root File.join(__dir__, "templates") argument :table, type: :string argument :columns, type: :array def copy_migration migrate_path = ActiveRecord::Tasks::DatabaseTasks.migrations_paths.first migration_template "index_migration.rb", "#{migrate_path}/add_index_on_#{columns.join('_and_')}_to_#{table}.rb" end def migration_version "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]" end def table_str table.to_sym.inspect end def column_str if columns.size == 1 columns.first.to_sym.inspect else columns.map(&:to_sym).inspect end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
gindex-0.4.0 | lib/generators/index/index_generator.rb |
gindex-0.3.0 | lib/generators/index/index_generator.rb |
gindex-0.2.0 | lib/generators/index/index_generator.rb |