DJANGO migrate big database from SQLite3 to PostgreSQL
I have a relatively bid database with around 50 model classes in DJANGO and I would like to migrate it from SQLite3 to PostgreSQL.
I set up a dummy local PSQL for testing. I read on multiple other posts to do the following:
- dump the db
- Change SQL credentials in setup.py
- migrate
- load the db
I was able to dump the DB into a json file. After I changed my settings to look like this:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'test_db_name',
'USER': 'test',
'PASSWORD': 'test',
'HOST': 'localhost',
'PORT': '',
}
}
I created the DB by hand, because I was getting errors that it does not exists.
After this if I run python3 manage.py migrate
I got a bunch of errors, that tables dont exists, so it is not doing what I wanted.
End of the long error:
django.db.utils.ProgrammingError: relation "gympro_gymclasstype" does not exist
LINE 1: ...."type", "gympro_gymclasstype"."description" FROM "gympro_gy...
I also saw on other posts that I should reset the migratons, so I tried python3 manage.py --fake appname zero
. This also failed, so what I tried is I put the old SQLite3 cretendials back, made the fake reset, I check with showmigrations
that the current status sits at init
, changed the SQL credentials to PSQL, tried migrate again, but no luck, same errors.
What am I doing wrong?