Could someone offer me a tip as to how to go about re-ordering my migration files to match my newly restructured project? There is only one migration in the admin app so it seems that it is not an unreasonable goal.
As was discussed in my post the-drawbacks-of-using-an-apps-sub-directory I started a project with my applications (only one) were grouped in an ‘apps’ directory at the same level of the project:
└── myproject <- project root
├── myadmin <- Django root
│ ├── migrations <- project migrations
│ │ ├── 0001_initial.py
│ │ └── __init__.py
│ ├── apps <- Home for all Django Apps
│ │ ├── appcustom <- appcustom app
│ │ │ ├── migrations <- dir for appcustom app migrations
│ │ │ │ ├── 0001_initial.py
│ │ │ │ ├── 0002_alter_asset_asset_type_code_and_more.py
│ │ │ │ ├── 0003_alter_another_entity_and_more.py
│ │ │ │ └── __init__.py
I decided to see if I could revert the project to a structure that is more in line with convention (@KenWhitesell feel free to say ‘I warned you’). So I refactored my app by changing all the references to the following:
└── myproject <- project root
├── appcustom <- appcustom app
│ ├── migrations <- dir for appcustom app migrations
│ ├── 0001_initial.py
│ ├── 0002_alter_asset_asset_type_code_and_more.py
│ ├── 0003_alter_another_entity_and_more.py
│ └── __init__.py
├── myadmin <- Django root
│ ├── migrations <- project migrations
│ │ ├── 0001_initial.py
│ │ └── __init__.py
Miraculously everything worked after pointing my app back at the database and life was good. Or so it seemed until I lost my local database running in a local container when I forgot to point the storage to something outside of the container and I needed to run migrations. However, I have just realized that Django no longer knows which migration to apply first. When I go to migrate my restored database I get the following error:
django.db.migrations.exceptions.InconsistentMigrationHistory: Migration admin.0001_initial is applied before its dependency appcustom.0001_initial on database 'default'.