From 5ee98d5e07a788378a2d0ef3d92e8d256c685cdf Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Tue, 15 Oct 2024 17:06:40 +0100 Subject: [PATCH] Add mix task to migrate the production database --- lib/mix/tasks/music_library/prod/db_migrate.ex | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 lib/mix/tasks/music_library/prod/db_migrate.ex diff --git a/lib/mix/tasks/music_library/prod/db_migrate.ex b/lib/mix/tasks/music_library/prod/db_migrate.ex new file mode 100644 index 00000000..0edbe293 --- /dev/null +++ b/lib/mix/tasks/music_library/prod/db_migrate.ex @@ -0,0 +1,16 @@ +defmodule Mix.Tasks.MusicLibrary.Prod.DbMigrate do + use Mix.Task + @shortdoc "Run migrations on the production database" + @moduledoc """ + Run migrations on the production database. + + Requires the `flyctl` CLI to be installed and authenticated. + """ + + @impl Mix.Task + def run(_args) do + IO.puts("Running migrations on production database") + + System.cmd("flyctl", ["ssh", "console", "--command", "bin/migrate"], into: IO.stream()) + end +end