Skip to content

Commit c374925

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 230e6e3 commit c374925

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

lib/plausible/data_migration/backfill_teams.ex

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,21 @@ defmodule Plausible.DataMigration.BackfillTeams do
1414
end
1515

1616
def run(opts \\ []) do
17+
start_cloak()
18+
1719
dry_run? = Keyword.get(opts, :dry_run?, true)
1820
Repo.transaction(fn -> backfill(dry_run?) end, timeout: :infinity)
1921
end
2022

23+
defp start_cloak() do
24+
Application.ensure_all_started(:cloak)
25+
Application.ensure_all_started(:cloak_ecto)
26+
Plausible.Auth.TOTP.Vault.start_link(key: totp_vault_key())
27+
rescue
28+
_ ->
29+
:ok
30+
end
31+
2132
defp backfill(dry_run?) do
2233
# Orphaned teams
2334

@@ -613,4 +624,10 @@ defmodule Plausible.DataMigration.BackfillTeams do
613624
defp log(msg) do
614625
IO.puts("[#{DateTime.utc_now(:second)}] #{msg}")
615626
end
627+
628+
defp totp_vault_key() do
629+
:plausible
630+
|> Application.fetch_env!(Plausible.Auth.TOTP)
631+
|> Keyword.fetch!(:vault_key)
632+
end
616633
end

0 commit comments

Comments
 (0)