Sha256: b76e0fc214d896f9eca23329d0cede068071a9a6fceb99e613dd03d6bf9b870c

Contents?: true

Size: 686 Bytes

Versions: 8

Compression:

Stored size: 686 Bytes

Contents

require 'rails/generators'
require 'rails/generators/active_record/migration/migration_generator'

class SqlMigrationGenerator < ActiveRecord::Generators::MigrationGenerator
  class_option :location, :type => :string, :default => "db/migrate"

  def create_migration_file
    set_local_assigns!
    validate_file_name!
    migration_name = "#{file_name}.rb"
    migration_template "migration.rb", File.join(options[:location], migration_name)
  end

  def source_paths
    [File.join(File.dirname(__FILE__), "templates")]
  end
  protected
    def validate_file_name!
      unless file_name =~ /^[_a-z0-9]+$/
        raise IllegalMigrationNameError.new(file_name)
      end
    end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dbmigrator-0.7.7 lib/dbmigrator/migration_generator.rb
dbmigrator-0.7.6 lib/dbmigrator/migration_generator.rb
dbmigrator-0.7.5 lib/dbmigrator/migration_generator.rb
dbmigrator-0.7.4 lib/dbmigrator/migration_generator.rb
dbmigrator-0.7.1 lib/dbmigrator/migration_generator.rb
dbmigrator-0.7.0 lib/dbmigrator/migration_generator.rb
dbmigrator-0.6.0 lib/dbmigrator/migration_generator.rb
dbmigrator-0.5.3 lib/dbmigrator/migration_generator.rb