Skip to content

Commit 80cbcc4

Browse files
committed
Start cloak vault for self-hosted release migrations.
Since this one is using schemas, existing encrypted columns do require cloak to be up.
1 parent d00298f commit 80cbcc4

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lib/plausible/data_migration/backfill_teams.ex

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@ defmodule Plausible.DataMigration.BackfillTeams do
1414
end
1515

1616
def run(opts \\ []) do
17-
dry_run? = Keyword.get(opts, :dry_run?, true)
18-
Repo.transaction(fn -> backfill(dry_run?) end, timeout: :infinity)
17+
Application.ensure_all_started(:cloak)
18+
Application.ensure_all_started(:cloak_ecto)
19+
Plausible.Auth.TOTP.Vault.start_link(key: totp_vault_key())
20+
rescue
21+
_ ->
22+
:ok
23+
24+
dry_run? = Keyword.get(opts, :dry_run?, true)
25+
Repo.transaction(fn -> backfill(dry_run?) end, timeout: :infinity)
1926
end
2027

2128
defp backfill(dry_run?) do
@@ -613,4 +620,10 @@ defmodule Plausible.DataMigration.BackfillTeams do
613620
defp log(msg) do
614621
IO.puts("[#{DateTime.utc_now(:second)}] #{msg}")
615622
end
623+
624+
defp totp_vault_key() do
625+
:plausible
626+
|> Application.fetch_env!(Plausible.Auth.TOTP)
627+
|> Keyword.fetch!(:vault_key)
628+
end
616629
end

0 commit comments

Comments
 (0)