将南方迁移与 IBM Bluemix 结合使用
Using South migrations with IBM Bluemix
对于使用 Django 1.6 的新应用程序,我正在尝试创建一个 run.sh
它将 运行 Bluemix 上的初始命令。
我找到了一个答案 here,它为 Django 1.7+
支持的内置迁移提供了一个 run.sh 文件
#!/bin/bash
if [ -z "$VCAP_APP_PORT" ];
then SERVER_PORT=80;
else SERVER_PORT="$VCAP_APP_PORT";
fi
echo [[=10=]] 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 [[=10=]] Starting Django Server...
python manage.py runserver --noreload 0.0.0.0:$SERVER_PORT
是否有一种幂等的方法来 运行 南方的等效命令(schemamigration --auto
、migrate
)?
我强烈建议不要在生产环境中创建迁移。您应该在本地开发环境中创建它们,并在提交它们之前测试它们以及代码库中的相应更改。
迁移写在 /migrations/ 文件夹中的 python 文件中。您应该将这些文件提交到您的存储库并将它们推送到 Bluemix(或以其他方式复制它们)。因此 manage.py schemamigration 应该只 运行 在开发和 committed/pushed,然后 manage.py 迁移可以安全地 运行 无论你部署你的项目。
对于使用 Django 1.6 的新应用程序,我正在尝试创建一个 run.sh
它将 运行 Bluemix 上的初始命令。
我找到了一个答案 here,它为 Django 1.7+
支持的内置迁移提供了一个 run.sh 文件#!/bin/bash
if [ -z "$VCAP_APP_PORT" ];
then SERVER_PORT=80;
else SERVER_PORT="$VCAP_APP_PORT";
fi
echo [[=10=]] 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 [[=10=]] Starting Django Server...
python manage.py runserver --noreload 0.0.0.0:$SERVER_PORT
是否有一种幂等的方法来 运行 南方的等效命令(schemamigration --auto
、migrate
)?
我强烈建议不要在生产环境中创建迁移。您应该在本地开发环境中创建它们,并在提交它们之前测试它们以及代码库中的相应更改。
迁移写在 /migrations/ 文件夹中的 python 文件中。您应该将这些文件提交到您的存储库并将它们推送到 Bluemix(或以其他方式复制它们)。因此 manage.py schemamigration 应该只 运行 在开发和 committed/pushed,然后 manage.py 迁移可以安全地 运行 无论你部署你的项目。