Class: Mongoid::Generators::MigrationGenerator

Inherits:
Base
  • Object
show all
Defined in:
lib/rails/generators/mongoid/migration/migration_generator.rb

Instance Method Summary collapse

Methods inherited from Base

next_migration_number, source_root

Instance Method Details

#create_migration_fileObject



8
9
10
11
12
13
14
15
16
# File 'lib/rails/generators/mongoid/migration/migration_generator.rb', line 8

def create_migration_file
  destination_folder = "db/migrate"
  if options.fetch(:shards, Config.shards_migration_as_default)
    destination_folder = "#{destination_folder}/shards"
    FileUtils.mkdir_p("#{Rails.root}/#{destination_folder}")
  end

  migration_template "migration.rb", "#{destination_folder}/#{file_name}.rb"
end