Reputation: 461
Something seems to be occurring with my django app. There are two models, one where I altered and the other a new addition. Ever since these two changes my makemigrations
and migrate
has continued to be the same changed with the migration number incrementing.
When I makemigrations
:
Migrations for 'om':
0033_auto_20200122_0001.py:
- Alter field delivery_date on growerpurchaseorderitem
Migrations for 'accounts':
0105_auto_20200122_0001.py:
- Alter field created on pushtoken
- Alter field push_token on pushtoken
And when I migrate
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
Rendering model states... DONE
Applying accounts.0105_auto_20200122_0001... OK
Applying om.0033_auto_20200122_0001... OK
I have tried to fake a migration to get past this but no luck. It is an issue as any new changes are not registering to my models.
EDIT:
Show migrations:
for my om
[X] 0030_auto_20200121_2339
[X] 0031_auto_20200121_2343
[X] 0032_auto_20200121_2348
[X] 0033_auto_20200122_0001
for my accounts
[X] 0099_certpdf_expiration_date
[X] 0100_pushtoken
[X] 0101_auto_20200121_2145
[X] 0102_auto_20200121_2339
[X] 0103_auto_20200121_2343
[X] 0104_auto_20200121_2348
[X] 0105_auto_20200122_0001
Upvotes: 4
Views: 1656
Reputation: 1
I had a similar problem in the last few days.
I've created migrations and migrated
Then, without any code changes, I've used '-makemigrations' again to check if all was alright
Django just created the new migration, with the next migration number and all changes that were already migrated with the previous migration.
My DB was in sync with my migration folder, all DB tables were in order, no issues in using the app.
I** tried this a few times and Django always created a new migration file with the next sequence number.
Then I noticed I had some attributes which I wanted to define later, so I kept them empty (e. g. help_text=_("") ). I got the idea that might be a problem and just filled the text.
AND VOILA! After that, I made makemigrations & migration, then checked again > all was finally in sync >> the new (repeated) migration was not created!
Maybe this can help in some cases.
Upvotes: 0
Reputation: 1
Whatever the problem with migrate, just delete lastly auto created files in the migrations folder and do it again.
You can also edit it directly and run:
python manage.py makemigrations
python manage.py migrate
Upvotes: 0
Reputation: 2383
According to my research, this is most likely the point where the program gets awry:
Synchronizing apps without migrations:
Try creating the migrations and then fake the first migration:
python manage.py makemigrations <app_name>
python manage.py migrate --fake-initial
Where the commands will skip any migration where the tables were already created.
P.S. If you don't know what fake migrations are, check out the explanation.
Upvotes: 2