dropIndex
dropIndex
is a Change Type in the Liquibase Open Source and Liquibase Pro extensions for MongoDB that drops an index for a collection by its keys.
Uses
The Liquibase Pro extension for MongoDB includes several modeled Change Types from the Liquibase Open Source version. These let you specify a few MongoDB commands using Liquibase XML, JSON, and YAML changelogs.
dropIndex
is one such Change Type. You can use it to drop an existing index from your database.
Note: If you want to specify mongosh
statements in your XML, JSON, and YAML changelogs, use the mongo
and mongoFile
Change Types instead.
Run
To run this Change Type, follow these steps:
- Add the Change Type to your changeset, as shown in the examples on this page.
- Specify any required attributes. Use the table on this page to see which ones your database requires.
- Deploy your changeset by running the
update
command:
liquibase update
Available attributes
For more information, see db.collection.dropIndex().
Tip: You must specify all top-level attributes marked as required. If you specify an optional attribute, you must also specify any nested attributes that it requires.
Name | Type | Description | Requirement |
---|---|---|---|
collectionName
|
String | Name of the collection to drop the index from | Required |
keys
Required. A document that defines the index's basic contents and structure.
keys
has the following nested attributes:
name
(string) (required): the name of a key in the collection to use for the indextype
(string) (required): the type of the index. For an ascending index, specify1
. For a descending index, specify-1
. Other accepted values includetext
,geospatial
,hashed
, and more.
Examples
YAML example
databaseChangeLog:
- changeSet:
id: 4
author: your.name
changes:
- dropIndex:
collectionName: countries_yaml
keys: '{ name: 1, type: 1}'
- rollback:
Database support
This Change Type is only supported for MongoDB. It does not support auto rollback.