diff options
author | Jamie Winsor <jamie@enmasse.com> | 2011-08-03 19:18:19 -0700 |
---|---|---|
committer | Jamie Winsor <jamie@enmasse.com> | 2011-08-03 19:18:19 -0700 |
commit | 274ba14ea24d2e59a4ddf2e09fd94fa9246f1c55 (patch) | |
tree | c61db4fd992067a80e47396fcfc2feabd542fe10 /spec/dummy/db/migrate/20110802081571_create_seo_meta.rb | |
parent | 13c35c262072c06a97b178c9c9cabbe2482ac649 (diff) | |
download | refinerycms-blog-274ba14ea24d2e59a4ddf2e09fd94fa9246f1c55.tar.gz refinerycms-blog-274ba14ea24d2e59a4ddf2e09fd94fa9246f1c55.tar.bz2 refinerycms-blog-274ba14ea24d2e59a4ddf2e09fd94fa9246f1c55.zip |
refactor dummy application into git submodule
Diffstat (limited to 'spec/dummy/db/migrate/20110802081571_create_seo_meta.rb')
m--------- | spec/dummy | 0 | ||||
-rw-r--r-- | spec/dummy/db/migrate/20110802081571_create_seo_meta.rb | 86 |
2 files changed, 0 insertions, 86 deletions
diff --git a/spec/dummy b/spec/dummy new file mode 160000 +Subproject 84d66350ec474665e7d436dca479a142b091f87 diff --git a/spec/dummy/db/migrate/20110802081571_create_seo_meta.rb b/spec/dummy/db/migrate/20110802081571_create_seo_meta.rb deleted file mode 100644 index abc2178..0000000 --- a/spec/dummy/db/migrate/20110802081571_create_seo_meta.rb +++ /dev/null @@ -1,86 +0,0 @@ -class CreateSeoMeta < ActiveRecord::Migration - - def self.up - create_table :seo_meta do |t| - t.integer :seo_meta_id - t.string :seo_meta_type - - t.string :browser_title - t.string :meta_keywords - t.text :meta_description - - t.timestamps - end - - add_index :seo_meta, :id - add_index :seo_meta, [:seo_meta_id, :seo_meta_type] - - # Grab the attributes of the records that currently exist - existing_translations = ::Refinery::Page.translation_class.all.map(&:attributes) - - # Remove columns - ::SeoMeta.attributes.keys.each do |field| - if ::Refinery::Page.translation_class.column_names.map(&:to_sym).include?(field) - remove_column ::Refinery::Page.translation_class.table_name, field - end - end - - # Reset column information because otherwise the old columns will still exist. - ::Refinery::Page.translation_class.reset_column_information - - # Re-attach seo_meta - ::Refinery::Page.translation_class.send :is_seo_meta - - # Migrate data - existing_translations.each do |translation| - ::Refinery::Page.translation_class.find(translation['id']).update_attributes( - ::SeoMeta.attributes.keys.inject({}) {|attributes, name| - attributes.merge(name => translation[name.to_s]) - } - ) - end - - # Reset column information again because otherwise the old columns will still exist. - ::Refinery::Page.reset_column_information - end - - def self.down - # Grab the attributes of the records that currently exist - existing_translations = ::Refinery::Page.translation_class.all.map(&:attributes) - - # Add columns back to your model - ::SeoMeta.attributes.each do |field, field_type| - unless ::Refinery::Page.translation_class.column_names.map(&:to_sym).include?(field) - add_column ::Refinery::Page.translation_class.table_name, field, field_type - end - end - - # Reset column information because otherwise the new columns won't exist yet. - ::Refinery::Page.translation_class.reset_column_information - - # Migrate data - existing_translations.each do |translation| - ::Refinery::Page.translation_class.update_all( - ::SeoMeta.attributes.keys.inject({}) {|attributes, name| - attributes.merge(name => translation[name.to_s]) - }, :id => translation['id'] - ) - end - - ::SeoMeta.attributes.keys.each do |k| - ::Refinery::Page.translation_class.module_eval %{ - def #{k} - end - - def #{k}=(*args) - end - } - end - - # Reset column information again because otherwise the old columns will still exist. - ::Refinery::Page.reset_column_information - - drop_table :seo_meta - end - -end |