Sha256: 893f77ff7a84ddc18a1d2670cf1808f5eb550bb343dd7c359784727d868bd147

Contents?: true

Size: 922 Bytes

Versions: 1

Compression:

Stored size: 922 Bytes

Contents

# rails generate effective:migration NAME [field[:type] field[:type]] [options]

# TODO - read from model dsl

# Generates a create_* migration
# rails generate effective:migration Thing
# rails generate effective:migration Thing name:string description:text

module Effective
  module Generators
    class MigrationGenerator < Rails::Generators::NamedBase
      include Helpers

      source_root File.expand_path(('../' * 4) + 'lib/scaffolds', __FILE__)

      desc 'Creates a migration.'

      argument :attributes, type: :array, default: [], banner: 'field[:type] field[:type]'

      def invoke_migration
        say_status :invoke, :migration, :white
      end

      def create_migration
        Rails::Generators.invoke('migration', ["create_#{plural_name}"] + invoked_attributes)
      end

      def invoked_attributes
        super | ['created_at:datetime', 'updated_at:datetime']
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
effective_developer-0.0.9 lib/generators/effective/migration_generator.rb