Sha256: 7e644ba768df060727da2147bba23b4a571c3a6642f2c4cab6c9476d11250127

Contents?: true

Size: 1.42 KB

Versions: 15

Compression:

Stored size: 1.42 KB

Contents

class MlmToMailManagerScoped < ActiveRecord::Migration

  def self.up
    rename_column :mlm_subscriptions, :mlm_mailing_list_id, :mailing_list_id
    rename_column :mlm_mailing_lists_mlm_mailings, :mlm_mailing_id, :mailing_id
    rename_column :mlm_mailing_lists_mlm_mailings, :mlm_mailing_list_id, :mailing_list_id
    rename_column :mlm_messages, :mlm_mailing_id, :mailing_id
    rename_column :mlm_bounces, :mlm_message_id, :message_id
    remove_column :mlm_mailings, :mlm_mailable_id
    rename_column :mlm_messages, :mlm_subscription_id, :subscription_id
    rename_column :mlm_bounces, :mlm_mailing_id, :mailing_id
    #this is better done with a straight query
    conn = ActiveRecord::Base.connection
    conn.execute("UPDATE `mlm_subscriptions` 
      SET contactable_type='MailManager::Subscription'
      WHERE contactable_type='MlmSubscription'")
  end
  
  def self.down
    rename_column :mlm_subscriptions, :mailing_list_id, :mlm_mailing_list_id
    rename_column :mlm_mailing_lists_mlm_mailings, :mailing_id, :mlm_mailing_id
    rename_column :mlm_mailing_lists_mlm_mailings, :mailing_list_id, :mlm_mailing_list_id
    rename_column :mlm_messages, :mailing_id, :mlm_mailing_id
    rename_column :mlm_bounces, :message_id, :mlm_message_id
    add_column :mlm_mailings, :mlm_mailable_id, :integer
    rename_column :mlm_messages, :subscription_id, :mlm_subscription_id
    rename_column :mlm_bounces, :mailing_id, :mlm_mailing_id
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
mail_manager-3.2.25.1 db/mlm_migrate/005_mlm_to_mail_mgr_scoped.rb
mail_manager-3.2.22.0 db/mlm_migrate/005_mlm_to_mail_mgr_scoped.rb
mail_manager-3.2.7 db/mlm_migrate/005_mlm_to_mail_mgr_scoped.rb
mail_manager-3.2.6 db/mlm_migrate/005_mlm_to_mail_mgr_scoped.rb
mail_manager-3.2.5 db/mlm_migrate/005_mlm_to_mail_mgr_scoped.rb
mail_manager-3.2.4 db/mlm_migrate/005_mlm_to_mail_mgr_scoped.rb
mail_manager-3.2.2 db/mlm_migrate/005_mlm_to_mail_mgr_scoped.rb
mail_manager-3.2.1 db/mlm_migrate/005_mlm_to_mail_mgr_scoped.rb
mail_manager-3.2.0 db/mlm_migrate/005_mlm_to_mail_mgr_scoped.rb
mail_manager-3.0.0 db/mlm_migrate/005_mlm_to_mail_mgr_scoped.rb
mail_manager-0.1.4 db/mlm_migrate/005_mlm_to_mail_mgr_scoped.rb
mail_manager-0.1.2 db/mlm_migrate/005_mlm_to_mail_mgr_scoped.rb
mail_manager-0.1.1 db/mlm_migrate/005_mlm_to_mail_mgr_scoped.rb
mail_manager-0.1.0 db/mlm_migrate/005_mlm_to_mail_mgr_scoped.rb
mail_manager-0.0.1 db/mlm_migrate/005_mlm_to_mail_mgr_scoped.rb