Commit b73a08ddaafdcabc7b34e67ed1752cfe3fd8f851
1 parent
166836ee
Exists in
master
and in
29 other branches
Not involving model objects in the migration
(ActionItem1733)
Showing
1 changed file
with
2 additions
and
2 deletions
Show diff stats
db/migrate/20101202205446_remove_published_articles.rb
1 | 1 | class RemovePublishedArticles < ActiveRecord::Migration |
2 | 2 | def self.up |
3 | 3 | select_all("SELECT * from articles WHERE type = 'PublishedArticle'").each do |published| |
4 | - reference = Article.exists?(published['reference_article_id']) ? Article.find(published['reference_article_id']) : nil | |
4 | + reference = select('select * from articles where id = %d' % published['reference_article_id']).first | |
5 | 5 | if reference |
6 | - execute(ActiveRecord::Base.sanitize_sql(["UPDATE articles SET type = ?, abstract = ?, body = ? WHERE articles.id = ?", reference[:type], reference[:abstract], reference[:body], published['id']])) | |
6 | + execute(ActiveRecord::Base.sanitize_sql(["UPDATE articles SET type = ?, abstract = ?, body = ? WHERE articles.id = ?", reference['type'], reference['abstract'], reference['body'], published['id']])) | |
7 | 7 | else |
8 | 8 | execute("DELETE from articles where articles.id = #{published['id']}") |
9 | 9 | end | ... | ... |