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:

  1. pip install package
  2. add package "installed_apps"
  3. 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

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -