I'm deploying a Django project to AWS using Elastic Beanstalk and am stuck on migrating the database.
Where I'm at: I am able to successfully deploy my django project and load the page through mysubdomain.elasticbeanstalk.com. The page loads without error until I get to a page that needs to do a database call. I then get an error like relation "accounts_user" does not exist LINE 1: SELECT COUNT(*) FROM "accounts_user"
because my database hasn't been migrated.
What I've tried: I've tried quite a few variations of things. Fortunately there are an abundance of stackoverflow posts and a couple tutorials. Unfortunately, they all seem to be using a different version and what they suggest do not apply to my project.
It is pretty clear to me that I need to run the migration in a foobar.config
file inside the .ebextensions/
folder. Here is the base of what I want to do:
container_commands:
01_migrate:
command: "python manage.py migrate --noinput"
leader_only: true
In the logs, I see that the post deployment script tried to run but it failed. I don't receive any other info on the error, the only thing I see is something like "ERROR: 01_migrate post deployment script failed"
I find out that I need to activate the virtual environment for the command, which makes sense. From asdf I try this:
container_commands:
01_migrate:
command: "source /opt/python/run/venv/bin/activate && python rlg/manage.py migrate --noinput"
leader_only: true
But it doesn't work. In fact, through SSH I find out I don't even have a /opt/python/ folder, only /opt/aws/ and /opt/elasticbeanstalk/. All tutorials and SO questions refer to this folder but I don't have it?
VERSIONS:
Python 3.4.1, Django 1.7.7, AWS CLI 3.2.1, Postgres 9.3
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…