How to make migrations only one app inside project using django

Viewed 5172

I have the follow project structure:

MyProject
|--myBaseApp
|  |--migrations
|  |--__init__.py
|  |--models.py
|  |...
|--myClientApp
|  |--migrations
|  |--__init__.py
|  |--models.py
|  |...
|--myProject
|  |--__init__.py
|  |--settings.py
|  |--urls.py
|  |...
|--manage.py
|...

I can import to myClientApp/models.py the models.py from myBaseApp, but when I use the commands on terminal mode:

python manage.py makemigrations
python manage.py migrate myClienteApp

The Django creates, on data base, all tables from models.py, both myClienApp/models.py and myBaseApp/models.py. I'd like to make migrate only the models.py from myClienApp/models.py. It's possible? Or do I need to create other project?

2 Answers

If you want to make migrations only within one app use,

python manage.py makemigrations <app_name>

If you want to run migrations only within one app use,

python manage.py migrate <app_name>

It sounds like this is the first migration -- Django will migrate the stuff from the myBaseApp if so

You can try to run a specific migration instead i.e.:

./manage.py migrate myapp 0005_migration_to_run

Related