Class: SocialFramework::Generators::InstallMigrationsGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- SocialFramework::Generators::InstallMigrationsGenerator
- Defined in:
- lib/generators/social_framework/install_migrations_generator.rb
Overview
Generator to add migrations in the application
Instance Method Summary collapse
-
#add_migrations ⇒ Object
Copy the migrations to application.
Instance Method Details
#add_migrations ⇒ Object
Copy the migrations to application
Without ‘-m’ option copy all migrations, With ‘-m’ option copy specifics migrations.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/generators/social_framework/install_migrations_generator.rb', line 16 def add_migrations migrations = Dir.glob(SocialFramework::Engine.config.paths["db/migrate"].first + "/*") if [:migrations] [:migrations].each do |migrate| file = "social_framework_#{migrate.pluralize}.rb" file = migrations.select { |m| m.include?(file) }.first unless file.nil? or file.empty? file_name = file.split("/").last copy_file file, "db/migrate/#{file_name}" else puts "Could not find migration: '#{migrate}'" end end else migrations.each do |migrate| file = migrate.split("/").last copy_file migrate, "db/migrate/#{file}" end end end |