python - How do I handle migrations as a Django package maintainer? -
i have been writing new django package pip-installable. i've been stuck awhile because i'm unsure how make migrations particular package allow normal workflow of install be:
- pip install package
- add package "installed_apps"
- run
python manage.py migrate
currently, package looks this:
package_root/ dist/ actual_package/ __init__.py models.py setup.py
the problem facing when package app , install using pip install dist/...
, add example apps "installed_apps", running python manage.py migrate
not create tables models in actual_package/models.py
, hence (from users perspective) need run python manage.py makemigrations actual_package
first, not ideal.
any ideas on how have migrations sorted before user installs excellent.
1 - include initial migrations in package - e.g., actual_package/migrations/0001_initial.py
2 - include python manage.py migrate actual_package
part of installation process - whether new or update.
3 - if publish updates actual_package, include new migrations.
this should work both new installations , updates. if migrations have been done (e.g., update no new migrations included) migrate command won't hurt.
one key warning: make sure package installation checks appropriate django version. there have been lot of changes between versions , code - , migrations - 1 version may not work another.
Comments
Post a Comment