cleanup scripts

This commit is contained in:
r888888888
2013-10-14 15:10:17 -07:00
parent 25e6018b2d
commit ee8ad9744c
3 changed files with 83 additions and 4 deletions

View File

@@ -0,0 +1,52 @@
#!/usr/bin/env ruby
require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'config', 'environment'))
require 'aws/s3'
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
files = "424276a46717a932bb9195e65d47dca4.gif
c91c68579d8698a0e090f61bd69af67c.jpg
108a1bea9259e660ce7ec710132192bd.gif
773213a4e08132a148a4b270d88001ec.jpg
2bd8f23f43fe8bde50f37e9533cc2f01.jpg
363afa3e90708daa6f5fc09df83eb446.gif
2afe888d6d4fb04ccc8b5e31fe247f28.gif
938785a540cab00918231949d2bd2c2d.jpg
9fce8a73db402e28a22dffba4072dd09.gif
53d1925948cdd054475556f60aac58c0.jpg
6be989aa5854ddd211060252aebc7435.jpg
35371159177fec6e1cfe33ce1e8cb2a4.jpg
88bfad0ed5b5f4b7a14b63ed3e4160ae.jpg
7bdad95ccd4eca1e5c1899a5b3fd9757.jpg
26df2ed194a57aff03e5199cf5bcbe1a.jpg
3fbb9be8c14fb6ce51b86ead55666b63.jpg
dd9ca526c947812eb7b5cb8638858090.jpg
bde86123407c1e9f84000bc5261c6821.gif
dca035595a4c87a9074b5c0eb20c1b62.gif
587c4214a75aa1d2762486d119582ca5.gif
39e088fe7bca020d844316fcf71a5bf2.jpg
cd5a9e4d98ee4f5e3532ff6bab635890.jpg
f100e8add26908f1374d706f53d99cfb.gif
8891e230b920c26bb2a05a47fb75961f.jpg
c82a7d3caf2915251a6ab2cb3f66a4b9.jpg
c3443778b89ffe0914e7ea4d6004b35f.rar
135c5b7e158d11f109fda7f0039afb68.jpg
5e153c126bb41d90ab488a09e3bc1271.jpg
c655efc1b4292f17db74bb07fef63e9e.jpg
66fffc6df639c9bf7ce9a9f9e3a18b7a.jpg
64d06a341120102b7b48ff3e8f437538.gif
634abd39db90f5fa5d7c5a7a2d427131.gif".scan(/\S+/)
AWS::S3::Base.establish_connection!(
:access_key_id => File.read(File.expand_path("~/.s3/access_key")),
:secret_access_key => File.read(File.expand_path("~/.s3/secret_access_key"))
)
files.each do |file_name|
bad_md5 = file_name.split(/\./).first
correct_md5 = Digest::MD5.hexdigest(AWS::S3::S3Object.value(file_name, "danbooru"))
puts "update posts set md5 = '#{correct_md5}' where md5 = '#{bad_md5}';"
# Post.find_by_md5(bad_md5).update_column(:md5, correct_md5)
end

31
script/sanitize.sql Normal file
View File

@@ -0,0 +1,31 @@
truncate table advertisement_hits;
truncate table advertisements;
update artist_versions set updater_ip_addr = '127.0.0.1';
truncate table bans;
truncate table comment_votes;
truncate table comments;
truncate table delayed_jobs;
truncate table dmails;
truncate table forum_posts;
truncate table forum_topics;
truncate table ip_bans;
truncate table janitor_trials;
truncate table mod_actions;
truncate table news_updates;
update note_versions set updater_ip_addr = '127.0.0.1';
update pool_versions set updater_ip_addr = '127.0.0.1';
update posts set uploader_ip_addr = '127.0.0.1';
truncate table post_appeals;
truncate table post_disapprovals;
truncate table post_flags;
update post_versions set updater_ip_addr = '127.0.0.1';
truncate table post_votes;
update tag_aliases set creator_ip_addr = '127.0.0.1';
update tag_implications set creator_ip_addr = '127.0.0.1';
truncate table tag_subscriptions;
truncate table uploads;
truncate table user_feedback;
truncate table user_name_change_requests;
truncate table user_password_reset_nonces;
update users set password_hash = '', email = '', recent_tags = '', favorite_tags = '', blacklisted_tags = '', bcrypt_password_hash = '', custom_style = '', email_verification_key = '', last_logged_in_at = now(), last_forum_read_at = null, receive_email_notifications = false, updated_at = now(), time_zone = 'Eastern Time (US & Canada)';
update wiki_page_versions set updater_ip_addr = '127.0.0.1';

View File

@@ -1,4 +0,0 @@
set statement_timeout = 0;
delete from posts where id < (select max(id) - 50000 from posts);
delete from post_appeals where post_id < (select max(id) - 50000 from posts);
vacuum analyze;