python - Running Django migrations when deploying to Elastic Beanstalk -


i have django app set on elastic beanstalk , made change db have applied live db now. understand need set container command, , after checking db can see migration run, can't figure out how have more controls on migration. example, want migration run when necessary understanding, container run migration on every deploy assuming command still listed in config file. also, on occassion, given options during migration such as:

any objects realted these content types foreign key deleted. sure want delete these content types? if you're unsure, answer 'no' 

how set container command respond yes during deployment phase?

this current config file

container_commands:   01_migrate:     command: 'source /opt/python/run/venv/bin/actiate && python app/manage.py makemigrations'     command: 'source /opt/python/run/venv/bin/activate && python app/manage.py migrate' 

is there way set these 2 commands run when necessary , respond yes/no options receive during migration?

i'm not sure there specific way answer yes or no. can append --noinput container command. use --noinput option suppress user prompting, such “are sure?” confirmation messages.

try     command: 'source /opt/python/run/venv/bin/activate && python app/manage.py migrate --noinput' 

or.. can ssh elasticbean instance , run command manually. you'll have more control on migrations.

  1. install awsebcli pip install awsebcli
  2. type eb ssh environmentname
  3. navigate eb instance app directory with:

  • sudo -s
  • source /opt/python/run/venv/bin/activate
  • source /opt/python/current/env
  • cd /opt/python/current/app

  • then run command.

    ./manage.py migrate

i hope helps


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -

jdbc - Not able to establish database connection in eclipse -