aboutsummaryrefslogtreecommitdiffstats
path: root/spec/dummy/db/migrate/20110314213540_remove_translated_fields_from_pages.rb
blob: 452daee8004aaa846739f3797a26f06046bb139c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class RemoveTranslatedFieldsFromPages < ActiveRecord::Migration
  def self.up
    ::Refinery::Page.translated_attribute_names.map(&:to_sym).each do |column_name|
      remove_column ::Refinery::Page.table_name, column_name if ::Refinery::Page.column_names.map(&:to_sym).include?(column_name)
    end

    ::Refinery::Page.reset_column_information
  end

  def self.down
    ::Refinery::Page.translated_attribute_names.map(&:to_sym).each do |column_name|
      add_column ::Refinery::Page.table_name, column_name, Page::Translation.columns.detect{|c| c.name.to_sym == column_name}.type
    end

    ::Refinery::Page.reset_column_information
  end
end