mongoengine-migrate
mongoengine-migrate copied to clipboard
No changes detected when creating first migration
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
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
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".
@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://
It can't connect what I do?