Sha256: cb10eb069aebe1c15ef489da0e9066ba3a14e6a6d71be06729167d51d0323c9c

Contents?: true

Size: 1.26 KB

Versions: 3

Compression:

Stored size: 1.26 KB

Contents

# -*- encoding : utf-8 -*-

class AccountRequestsToSignups < ActiveRecord::Migration
  include Wagn::MigrationHelper
  def up
    contentedly do

      newname = 'Sign up'
      newname = '*signup' if Card.exists? newname
      
      #get old codename and name out of the way
      old_signup = Card[:signup]
      old_signup_name = old_signup.name
      old_signup.name = "#{newname} - old"
      old_signup.codename = nil
      old_signup.save!

      Card::Codename.reset_cache
      
      # rename Account Request to "Sign up"
      new_signup = Card[:account_request]
      new_signup.name = newname
      new_signup.update_referencers = true
      new_signup.codename = :signup
      new_signup.save!
      
      # move old "*signup+*thanks" to "Sign up+*type+*thanks"
      thanks = Card[:thanks]
      if signup_thanks = Card["#{old_signup.name}+#{thanks.name}"]
        signup_thanks.name = "#{new_signup.name}+#{Card[:type].name}+#{thanks.name}" 
        signup_thanks.update_referencers = true
        signup_thanks.save!
      end
      
      # get rid of old signup card unless there is other data there (most likely +*subject and +*message)
      unless Card.search(:return=>:id, :left_id=>old_signup.id).first
        old_signup.delete!
      end
      
    end
  end

end


Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wagn-1.13.0.pre2 db/migrate_cards/20140317035504_account_requests_to_signups.rb
wagn-1.13.0.pre1 db/migrate_cards/20140317035504_account_requests_to_signups.rb
wagn-1.13.0.pre db/migrate_cards/20140317035504_account_requests_to_signups.rb