summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhukl <contact@smyck.org>2009-11-11 16:53:23 +0100
committerhukl <contact@smyck.org>2009-11-11 16:53:23 +0100
commit13e04a41bf634cbefada19881caf81e7a9a69e0c (patch)
treeb2742e2686fa76ec01133953a66eb4c676e79ff5
parent19149240692ae5ca429b6d7d627c9af3fefe2cea (diff)
added rake task to migrate to the new editor column.
also added rake task to repair pages that don't have a published_at date set
-rw-r--r--lib/tasks/development_init.rake27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/tasks/development_init.rake b/lib/tasks/development_init.rake
index cb31215..e503728 100644
--- a/lib/tasks/development_init.rake
+++ b/lib/tasks/development_init.rake
@@ -82,4 +82,31 @@ namespace :cccms do
82 end 82 end
83 end 83 end
84 end 84 end
85
86 desc "Migrate users to editors"
87 task :migrate_editors => :environment do |t|
88 Page.record_timestamps = false
89 Page.before_save.reject! {|filter| filter.method == :rewrite_links_in_body}
90
91 Page.all.each do |page|
92 if page.node.locked?
93 page.editor = page.node.lock_owner
94 puts "#{page.id} #{page.node.lock_owner.login}"
95 else
96 page.editor = page.user if page.user
97 end
98
99 page.save!
100 end
101
102 end
103
104 desc "Repair pages without published_at set"
105 task :set_published_at => :environment do |t|
106 unpublished = Page.all(:conditions => {:published_at => nil})
107 unpublished.each do |p|
108 p.published_at = p.created_at
109 p.save!
110 end
111 end
85end \ No newline at end of file 112end \ No newline at end of file