Comic Site Migration to SQLite
Postgres was the database for my comic site but I chose to migrate to sqlite because it would:
- be easier to back up
- use less resources on my server
- be one less service to manage
I also don't get a lot of traffic so it wouldn't have an impact.
The process followed this general pattern:
Change the code to use sqlite instead of postgres. I'd maintain the same paths to the static resources so that I wouldn't have to move these (I stored static resources on the host).
- Change the docker-compose yml file to:
- Use a different local port for the sqlite instance
- Use a different project name
Create a json dump from the production server using: python manage.py dumpdata --natural-foreign --natural-primary > /var/backups/comic_server/natural_dump.json
Change ansible to deploy the project to a different folder and run it.
Perform a migration and load the data with:
python manage.py migrate python manage.py loaddata /var/backups/comic_server/natural_dump.json
Verify the new instance works.
Change nginx configuration to point to the new instance.
Turn down the old instance with docker-compose down. I'll clear out the volumes once I'm sure everything is ok.
Note: python commands run in the docker-compose container by first running: docker compose exec comic_server /bin/bash