Class: Padrino::Generators::Migration

Inherits:
Thor::Group
  • Object
show all
Includes:
Actions, Components::Actions, Thor::Actions
Defined in:
padrino-gen/lib/padrino-gen/generators/migration.rb

Overview

Responsible for generating migration files for the appropriate ORM component.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Actions

#already_exists?, #app_skeleton, #apply_component_for, #apply_default_fields, #check_app_existence, #destination_root, #empty_directory_with_keep_file, #execute_component_setup, #fetch_app_name, #fetch_component_choice, #fetch_project_name, #in_app_root?, #include_component_module_for, #initializer, #inject_into_file, #insert_hook, #insert_into_gemfile, #insert_middleware, #invalid_fields, #keep_file, #middleware, #recognize_path, #require_contrib, #require_dependencies, #resolve_valid_choice, #retrieve_component_config, #run_bundler, #store_component_choice, #store_component_config, #test?, #tiny?, #valid_choice?, #valid_constant?, #validate_namespace

Class Method Details



10
# File 'padrino-gen/lib/padrino-gen/generators/migration.rb', line 10

def self.banner; "padrino-gen migration [name] [fields]"; end

.source_rootObject



9
# File 'padrino-gen/lib/padrino-gen/generators/migration.rb', line 9

def self.source_root; File.expand_path(File.dirname(__FILE__)); end

Instance Method Details

#create_migrationObject

Creates the migration file within a Padrino project.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'padrino-gen/lib/padrino-gen/generators/migration.rb', line 27

def create_migration
  validate_namespace name
  self.destination_root = options[:root]
  if in_app_root?
    self.behavior = :revoke if options[:destroy]
    if include_component_module_for(:orm)
      create_migration_file(name, name, columns)
    else
      say '<= You need an ORM adapter for run this generator. Sorry!'
      raise SystemExit
    end
  else
    say 'You are not at the root of a Padrino application! (config/boot.rb not found)'
  end
end