Sha256: 04d32e12e35a28c8ab26809532741a83b551b8a2c3eb58ec7a8619e0ef7e0027

Contents?: true

Size: 917 Bytes

Versions: 7

Compression:

Stored size: 917 Bytes

Contents

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

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

    option :name, aliases: '-n', type: :string, desc: "Index name"
    option :options, aliases: '-o', type: :hash, default: {}, enum: %w[unique length where using type], desc: "Index options"
    desc "index [TABLE] *[COLUMNS]", "Adds an index".colorize(:grey)
    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
  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-index.rb
eucalypt-0.2.1 lib/eucalypt/eucalypt-migration/namespaces/migration-add/cli/add-index.rb
eucalypt-0.2.0 lib/eucalypt/eucalypt-migration/namespaces/migration-add/cli/add-index.rb
eucalypt-0.1.3 lib/eucalypt/eucalypt-migration/namespaces/migration-add/cli/add-index.rb
eucalypt-0.1.2 lib/eucalypt/eucalypt-migration/namespaces/migration-add/cli/add-index.rb
eucalypt-0.1.1 lib/eucalypt/eucalypt-migration/namespaces/migration-add/cli/add-index.rb
eucalypt-0.1.0 lib/eucalypt/eucalypt-migration/namespaces/migration-add/cli/add-index.rb