Help understanding Django app creation with compose

I went through this to learn a bit about docker-compose:

However, being a Django project, it requires migrations to be run. How can I run migrations when the database is being created from a stock Prostgres image each time? It would appear that I would need to run migrations when the container starts (for those not familiar with Django, migrations maintain the db state when models are updated or changed). This stack overflow answer sets up another service, and I think I implemented it but I’m wondering if there are other ways to achieve the same result?