Class: Flipper::Generators::UpdateGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Flipper::Generators::UpdateGenerator
- Includes:
- ActiveRecord::Generators::Migration
- Defined in:
- lib/generators/flipper/update_generator.rb
Overview
Rails generator used for updating Flipper in a Rails application. Run it with bin/rails g flipper:update in your console.
Constant Summary collapse
- TEMPLATES =
File.join(File.dirname(__FILE__), 'templates/update')
Instance Method Summary collapse
-
#update_migration_files ⇒ Object
Generates incremental migration files unless they already exist.
Instance Method Details
#update_migration_files ⇒ Object
Generates incremental migration files unless they already exist. All migrations should be idempotent e.g. add_index
is guarded with if_index_exists?
20 21 22 23 24 25 26 |
# File 'lib/generators/flipper/update_generator.rb', line 20 def update_migration_files migration_templates = Dir.children(File.join(TEMPLATES, 'migrations')).sort migration_templates.each do |template_file| destination_file = template_file.match(/^\d*_(.*\.rb)/)[1] # 01_create_flipper_tables.rb.erb => create_flipper_tables.rb migration_template "migrations/#{template_file}", File.join(db_migrate_path, destination_file), skip: true end end |