从一个灵药应用程序的发布中进行Ecto迁移

问题描述:

我已经发布了我的灵丹应用程序。
它在应用程序启动时开始运行使用数据库的监督任务。从一个灵药应用程序的发布中进行Ecto迁移

当数据库未迁移时,任务保持错误,应用程序终止。

我读http://blog.firstiwaslike.com/elixir-deployments-with-distillery-running-ecto-migrations/,https://hexdocs.pm/distillery/running-migrations.html,并试图实现他们后面的迁移功能,但失败,因为应用程序需要启动加载应用程序的配置,并使命令终止。

当我运行Application.get_all_env(:my_app)而未启动我的应用程序时,它将返回空列表[]。 反正有没有启动应用程序运行Ecto.Migrator.run(MyApp.Repo, path, :up, all: true)

Application.load(:my_app)加载应用程序就可以访问env就足够了 - 它不需要启动。

distillery documentation中提供了有关运行版本迁移的详细指南。