Sha256: d390e11814027a0c5a3d5b5bb9703d1bc85511c62656c348b094130367f4a4fb

Contents?: true

Size: 825 Bytes

Versions: 4

Compression:

Stored size: 825 Bytes

Contents

require 'rails/generators'
require 'rails/generators/named_base'
require 'rails/generators/migration'

module Imigrate
  module Generators
    class DataMigrationGenerator < Rails::Generators::NamedBase #:nodoc:
      namespace "data_migration"
      include Rails::Generators::Migration

      def self.source_root
        @_data_migrator_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
      end

      def create_data_migration
        migration_template "data_migration.rb", "db/data/#{file_name}.rb"
      end

      protected

      def self.next_migration_number(dirname)
        if ActiveRecord::Base.timestamped_migrations
          Time.new.utc.strftime("%Y%m%d%H%M%S")
        else
          "%.3d" % (current_migration_number(dirname) + 1)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
imigrate-0.9.3 lib/generators/imigrate.rb
imigrate-0.9.2 lib/generators/imigrate.rb
imigrate-0.9.1 lib/generators/imigrate.rb
imigrate-0.9.0 lib/generators/imigrate.rb