Issue
I'm trying to migrate from SQLite to PostgreSQL. "makemigrations" works fine, but when I run the "migrate" command, everything gets complicated.
Hello, I'm new to using Django, and I'm encountering the following error when trying to migrate from SQLite to PostgreSQL with an new database
When I started the development of the project, I used fields like TimeField in my model. I'm attaching a snippet from my 0001_initial.py.
Later, I realized that I should use time values differently and decided to modify the model to make them of type FloatField. Snippet from my migrations file 0004_alter_test_time_human_and_more.py
I believe I understand that the issue is when I run the 'migrate' command, Django goes through all migration files, and that's where the conflict with PostgreSQL arises. Has anyone faced the same issue? Any help would be greatly appreciated.
Solution
One simple way to solve this issue, generate all migrations again. follow the steps.
Update your DB Connection to PostgreSQL (Delete tables if any already created in PostgreSQL)
Delete all migration folder and files inside migration folders in all your django apps, you created.
Generate migration again for all your apps with command. You must mention your app name in make migration command.
python manage.py makemigrations your_app1 your_app2 etc...
run migrate command
python manage.py migrate
Answered By - Vinita Sonakiya
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.