Search code examples
djangoamazon-web-servicesamazon-elastic-beanstalk

Why not makemigrations in Elastic Beanstalk Config File Django?


Go to aws's setup guide for deploying a django app to elastic beanstalk here and go to the "Add a database migration configuration file" section.

You'll see that in the db-migrate.config file, they migrate the django app when it is deployed. I am wondering why they do not run makemigrations as well?

Thanks!


Solution

  • I'm no expert on django, but from what I can understand (e.g. here), makemigrations should be run when you change your existing models.

    In the tutorial there are no changes made to existing models, thus its not executed.

    If you want you can add makemigrations command to the db-migrate.config and check if it will have effect.

    Possible new version of db-migrate.config:

    container_commands:
      10_makemigrate:
        command: "python manage.py makemigrations"
        leader_only: true
      20_migrate:
        command: "django-admin.py migrate"
        leader_only: true
    option_settings:
      aws:elasticbeanstalk:application:environment:
        DJANGO_SETTINGS_MODULE: ebdjango.settings