I am working with Django v4.* which I connected it to Postgres DB on the localhost,
I have created my model (Article) then makemigrations
then migrate
then I have changed the model by adding extra field, as a result it didn't take effect so I have deleted the table and all the migrations files in articles/migrations
folder apart of the __init__.py
file, then I did makemigrations
then migrate
it create a new file 0001_initial.py
but its not creating a new table into the DB, unless I drop the whole DB, which is not ideal in the production env!
I am wondering why Django is unable to create the table back again? and how I can get it created as a new table?
CodePudding user response:
Roll back to your initial migration by running below command:
python manage.py migrate --fake <appname> 0001
Followed by:
python manage.py migrate <appname>
CodePudding user response:
Just delete your database with
python manage.py flush
And delete migrations files
You may have mistyped the directory in the terminal