Sha256: 315ea77b4f3dd5a1e10500292f06b233b91c61ecdd8d977b26ca0e0e372ee951
Contents?: true
Size: 1.19 KB
Versions: 4
Compression:
Stored size: 1.19 KB
Contents
module Rails module Generators module MigrationHelper include Rails::Generators::Migration module ClassMethods def migration_lookup_at(dirname) #:nodoc: Dir.glob("#{dirname}/[0-9]*_*.rb") end def migration_exists?(dirname, file_name) #:nodoc: migration_lookup_at(dirname).grep(/\d+_#{file_name}.rb$/).first end def current_migration_number(dirname) #:nodoc: migration_lookup_at(dirname).collect do |file| File.basename(file).split("_").first.to_i end.max.to_i end def next_migration_number(dirname) #:nodoc: orm = Rails.configuration.generators.options[:rails][:orm] require "rails/generators/#{orm}" "#{orm.to_s.camelize}::Generators::Base".constantize.next_migration_number(dirname) rescue raise NotImplementedError end end def self.included(base) #:nodoc: base.extend ClassMethods end def info msg Rails.logger.info msg end def migration(options) migration_template "create_users.erb", "db/migrations/#{name}" end end end end
Version data entries
4 entries across 4 versions & 1 rubygems