mongoengine-migrate icon indicating copy to clipboard operation
mongoengine-migrate copied to clipboard

No changes detected when creating first migration

Open prihoda opened this issue 3 years ago • 3 comments

Hi all, how can I create my first migration?

I'm getting:

myproject git:(develop): mongoengine_migrate -u mongodb://localhost:27017/myproject --log-level DEBUG makemigrations
[DEBUG] Connecting to MongoDB...
[INFO] MongoDB version: 4.4.3
[DEBUG] Loading migration files...
[DEBUG] > Applied migrations: []
[DEBUG] > Last migration is: None
[DEBUG] Loading schema from database...
[DEBUG] Collecting schema from mongoengine documents...
[INFO] No changes detected

Nothing is created in ./migrations and the mongoengine_migrations collection is not created

prihoda avatar Apr 23 '21 07:04 prihoda

Hi @prihoda .

Seems that utility doesn't "see" your python module with mongoengine models. By default it looks for "models.py" in current directory. Try to specify module with -m parameter like this (in "import" syntax): mongoengine_migrate -u mongodb://localhost:27017/myproject --log-level DEBUG makemigrations -m your_project.models

bdragon300 avatar Apr 23 '21 11:04 bdragon300

Hi @bdragon300, thanks, in my case models is actually a module, so the documents from the individual scripts were not detected. I solved it by importing * from each script in __init__.py, but I wonder if it would be possible to solve this on mongoengine_migrate side?

It would also be helpful to get an error message like "No documents detected" rather than "No changes detected".

prihoda avatar Apr 26 '21 06:04 prihoda

@bdragon300 In the part of putting uri I can't put my uri that is not localhost what do I do?

EX: mongoengine_migrate --uri mongodb+srv://:@cluster0.f3c9z.mongodb.net/?retryWrites=true&w=majority

It can't connect what I do?

Cauan2305 avatar Dec 06 '21 20:12 Cauan2305