[Instiki] instiki moved to a new host, rails 2.2 and passenger, all previous spam removed

Matthias Tarasiewicz parasew at gmail.com
Wed Feb 4 21:33:18 EST 2009


On 04.02.2009, at 18:57, Morgan Sutherland wrote:

> How did you go about deleting spam messages?


we manually deleted the existing spam messages in the database, since  
the db grew too big and the export would take too long.

if somebody tries to redo this manually, keep the following in mind:
the data in the db is connected/linked, so when deleting rows from  
tables, make sure to not destroy the database integrity. the best  
approach to deal with the data is via the script/console.

backup your database before interacting with the data!

1. invoke with 'ruby script/console production' in the instiki root
2. get the page you want to alter

 >> mypage=Page.find_by_name('HomePage')

3. check how much revisions you've got

 >> mypage.revisions.count
=> 202

4. either delete all the versions but one (leave at least one  
revision! else your data integrity is gone!)

 >> mypage.revisions.each {|r| mypage.revisions.reload; r.destroy if  
mypage.revisions.count.to_i>1}
 >> mypage.revisions.reload
 >> mypage.revisions.count
=> 1

(keep in mind that on the website, the changes might be not visible  
immediately because of caching. delete everything in /cache to get the  
site to rebuild.

if you accidentally deleted all the revisions of your page and get  
error 500's:

 >> mypage=Page.find_by_name('HomePage')
 >>  
mypage 
.revisions 
.create 
(:revised_at=>Time.now,:author=>Author.new('console','127.0.0.1'))
 >> mypage.save!
=> true

5. selectively delete revisions:

# delete all revisions systemwide that contain the word "v1agra"
 >> Page.find(:all).each {|p| p.revisions.each {|r| r.destroy if  
r.content.include? "V1agra" }}

# delete all revisions systemwide that from the ip 55.55.55.55
 >> Page.find(:all).each {|p| p.revisions.each{|r| r.destroy if  
r.ip=="55.55.55.55" }}



# make sure that you don't have any pages without revisions afterwards

# either restore empty revisions
 >> Page.find(:all).each {|p|  
p 
.revisions 
.create 
(:revised_at=>Time.now,:author=>Author.new('console','127.0.0.1')) if  
p.revisions.size == 0}

# or also delete the corresponding Pages without revisions
 >> Page.find(:all).each {|p| p.destroy if p.revisions.size == 0}



in the next version of instiki there will be a "delete" functionality,  
but i am thinking of also implementing a delete-option for versions  
(revisions) soon, since databases can grow huge if there are lots of  
rollbacks.

another idea would be something like an "administrative rollback" or  
"hard rollback" that deletes all previous versions between the current  
entry and the to-be-rolled-back entry, anyone interested in such a  
functionality?

-m


More information about the Instiki-users mailing list