Sha256: 4cd10d5d86e4f2ef7d19223b376970627cc09c85eb7dbb986c6565905df67bad

Contents?: true

Size: 858 Bytes

Versions: 48

Compression:

Stored size: 858 Bytes

Contents

# This migration comes from dm_cms (originally 20140328205246)
class AddPagesRankedModel < ActiveRecord::Migration
  def up
    add_column    :cms_pages,         :row_order,   :integer
    rename_column :cms_contentitems,  :position,  :row_order

    #--- because of some duplications in the position column, need to 
    #    create a more unique position value.  So add up the positions
    total = 0
    CmsPage.unscoped.order(:ancestry, :position).each do |page|
      total = total + page.position
      Account.current = Account.find(page.account_id)
      page.update_attributes :row_order => total
    end
    remove_column :cms_pages,        :position
  end
  
  def down
    remove_column :cms_pages,         :row_order
    add_columnn   :cms_pages,         :position, :integer
    rename_column :cms_contentitems,  :row_order, :position
  end
end

Version data entries

48 entries across 48 versions & 3 rubygems

Version Path
dm_newsletter-4.2.3.10 spec/dummy/db/migrate/20141119112038_add_pages_ranked_model.dm_cms.rb
dm_forum-4.2.3.10 spec/dummy/db/migrate/20141119112038_add_pages_ranked_model.dm_cms.rb
dm_event-4.2.3.10 spec/dummy/db/migrate/20141119103748_add_pages_ranked_model.dm_cms.rb
dm_newsletter-4.2.3.9 spec/dummy/db/migrate/20141119112038_add_pages_ranked_model.dm_cms.rb
dm_forum-4.2.3.9 spec/dummy/db/migrate/20141119112038_add_pages_ranked_model.dm_cms.rb
dm_event-4.2.3.9 spec/dummy/db/migrate/20141119103748_add_pages_ranked_model.dm_cms.rb
dm_newsletter-4.2.3.8 spec/dummy/db/migrate/20141119112038_add_pages_ranked_model.dm_cms.rb
dm_forum-4.2.3.8 spec/dummy/db/migrate/20141119112038_add_pages_ranked_model.dm_cms.rb
dm_event-4.2.3.8 spec/dummy/db/migrate/20141119103748_add_pages_ranked_model.dm_cms.rb
dm_newsletter-4.2.3.7 spec/dummy/db/migrate/20141119112038_add_pages_ranked_model.dm_cms.rb
dm_forum-4.2.3.7 spec/dummy/db/migrate/20141119112038_add_pages_ranked_model.dm_cms.rb
dm_event-4.2.3.7 spec/dummy/db/migrate/20141119103748_add_pages_ranked_model.dm_cms.rb
dm_newsletter-4.2.3.6 spec/dummy/db/migrate/20141119112038_add_pages_ranked_model.dm_cms.rb
dm_forum-4.2.3.6 spec/dummy/db/migrate/20141119112038_add_pages_ranked_model.dm_cms.rb
dm_event-4.2.3.6 spec/dummy/db/migrate/20141119103748_add_pages_ranked_model.dm_cms.rb
dm_newsletter-4.2.3.5 spec/dummy/db/migrate/20141119112038_add_pages_ranked_model.dm_cms.rb
dm_forum-4.2.3.5 spec/dummy/db/migrate/20141119112038_add_pages_ranked_model.dm_cms.rb
dm_event-4.2.3.5 spec/dummy/db/migrate/20141119103748_add_pages_ranked_model.dm_cms.rb
dm_newsletter-4.2.3.4 spec/dummy/db/migrate/20141119112038_add_pages_ranked_model.dm_cms.rb
dm_forum-4.2.3.4 spec/dummy/db/migrate/20141119112038_add_pages_ranked_model.dm_cms.rb