SRoddis/Mongo.Migration

[Question] Is it possible to drop indexes for a specific collection

Closed this issue · 1 comments

Is it possible to drop indexes for a specific collection ? I try it with the DatabaseMigration interface but looks like it not work atm. or is not supported.

public class DropIndexes : DatabaseMigration
{
    public DropIndexes () : base("1.1.0")  {  }

    public override void Up(IMongoDatabase db)
    {
        var collection = db.GetCollection<UserDocument>(nameof(UserDocument));
        var indexes = collection.Indexes;
        
        // drop index here ???        
    }

    public override void Down(IMongoDatabase db)  {  }
}

Ok. nvm.
I figured out that the following line of code works.
collection.Indexes.DropAll();