Sha256: adb8bc4905bd4b26791731e7c7f8d2ba8c143ec68b0222d7462adeb9cb0f54d1

Contents?: true

Size: 857 Bytes

Versions: 4

Compression:

Stored size: 857 Bytes

Contents

# -*- encoding : utf-8 -*-
class Alter<%= @entities.select{|e| e.resource?}.collect{|e| e.file_name.camelize}.join('') %><%= @random_migration_key %> < ActiveRecord::Migration
  
  def self.up
  <%- @changes.each do |change| -%>
    <%= change[:type] %> :<%= MDWA::Generators::Model.new(change[:entity].model_name).plural_name %>, :<%= change[:column] %> <%= ", :#{change[:attr_type]}" unless change[:attr_type].blank? or change[:type] == 'remove_column' %>
  <%- end -%>
  end
  
  def self.down
  <%- @changes.each do |change| -%>
    <%= inverse_migration_type change[:type] %> :<%= MDWA::Generators::Model.new(change[:entity].model_name).plural_name %>, :<%= change[:column] %> <%= ", :#{change[:attr_type]}" if inverse_migration_type(change[:type]) == 'add_column' %> <%= ", :#{change[:from]}" unless change[:from].blank? %>
  <%- end -%>
  end
  
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mdd-3.0.10 lib/generators/mdwa/transform/templates/changes_migration.rb
mdd-3.0.9 lib/generators/mdwa/transform/templates/changes_migration.rb
mdd-3.0.8 lib/generators/mdwa/transform/templates/changes_migration.rb
mdd-3.0.7 lib/generators/mdwa/transform/templates/changes_migration.rb