import mongoose from 'mongoose';

import connectToDatabase from '../config/dbConfig';

async function dropIndexes() {
  try {
    console.info('Connecting DB...');

    await connectToDatabase();
    const coll = mongoose.connection.db.collection('contacts');

    // drop all non-_id indexes
    await coll.dropIndexes();
    process.exit(0);
  } catch (error) {
    console.error('🚀 ~ dropIndexes ~ error:', error);
    process.exit(1);
  }
}

dropIndexes();
