Sha256: a5370a79319a7006c67ecb06a2304dcd4a486ddb5850e5a51e1853b155b32558
Contents?: true
Size: 1.24 KB
Versions: 1
Compression:
Stored size: 1.24 KB
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" class_option :skip_schema_migration, :desc => 'Dont generate database migration file.', :type => :boolean def create_data_migration set_local_assigns! unless options.skip_schema_migration? migration_template "migration.rb", "db/migrate/#{file_name}.rb" end 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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
data_migrate-1.0.0 | lib/generators/data_migration/data_migration_generator.rb |