Open PrinceCEE opened 2 years ago
You have to import the schema to migration file and then write directly in up function smth like this:
const model = this('model', Model.schema)
After that use this model and it seems to work well.
It happens because migrate-mongoose and the model use different instances of mongoose connection. And that means that the model isn't connected yet when the migrator is. That's why the migrator doesn't see the model if you don't write thing that I've mentioned above.
When running the migrate up command, it consoles that schema hasn't been registered for my models, whereas I imported the schema, and used mongoose.mode to create the model.