diff --git a/db/migrate/20101202205446_remove_published_articles.rb b/db/migrate/20101202205446_remove_published_articles.rb index a5cac79..fd8fbb1 100644 --- a/db/migrate/20101202205446_remove_published_articles.rb +++ b/db/migrate/20101202205446_remove_published_articles.rb @@ -1,9 +1,9 @@ class RemovePublishedArticles < ActiveRecord::Migration def self.up select_all("SELECT * from articles WHERE type = 'PublishedArticle'").each do |published| - reference = Article.exists?(published['reference_article_id']) ? Article.find(published['reference_article_id']) : nil + reference = select('select * from articles where id = %d' % published['reference_article_id']).first if reference - execute(ActiveRecord::Base.sanitize_sql(["UPDATE articles SET type = ?, abstract = ?, body = ? WHERE articles.id = ?", reference[:type], reference[:abstract], reference[:body], published['id']])) + execute(ActiveRecord::Base.sanitize_sql(["UPDATE articles SET type = ?, abstract = ?, body = ? WHERE articles.id = ?", reference['type'], reference['abstract'], reference['body'], published['id']])) else execute("DELETE from articles where articles.id = #{published['id']}") end -- libgit2 0.21.2