Using southern migrations with IBM Bluemix

For a new app using Django 1.6, I'm trying to create run.sh

one that will run initial commands on Bluemix.

I found an answer here which gives a run.sh file for inline migration which is supported in Django 1.7+

#!/bin/bash

 if [ -z "$VCAP_APP_PORT" ];
 then SERVER_PORT=80;
 else SERVER_PORT="$VCAP_APP_PORT";
 fi

 echo [$0] port is------------------- $SERVER_PORT

 python manage.py makemigrations
 python manage.py migrate

 echo "from django.contrib.auth.models import User; User.objects.create_superuser(username='username',password='password',email='you@example.com')" | python manage.py shell

 echo [$0] Starting Django Server...
 python manage.py runserver --noreload 0.0.0.0:$SERVER_PORT 

      

Is there an idempotent way to run equivalent commands ( schemamigration --auto

, migrate

) in the south?

+3


source to share


1 answer


I would highly recommend creating your migrations in production. You must create them in your local development environment and test them before committing them along with the corresponding changes to your codebase.



Migrations are written to python files in the / migrations / folder. You must move these files into your repository and push them to Bluemix (or otherwise copy them). So manage.py schemamigration should only be run during development and commit / push and then migrated manage.py can safely run wherever you deploy your project.

0


source







All Articles