Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Makemigrations and Migrate keep repeating

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
like image 815
Andy Nguyen Avatar asked Oct 30 '25 17:10

Andy Nguyen


1 Answers

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.

like image 88
crimsonpython24 Avatar answered Nov 02 '25 06:11

crimsonpython24