Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema hasn't been registered #79

Open
PrinceCEE opened this issue Sep 22, 2021 · 1 comment
Open

Schema hasn't been registered #79

PrinceCEE opened this issue Sep 22, 2021 · 1 comment

Comments

@PrinceCEE
Copy link

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.

@vsmeyukha
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants