aboutsummaryrefslogtreecommitdiffstats
path: root/spec/dummy/db/migrate/20110802081569_translate_custom_title_on_pages.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/dummy/db/migrate/20110802081569_translate_custom_title_on_pages.rb')
-rw-r--r--spec/dummy/db/migrate/20110802081569_translate_custom_title_on_pages.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/dummy/db/migrate/20110802081569_translate_custom_title_on_pages.rb b/spec/dummy/db/migrate/20110802081569_translate_custom_title_on_pages.rb
new file mode 100644
index 0000000..ab21e11
--- /dev/null
+++ b/spec/dummy/db/migrate/20110802081569_translate_custom_title_on_pages.rb
@@ -0,0 +1,26 @@
+class TranslateCustomTitleOnPages < ActiveRecord::Migration
+ def self.up
+ unless ::Refinery::Page.translation_class.column_names.map(&:to_sym).include?(:custom_title)
+ add_column ::Refinery::Page.translation_class.table_name, :custom_title, :string
+
+ # Re-save custom_title
+ ::Refinery::Page.all.each do |page|
+ page.update_attribute(:custom_title, page.untranslated_attributes['custom_title'])
+ end
+
+ end
+ end
+
+ def self.down
+ # Re-save custom_title
+ ::Refinery::Page.all.each do |page|
+ ::Refinery::Page.update_all({
+ :custom_title => page.attributes['custom_title']
+ }, {
+ :id => page.id.to_s
+ }) unless page.attributes['custom_title'].nil?
+ end
+
+ remove_column ::Refinery::Page.translation_class.table_name, :custom_title
+ end
+end