Class: CassandraMigrationGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/cassandra_migrations/railtie/generators/cassandra_migration/cassandra_migration_generator.rb

Instance Method Summary collapse

Instance Method Details

#generate_migrationObject

Interpolates template and creates migration in the application

Any public method in the generator is run automatically when the generator is run. To understand fully see asciicasts.com/episodes/218-making-generators-in-rails-3



12
13
14
15
16
17
# File 'lib/cassandra_migrations/railtie/generators/cassandra_migration/cassandra_migration_generator.rb', line 12

def generate_migration
  file_name = "#{Time.current.utc.strftime('%Y%m%d%H%M%S')}_#{migration_name.underscore}"
  @migration_class_name = migration_name.camelize
  
  template "empty_migration.rb.erb", "db/cassandra_migrate/#{file_name}.rb"  
end