From c7515b2981c0fbca985751f54e7493e129176b86 Mon Sep 17 00:00:00 2001 From: Joshua Potter Date: Tue, 5 Dec 2023 16:06:25 -0700 Subject: [PATCH] Maintain order on languages. --- lib/boardwise/languages.ex | 4 +++- .../migrations/20231205230009_language_pos.exs | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 priv/repo/migrations/20231205230009_language_pos.exs diff --git a/lib/boardwise/languages.ex b/lib/boardwise/languages.ex index a19b6c0..185c01f 100644 --- a/lib/boardwise/languages.ex +++ b/lib/boardwise/languages.ex @@ -20,7 +20,9 @@ defmodule BoardWise.Languages do """ def list_languages do - Repo.all(Language, prefix: @prefix) + Language + |> order_by(:pos) + |> Repo.all(prefix: @prefix) end @doc """ diff --git a/priv/repo/migrations/20231205230009_language_pos.exs b/priv/repo/migrations/20231205230009_language_pos.exs new file mode 100644 index 0000000..cdfcc61 --- /dev/null +++ b/priv/repo/migrations/20231205230009_language_pos.exs @@ -0,0 +1,16 @@ +defmodule BoardWise.Repo.Migrations.LanguagePos do + use Ecto.Migration + + alias BoardWise.Languages.Language + + @prefix "coach_scraper" + + def change do + # We'll just recreate all the entries in the table. + BoardWise.Repo.delete_all(Language, prefix: @prefix) + + alter table(:languages, prefix: @prefix) do + add :pos, :integer, null: false + end + end +end