supercharge / mongodb-github-action

Use MongoDB in GitHub Actions
MIT License
224 stars 46 forks source link

Add unique index option? #11

Closed Puddinglord closed 4 years ago

Puddinglord commented 4 years ago

When running my unit tests my production database has a unique index field date: 1. When running my unit tests using this action the tests fail because there is no unique index on the date field.

Would it be possible to add unique index support?

marcuspoehls commented 4 years ago

@Puddinglord Hey, how are you creating the indexes in your database?

I assume you're populating your database schema and collections while testing your application. Is the index creation part of this population?

Puddinglord commented 4 years ago

I was unaware that I could create a unique index on a collection using the JS driver. I have always made them using Compass. Thanks for putting me on the right track and I appreciate you making this action as it's saved me a ton of time 👏

Puddinglord commented 4 years ago

I can confirm that I can add a unique index via the nodejs driver and have done so successfully. My unit tests now run correctly with a fresh container spun up each time.

Thank you for setting me on the right path. I will close this issue now.

marcuspoehls commented 4 years ago

@Puddinglord Great! Good to hear your tests are passing now 😃 Sweet!

Also nice we both learned something new: I didn't know you can create indexes in Compass. I'm typically using Robo 3T as a MongoDB GUI. Compass keeps getting better in terms of features 👍