Migrate django database to existing one

So I am using Django with mysql database (most basic tables, like auth, user, admin and few custom models) but I need to migrate those tables with data to a existing PostgreSQL database. The issue is that there are tables created there already. Should I create additional models in the models.py file for those models existing in the database already so that migrations will be applied correctly?

I am trying to figure what are the steps that I should take to properly switch databases in the Django app. So far what I have done is saved the data from current (mysql) database:

python manage.py dumpdata > dump.json

Now the next step I took was to change database in settings.py to postgres.

After this I save current table schemas using inspectdb. Here is where I want to ask what should be next steps(?)

  • Merge old and new models.py files.

  • Apply migrations

  • Add data from json dump file to the new database.

First export table data and take a backup or for this, he needs to clear his table data from Postgres so he or she can migrate all the tables with the existing table and also with the previous table if the data table is there at that time and create new migration with make migration first.

Back to Top