Class: Eucalypt::MigrationAdd
- Inherits:
-
Thor
- Object
- Thor
- Eucalypt::MigrationAdd
- 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
Class Method Details
.banner(task, namespace = false, subcommand = true) ⇒ Object
12 13 14 |
# File 'lib/eucalypt/migration/namespaces/migration-add/cli/add.rb', line 12 def self.(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.('.') 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]) 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.('.') if Eucalypt.app? directory migration = Eucalypt::Generators::Add::Index.new migration.destination_root = directory migration.generate(table: table, columns: columns, name: [:name]||'index', options: [:options]) else Eucalypt::Error.wrong_directory end end |