From b73a08ddaafdcabc7b34e67ed1752cfe3fd8f851 Mon Sep 17 00:00:00 2001 From: Antonio Terceiro Date: Tue, 21 Dec 2010 12:37:55 -0300 Subject: [PATCH] Not involving model objects in the migration --- db/migrate/20101202205446_remove_published_articles.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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