Django Migration Process for Elasticbeanstalk / Multiple Databases
<p>I am developing a small web application using Django and Elasticbeanstalk.
I created a EB application with two environments (staging and production), created a RDS instance and assigned it to my EB environments. </p>

<p>For development I use a local database, because deploying to AWS takes quite some time.</p>

<p>However, I am having troubles with the migrations. Because I develop and test locally every couple of minutes, I tend to have different migrations locally and on the two environments.</p>

<p>So once I deploy the current version of the app to a certain environment, the "manage.py migrate" fails most of the times because tables already exist or do not exist even though they should (because another environment already created the tables).</p>

<p>So I was wondering how to handle the migration process when using multiple environments for development, staging and production with some common and some exclusive database instances that might not reflect the same structure all the time?</p>

<p>Should I exclude the migration files from the code repository and the eb deployment and run makemigrations &amp; migrate after every deployment? Should I not run migrations automatically using the .ebextensions and apply all the migrations manually through one of the instances?</p>

<p>What's the recommended way of using the same Django application with different database instances on different environments?</p>

<p>Seems that you might have deleted the table or migrations at some point of time.</p>

<p>When you run makemigrations, django create migratins and when you run migrate, it creates database whichever is specified in settings file.</p>

<p>One thing is if you keep on creating migrations and do not run it in a particular database, it will be absolutely fine. Whenever you switch to databsse and run migrations, it will handle it as every  database will store the point upto which migrations have been run until now in django-migrations table and will start running next migrations only.</p>

<p>To solve your problem, you can delete all databases and migration files and start afresh as you are perhaps testing right now. Things will go fine untill you delete a migration or a database in any of the server.</p>

<p>If you have precious data, you should get into migration files and tables to analyse and manage things.</p>

python django amazon-web-services elastic-beanstalk django-migrations