Skip to content

Commit

Permalink
Make seo_meta migration consistent and prevent bugs with 'title' fiel…
Browse files Browse the repository at this point in the history
…d on other engines' migrations.
  • Loading branch information
parndt committed May 27, 2011
1 parent 3812f11 commit 39dbf85
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
6 changes: 6 additions & 0 deletions db/migrate/20110329222114_create_seo_meta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def self.up
}
)
end

# Reset column information again because otherwise the old columns will still exist.
::Page.reset_column_information
end

def self.down
Expand Down Expand Up @@ -76,6 +79,9 @@ def #{k}=(*args)
}
end

# Reset column information again because otherwise the old columns will still exist.
::Page.reset_column_information

drop_table :seo_meta
end

Expand Down
20 changes: 18 additions & 2 deletions pages/db/migrate/20110329080451_create_seo_meta.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def self.up
}
)
end

# Reset column information again because otherwise the old columns will still exist.
::Page.reset_column_information
end

def self.down
Expand All @@ -59,13 +62,26 @@ def self.down

# Migrate data
existing_translations.each do |translation|
::Page::Translation.find(translation['id']).update_attributes(
::Page::Translation.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|
::Page::Translation.module_eval %{
def #{k}
end
def #{k}=(*args)
end
}
end

# Reset column information again because otherwise the old columns will still exist.
::Page.reset_column_information

drop_table :seo_meta
end

Expand Down

0 comments on commit 39dbf85

Please sign in to comment.