Sha256: 2ebcc3c145c9a37d31b7a1258fec7fd90b47f0bb7c4f1715f389144fab3f8265

Contents?: true

Size: 604 Bytes

Versions: 1

Compression:

Stored size: 604 Bytes

Contents

class ChangeLiquidTagsToPolymorphic < ActiveRecord::Migration
  def up
    rename_column :spud_page_liquid_tags, :spud_page_partial_id, :attachment_id
    add_column :spud_page_liquid_tags, :attachment_type, :string

    add_index :spud_page_liquid_tags, [:attachment_type,:attachment_id], :name => "idx_spliquid_attachment"

    SpudPageLiquidTag.all.each do |f|
      f.update_attributes(:attachment_type => "SpudPagePartial")
    end
  end

  def down
    rename_column :spud_page_liquid_tags, :attachment_id, :spud_page_partial_id
    remove_column :spud_page_liquid_tags, :attachment_type
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
spud_cms-1.0.2 db/migrate/20121119030136_change_liquid_tags_to_polymorphic.rb