我在github存储库中有一个django应用程序。通过github动作,它在Azure中被部署为Python应用程序。
的azure门户网站中
在“ configuration> application”设置中
python manage.py makemigrations && python manage.py migrate
,我已经定义了post_build_command ,如为Azure应用程序服务配置Linux Python应用。
2-我配置了一个部署插槽和一个生产插槽。它提供了一个“交换”选项,将部署插槽中的实时应用推向生产。
但是,我的印象是,这样做并不能为生产Django应用程序运行post_build_command命令,而使数据库未改变 - 这意味着生产前端获得了新的字段/更新,但迁移不会发生。
执行生产迁移的最佳方法是什么?
正确的方法是将“配置> general设置> gt; gt; gt; gt; python manage.py迁移'?那会起作用吗?
I have a Django app in a Github repo. Through a Github action, it is deployed as a Python app in Azure.
In the Azure portal:
1- In "Configuration > Application" settings, I've defined POST_BUILD_COMMAND as
python manage.py makemigrations && python manage.py migrate
as described in Configure a Linux Python app for Azure App Service.
2- I have configured a deployment slot and a production slot. It offers a 'Swap' option, to push the live app in the deployment slot to production.
However, I'm under the impression that doing that doesn't run the POST_BUILD_COMMAND command for the production Django app, leaving the database unaltered - which means that the production frontend gets the new fields/updates, but the migrations don't occur.
What's the best way to perform the migrations in production?
Would the correct way be to set "Configurations > General settings > Startup Command" to 'python manage.py makemigrations && python manage.py migrate'? Would that work?
发布评论
评论(1)
执行迁移的最佳方法是使用 yaml 配置。
当我们需要安装需要安装的库时,在生产中,请小心迁移时,因为我们需要忽略, venv 文件夹。
使用实时数据创建 dev 环境,并确保在Azure Portal
上添加数据库的环境变量
上后,将环境变量创建到数据库,然后我们可以将实时数据获取到<< strong> dev 环境。
创建生产环境 repo,而不是再次从github创建连接,而是从 dev repo中转移。
将父储备作为 dev repo prod repo。使用与文档中使用的相同方法。
根据环境变量配置管道。
创建一个自动化过程以间隔更新生产环境。
python manage.py makemigrations&amp;&amp; python manage.py迁移
使用上述代码块将操作执行 dev 。使用Azure门户网站终端创建YAML文件并更改参数。
文档,是该过程的完美流参考。
github-&gt; Azure dev repo-&gt;备份 - &GT;创建 prod repo-&gt;从 dev迁移到prod - &gt;排除 gitignore 文件夹
The best way to perform the migration is using the YAML configuration.
When we have the requirement of the libraries which are needed to be installed, while in production, be careful while migrating, because we need to ignore, venv folder.
Create a dev environment with live data and make sure to add the environment variables of the database on azure portal
Once we create the environment variables to the database, then we can get live data to the dev environment.
Create the Production Environment repo and instead of creating the connection from GitHub again, take the diversion from dev repo.
Make the parent repo as dev repo for prod repo. Use the same methodology which you used in the documentation.
Configure the pipeline based on the environment variables.
Create an automation procedure to update the production environment on interval basis.
python manage.py makemigrations && python manage.py migrate
Use the above code block for performing operations into the dev. Use the Azure portal terminal to create YAML files and change the parameters.
Document, is the perfect flow reference for the procedure.
GitHub -> Azure Dev Repo -> Backup -> Create Prod Repo -> Migrate from Dev to Prod -> Exclude gitignore folder