Sha256: d471951eaf963b2b49e37902d49c4629dd040e0ddb93b54116b34a7528aa1bf1

Contents?: true

Size: 927 Bytes

Versions: 7

Compression:

Stored size: 927 Bytes

Contents

require 'eucalypt/eucalypt-migration/namespaces/migration-add/generators/column'
require 'eucalypt/app'
require 'eucalypt/errors'
require 'eucalypt/helpers'

module Eucalypt
  class MigrationAdd < Thor
    include Eucalypt::Helpers
    using Colorize

    option :options, aliases: '-o', type: :hash, default: {}, enum: %w[limit default null precision scale], desc: "Column options"
    desc "column [TABLE] [COLUMN] [TYPE]", "Adds a column".colorize(:grey)
    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
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
eucalypt-0.2.2 lib/eucalypt/eucalypt-migration/namespaces/migration-add/cli/add-column.rb
eucalypt-0.2.1 lib/eucalypt/eucalypt-migration/namespaces/migration-add/cli/add-column.rb
eucalypt-0.2.0 lib/eucalypt/eucalypt-migration/namespaces/migration-add/cli/add-column.rb
eucalypt-0.1.3 lib/eucalypt/eucalypt-migration/namespaces/migration-add/cli/add-column.rb
eucalypt-0.1.2 lib/eucalypt/eucalypt-migration/namespaces/migration-add/cli/add-column.rb
eucalypt-0.1.1 lib/eucalypt/eucalypt-migration/namespaces/migration-add/cli/add-column.rb
eucalypt-0.1.0 lib/eucalypt/eucalypt-migration/namespaces/migration-add/cli/add-column.rb