blob: 45d705528362a419674e9e74229c6337808b1cb1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#!/usr/bin/ruby
#
# Clean up cruft left over by bad tests.
#
# Removes all 'test_user_x' users from the users db, along with the
# corresponding indentities and storage db.
#
require 'couchrest'
users_db_name = 'users'
#user_db_name = 'tmp_users'
identities_db_name = 'identities'
server = CouchRest::Server.new
users_db = server.database(users_db_name)
identities_db = server.database(identities_db_name)
records = db.view('User/by_login', :reduce => false, :startkey => 'test_user_', :endkey => 'test_user_'+"\u{fff}")['rows']
records.each do |record|
user_id = record['id']
username = record['key']
storage_db = server.database("user-" + user_id)
storage_db.delete! rescue RestClient::ResourceNotFound
identities_db.view('Identity/by_user_id', :reduce => false, :startkey => user_id, :endkey => user_id)['rows'].each do |row|
identities_db.delete_doc(row['id'])
end
end
users_db.compact!
identities_db.compact!
|