Class: Eucalypt::MigrationAdd

Inherits:
Thor
  • Object
show all
Extended by:
List
Includes:
Helpers, Thor::Actions
Defined in:
lib/eucalypt/migration/namespaces/migration-add/cli/add.rb,
lib/eucalypt/migration/namespaces/migration-add/cli/add-index.rb,
lib/eucalypt/migration/namespaces/migration-add/cli/add-column.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from List

help

Class Method Details



12
13
14
# File 'lib/eucalypt/migration/namespaces/migration-add/cli/add.rb', line 12

def self.banner(task, namespace = false, subcommand = true)
  "#{basename} migration #{task.formatted_usage(self, true, subcommand).split(':').join(' ')}"
end

Instance Method Details

#column(table, column, type) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/eucalypt/migration/namespaces/migration-add/cli/add-column.rb', line 13

def column(table, column, type)
  directory = File.expand_path('.')
  if Eucalypt.app? directory
    return unless Eucalypt::Helpers::Migration::Validation.valid_type? type
    migration = Eucalypt::Generators::Add::Column.new
    migration.destination_root = directory
    migration.generate(table: table, column: column, type: type, options: options[:options])
  else
    Eucalypt::Error.wrong_directory
  end
end

#index(table, *columns) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/eucalypt/migration/namespaces/migration-add/cli/add-index.rb', line 14

def index(table, *columns)
  directory = File.expand_path('.')
  if Eucalypt.app? directory
    migration = Eucalypt::Generators::Add::Index.new
    migration.destination_root = directory
    migration.generate(table: table, columns: columns, name: options[:name]||'index', options: options[:options])
  else
    Eucalypt::Error.wrong_directory
  end
end