module Rails::Generators::Migration
def self.included(base) #:nodoc:
def self.included(base) #:nodoc: base.extend ClassMethods end
def migration_template(source, destination=nil, config={})
migration_template "migration.rb", "db/migrate/add_foo_to_bar.rb"
==== Examples
available as instance variables in the template to be rendered.
The migration version, migration file name, migration class name are
to the destination file name.
to the default template method is that the migration version is appended
Creates a migration template at the given destination. The difference
def migration_template(source, destination=nil, config={}) destination = File.expand_path(destination || source, self.destination_root) migration_dir = File.dirname(destination) @migration_number = self.class.next_migration_number(migration_dir) @migration_file_name = File.basename(destination).sub(/\.rb$/, '') @migration_class_name = @migration_file_name.camelize destination = self.class.migration_exists?(migration_dir, @migration_file_name) if behavior == :invoke raise Error, "Another migration is already named #{@migration_file_name}: #{destination}" if destination destination = File.join(migration_dir, "#{@migration_number}_#{@migration_file_name}.rb") end template(source, destination, config) end