mirror of
https://github.com/outbackdingo/firezone.git
synced 2026-01-27 10:18:54 +00:00
refactor(portal): rename conditional->manual (#9612)
These only have one condition - to run manually. `manual migrations` better implies that these migrations _must_ typically be run manually.
This commit is contained in:
@@ -263,10 +263,10 @@ defmodule Domain.Config.Definitions do
|
||||
##############################################
|
||||
|
||||
@doc """
|
||||
Whether to run migrations in the priv/repo/conditional_migrations directory.
|
||||
Whether to run migrations in the priv/repo/manual_migrations directory.
|
||||
If set to false, these migrations must be manually run from an IEx shell.
|
||||
"""
|
||||
defconfig(:run_conditional_migrations, :boolean, default: false)
|
||||
defconfig(:run_manual_migrations, :boolean, default: false)
|
||||
|
||||
@doc """
|
||||
PostgreSQL host.
|
||||
|
||||
@@ -8,19 +8,19 @@ defmodule Domain.Release do
|
||||
IO.puts("Starting sentry app..")
|
||||
{:ok, _} = Application.ensure_all_started(:sentry)
|
||||
|
||||
conditional =
|
||||
manual =
|
||||
Keyword.get(
|
||||
opts,
|
||||
:conditional,
|
||||
:manual,
|
||||
Application.get_env(
|
||||
:domain,
|
||||
:run_conditional_migrations,
|
||||
System.get_env("RUN_CONDITIONAL_MIGRATIONS") == "true"
|
||||
:run_manual_migrations,
|
||||
System.get_env("RUN_MANUAL_MIGRATIONS") == "true"
|
||||
)
|
||||
)
|
||||
|
||||
for repo <- @repos do
|
||||
{:ok, _, _} = do_migration(repo, conditional)
|
||||
{:ok, _, _} = do_migration(repo, manual)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -51,15 +51,15 @@ defmodule Domain.Release do
|
||||
end
|
||||
end
|
||||
|
||||
defp do_migration(repo, conditional) do
|
||||
defp do_migration(repo, manual) do
|
||||
default_path = priv_dir(@otp_app, ["repo", "migrations"])
|
||||
conditional_path = priv_dir(@otp_app, ["repo", "conditional_migrations"])
|
||||
manual_path = priv_dir(@otp_app, ["repo", "manual_migrations"])
|
||||
|
||||
paths =
|
||||
if conditional do
|
||||
if manual do
|
||||
[
|
||||
default_path,
|
||||
conditional_path
|
||||
manual_path
|
||||
]
|
||||
else
|
||||
[
|
||||
@@ -70,18 +70,18 @@ defmodule Domain.Release do
|
||||
Ecto.Migrator.with_repo(repo, fn repo ->
|
||||
Ecto.Migrator.run(repo, paths, :up, all: true)
|
||||
|
||||
unless conditional do
|
||||
check_pending_conditional_migrations(@otp_app, repo)
|
||||
unless manual do
|
||||
check_pending_manual_migrations(@otp_app, repo)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
defp check_pending_conditional_migrations(app, repo) do
|
||||
conditional_path = priv_dir(app, ["repo", "conditional_migrations"])
|
||||
defp check_pending_manual_migrations(app, repo) do
|
||||
manual_path = priv_dir(app, ["repo", "manual_migrations"])
|
||||
|
||||
if File.dir?(conditional_path) do
|
||||
# Get all migrations from the conditional directory
|
||||
case Ecto.Migrator.migrations(repo, conditional_path) do
|
||||
if File.dir?(manual_path) do
|
||||
# Get all migrations from the manual directory
|
||||
case Ecto.Migrator.migrations(repo, manual_path) do
|
||||
[] ->
|
||||
:ok
|
||||
|
||||
@@ -97,10 +97,10 @@ defmodule Domain.Release do
|
||||
|
||||
defp maybe_log_error(pending) do
|
||||
error = """
|
||||
#{pending} pending conditional migration(s) were not run because run_conditional_migrations is false.
|
||||
#{pending} pending manual migration(s) were not run because run_manual_migrations is false.
|
||||
Run the following command from an IEx shell when you're ready to execute them:
|
||||
|
||||
Domain.Release.migrate(conditional: true)
|
||||
Domain.Release.migrate(manual: true)
|
||||
"""
|
||||
|
||||
Logger.error(error)
|
||||
|
||||
@@ -17,8 +17,8 @@ config :domain, generators: [binary_id: true, context_app: :domain]
|
||||
|
||||
config :domain, sql_sandbox: false
|
||||
|
||||
# Don't run conditional migrations by default
|
||||
config :domain, run_conditional_migrations: false
|
||||
# Don't run manual migrations by default
|
||||
config :domain, run_manual_migrations: false
|
||||
|
||||
config :domain, Domain.Repo,
|
||||
hostname: "localhost",
|
||||
|
||||
@@ -13,7 +13,7 @@ config :domain, Domain.Repo,
|
||||
|
||||
config :domain, outbound_email_adapter_configured?: true
|
||||
|
||||
config :domain, run_conditional_migrations: true
|
||||
config :domain, run_manual_migrations: true
|
||||
|
||||
config :domain, Domain.Billing,
|
||||
enabled: System.get_env("BILLING_ENABLED", "false") == "true",
|
||||
|
||||
@@ -42,7 +42,7 @@ if config_env() == :prod do
|
||||
database: env_var_to_config!(:database_name)
|
||||
]
|
||||
|
||||
config :domain, run_conditional_migrations: env_var_to_config!(:run_conditional_migrations)
|
||||
config :domain, run_manual_migrations: env_var_to_config!(:run_manual_migrations)
|
||||
|
||||
config :domain, Domain.Tokens,
|
||||
key_base: env_var_to_config!(:tokens_key_base),
|
||||
|
||||
@@ -13,7 +13,7 @@ partition_suffix =
|
||||
|
||||
config :domain, sql_sandbox: true
|
||||
|
||||
config :domain, run_conditional_migrations: true
|
||||
config :domain, run_manual_migrations: true
|
||||
|
||||
config :domain, Domain.Repo,
|
||||
database: "firezone_test#{partition_suffix}",
|
||||
|
||||
@@ -56,7 +56,7 @@ defmodule Firezone.MixProject do
|
||||
|
||||
defp aliases do
|
||||
migration_args =
|
||||
"--migrations-path apps/domain/priv/repo/migrations --migrations-path apps/domain/priv/repo/conditional_migrations"
|
||||
"--migrations-path apps/domain/priv/repo/migrations --migrations-path apps/domain/priv/repo/manual_migrations"
|
||||
|
||||
[
|
||||
"ecto.migrate": ["ecto.migrate #{migration_args}"],
|
||||
|
||||
Reference in New Issue
Block a user