class SimpleDataMigrations::TemplateGenerator

Public Instance Methods

create_template_file() click to toggle source
# File lib/generators/simple_data_migrations/template_generator.rb, line 7
    def create_template_file
      version = Time.now.utc.strftime("%Y%m%d%H%M%S") # Rails db migration like
      path = SimpleDataMigrations::Utils.root.join("#{version}_#{file_name}.rb")

      create_file path do
<<-TEMPLATE
ApplicationRecord.transaction do
  # Your code

  SimpleDataMigrations::Entry.create!(version: #{version})
end
TEMPLATE
      end
    end