Class: Deimos::Generators::DbBackendGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Deimos::Generators::DbBackendGenerator
- Extended by:
- ActiveRecord::Generators::Migration
- Includes:
- ActiveRecord::Generators::Migration, Rails::Generators::Migration
- Defined in:
- lib/generators/deimos/db_backend_generator.rb
Overview
Generate the database backend migration.
Instance Method Summary collapse
- #db_migrate_path ⇒ String
-
#generate ⇒ void
Main method to create all the necessary files.
- #migration_version ⇒ String
Instance Method Details
#db_migrate_path ⇒ String
27 28 29 30 31 32 33 34 |
# File 'lib/generators/deimos/db_backend_generator.rb', line 27 def db_migrate_path if defined?(Rails.application) && Rails.application paths = Rails.application.config.paths['db/migrate'] paths.respond_to?(:to_ary) ? paths.to_ary.first : paths.to_a.first else 'db/migrate' end end |
#generate ⇒ void
This method returns an undefined value.
Main method to create all the necessary files
38 39 40 41 42 43 44 45 46 |
# File 'lib/generators/deimos/db_backend_generator.rb', line 38 def generate if Rails.version < '4' migration_template('rails3_migration', "#{db_migrate_path}/create_db_backend.rb") else migration_template('migration', "#{db_migrate_path}/create_db_backend.rb") end end |
#migration_version ⇒ String
20 21 22 23 24 |
# File 'lib/generators/deimos/db_backend_generator.rb', line 20 def migration_version "[#{ActiveRecord::Migration.current_version}]" rescue StandardError '' end |