Sha256: 918aacaabe6fd32e4810379fed1e90eeb967b5947731efe7450d0711bc70738a
Contents?: true
Size: 1012 Bytes
Versions: 2
Compression:
Stored size: 1012 Bytes
Contents
require 'generators/data_migrate' require 'rails/generators' require 'rails/generators/migration' module DataMigrate module Generators class DataMigrationGenerator < Rails::Generators::NamedBase namespace "data_migration" include Rails::Generators::Migration argument :attributes, type: :array, default: [], banner: 'field:type field:type' def create_data_migration set_local_assigns! migration_template 'data_migration.rb', "db/data/#{file_name}.rb" end protected attr_reader :migration_action 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 def set_local_assigns! if file_name =~ /^(add|remove)_.*_(?:to|from)_(.*)/ @migration_action = $1 @table_name = $2.pluralize end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
data_migrate-3.0.1 | lib/generators/data_migration/data_migration_generator.rb |
data_migrate-3.0.0 | lib/generators/data_migration/data_migration_generator.rb |