Last active
August 29, 2015 14:16
-
-
Save barkerja/1d11f73a1868edbfbe86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| include RethinkDB::Shortcuts | |
| conn = r.connect(host: ENV['RETHINKDB_URL']) | |
| databases = r.db_list().run(conn) | |
| databases.each do |database| | |
| puts "Database: #{database}" | |
| tables = r.db(database).table_list().run(conn) | |
| tables.each do |table| | |
| puts "Table: #{table}" | |
| indexes = r.db(database).table(table).index_list().run(conn) | |
| indexes.each do |index| | |
| puts "Index: #{index}" | |
| index_status = r.db(database).table(table).index_status(index).nth(0).run(conn) | |
| next unless index_status['outdated'] == true | |
| index_function = index_status['function'] | |
| r.db(database).table(table).index_create('new_index', index_function).run(conn) | |
| r.db(database).table(table).index_wait('new_index').run(conn) | |
| r.db(database).table(table).index_rename('new_index', index, overwrite: true).run(conn) | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment