Class: Metka::Generators::Strategies::TableGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Metka::Generators::SqlIdentifier, Rails::Generators::Migration
Defined in:
lib/generators/metka/strategies/table/table_generator.rb

Overview

:nodoc:

Constant Summary collapse

DEFAULT_SOURCE_COLUMNS =
[ "tags" ].freeze

Constants included from Metka::Generators::SqlIdentifier

Metka::Generators::SqlIdentifier::IDENTIFIER

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dir) ⇒ Object



85
86
87
# File 'lib/generators/metka/strategies/table/table_generator.rb', line 85

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

Instance Method Details

#generate_migrationObject



36
37
38
39
40
41
42
43
44
# File 'lib/generators/metka/strategies/table/table_generator.rb', line 36

def generate_migration
  validate_sql_identifiers!(
    "--source-table-name" => [ source_table_name ],
    "--source-columns" => source_columns,
    "--table-name" => Array(options[:table_name])
  )

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