Sha256: fdb1268e9afb1ed8fe1607290091a236f0f946d17b0388bfafd436e3bd394f2f

Contents?: true

Size: 938 Bytes

Versions: 22

Compression:

Stored size: 938 Bytes

Contents

require 'eucalypt/migration/namespaces/migration-create/generators/table'
require 'eucalypt/app'
require 'eucalypt/errors'
require 'eucalypt/helpers'

module Eucalypt
  class MigrationCreate < Thor
    include Eucalypt::Helpers
    using Colorize
    option :options, aliases: '-o', type: :hash, default: {}, enum: %w[primary_key id temporary force], desc: "Table options"
    desc "table [NAME] *[COLUMN∶TYPE]", "Creates a table".colorize(:grey)
    def table(name, *columns)
      directory = File.expand_path('.')
      if Eucalypt.app? directory
        validation = Eucalypt::Helpers::Migration::Validation.new columns
        return if validation.any_invalid?
        migration = Eucalypt::Generators::Create::Table.new
        migration.destination_root = directory
        migration.generate(name: name, columns: columns, options: options[:options])
      else
        Eucalypt::Error.wrong_directory
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
eucalypt-0.9.0 lib/eucalypt/migration/namespaces/migration-create/cli/create-table.rb
eucalypt-0.8.0 lib/eucalypt/migration/namespaces/migration-create/cli/create-table.rb
eucalypt-0.7.2 lib/eucalypt/migration/namespaces/migration-create/cli/create-table.rb
eucalypt-0.7.1 lib/eucalypt/migration/namespaces/migration-create/cli/create-table.rb
eucalypt-0.7.0 lib/eucalypt/migration/namespaces/migration-create/cli/create-table.rb
eucalypt-0.6.2 lib/eucalypt/migration/namespaces/migration-create/cli/create-table.rb
eucalypt-0.6.1 lib/eucalypt/migration/namespaces/migration-create/cli/create-table.rb
eucalypt-0.6.0 lib/eucalypt/migration/namespaces/migration-create/cli/create-table.rb
eucalypt-0.5.4 lib/eucalypt/migration/namespaces/migration-create/cli/create-table.rb
eucalypt-0.5.3 lib/eucalypt/migration/namespaces/migration-create/cli/create-table.rb
eucalypt-0.5.2 lib/eucalypt/migration/namespaces/migration-create/cli/create-table.rb
eucalypt-0.5.1 lib/eucalypt/migration/namespaces/migration-create/cli/create-table.rb
eucalypt-0.5.0 lib/eucalypt/migration/namespaces/migration-create/cli/create-table.rb
eucalypt-0.4.2 lib/eucalypt/migration/namespaces/migration-create/cli/create-table.rb
eucalypt-0.4.1 lib/eucalypt/migration/namespaces/migration-create/cli/create-table.rb
eucalypt-0.4.0 lib/eucalypt/migration/namespaces/migration-create/cli/create-table.rb
eucalypt-0.3.5 lib/eucalypt/migration/namespaces/migration-create/cli/create-table.rb
eucalypt-0.3.4 lib/eucalypt/migration/namespaces/migration-create/cli/create-table.rb
eucalypt-0.3.3 lib/eucalypt/migration/namespaces/migration-create/cli/create-table.rb
eucalypt-0.3.2 lib/eucalypt/migration/namespaces/migration-create/cli/create-table.rb