ReQL command: index_rename
Command syntax
table.index_rename(old_index_name, new_index_name[, {:overwrite => false}]) → object
Description
Rename an existing secondary index on a table. If the optional argument overwrite
is specified as true
, a previously existing index with the new name will be deleted and the index will be renamed. If overwrite
is false
(the default) an error will be raised if the new index name already exists.
The return value on success will be an object of the format {:renamed => 1}
, or {:renamed => 0}
if the old and new names are the same.
An error will be raised if the old index name does not exist, if the new index name is already in use and overwrite
is False
, or if either the old or new index name are the same as the primary key field name.
Example: Rename an index on the comments table.
r.table('comments').index_rename('post_id', 'message_id').run(conn)
© RethinkDB contributors
Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
https://rethinkdb.com/api/ruby/index_rename/