从 elixir 应用程序的发布中执行 Ecto 迁移
Do Ecto migration from a release of an elixir app
我已经发布了我的 elixir 应用程序。
当应用程序启动时,它开始 运行 使用 DB 的监督任务。
未迁移数据库时,任务保持错误并终止应用程序。
我阅读了http://blog.firstiwaslike.com/elixir-deployments-with-distillery-running-ecto-migrations/, https://hexdocs.pm/distillery/running-migrations.html,并尝试按照它们实现迁移功能,但失败了,因为需要启动该应用程序以加载该应用程序的配置并导致命令终止。
当我 运行 Application.get_all_env(:my_app)
没有启动我的应用程序时,它 returns 空列表 []
。
运行 Ecto.Migrator.run(MyApp.Repo, path, :up, all: true)
有没有不启动应用程序的方法?
使用 Application.load(:my_app)
加载应用程序就足以访问环境 - 它不需要启动。
运行 发布迁移的详细指南可在 distillery documentation 中找到。
我已经发布了我的 elixir 应用程序。
当应用程序启动时,它开始 运行 使用 DB 的监督任务。
未迁移数据库时,任务保持错误并终止应用程序。
我阅读了http://blog.firstiwaslike.com/elixir-deployments-with-distillery-running-ecto-migrations/, https://hexdocs.pm/distillery/running-migrations.html,并尝试按照它们实现迁移功能,但失败了,因为需要启动该应用程序以加载该应用程序的配置并导致命令终止。
当我 运行 Application.get_all_env(:my_app)
没有启动我的应用程序时,它 returns 空列表 []
。
运行 Ecto.Migrator.run(MyApp.Repo, path, :up, all: true)
有没有不启动应用程序的方法?
使用 Application.load(:my_app)
加载应用程序就足以访问环境 - 它不需要启动。
运行 发布迁移的详细指南可在 distillery documentation 中找到。