Class: Strata::CLI::Generators::Migration
- Defined in:
- lib/strata/cli/generators/migration.rb
Overview
Generates migration YAML files from templates.
Instance Method Summary collapse
Methods inherited from Group
Instance Method Details
#create_migration_file ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/strata/cli/generators/migration.rb', line 15 def create_migration_file = filename = generate_filename(operation, entity, from, to, ) output_path = File.join("migrations", filename) # Ensure directory exists empty_directory "migrations" # Load template and update with user inputs template_content = load_template(operation) hook = [:hook] || ((operation == "swap") ? "post" : "pre") updated_content = update_template(template_content, hook) # Write the updated template create_file output_path, updated_content say_status :created, output_path, :green end |