[#633] WikiPages may have no author - but should have

Chili 1.x did not enforce the presence of an author for wiki pages, but Chili 2.x does. This migrations fails, if there are WikiPages or Versions without author. By updating the migration, we may ensure, that the erroneous pages are correctly updated.

Signed-off-by: Holger Just <h.just@finn.de>
This commit is contained in:
Gregor Schmidt 2011-09-21 13:42:04 +02:00 committed by Holger Just
parent 0d306a8bfc
commit 3fd809f059
1 changed files with 5 additions and 0 deletions

View File

@ -24,6 +24,11 @@ class MergeWikiVersionsWithJournals < ActiveRecord::Migration
end
}
# assign all wiki_contents w/o author to the anonymous user - they used to
# work w/o author but don't any more.
WikiContent.update_all({:author_id => User.anonymous.id}, :author_id => nil)
WikiContent::Version.update_all({:author_id => User.anonymous.id}, :author_id => nil)
WikiContent::Version.find_by_sql("SELECT * FROM wiki_content_versions").each do |wv|
journal = WikiContentJournal.create!(:journaled_id => wv.wiki_content_id, :user_id => wv.author_id,
:notes => wv.comments, :created_at => wv.updated_on, :activity_type => "wiki_edits")