Skip to content

Commit

Permalink
add counter_cache migration to phoenix
Browse files Browse the repository at this point in the history
  • Loading branch information
stepchud committed Jan 13, 2025
1 parent 9e5dd78 commit 091e8cc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
defmodule ChallengeGov.Repo.Migrations.AddPhasesSubmissionsCount do
use Ecto.Migration

def change do
alter table("phases") do
add_if_not_exists :submissions_count, :integer, null: false, default: 0
end
end
end
1 change: 1 addition & 0 deletions test/challenge_gov/submissions_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ defmodule ChallengeGov.SubmissionsTest do
%{"title" => "New Test Title", "terms_accepted" => "true", "review_verified" => "true"},
challenge
)

# does not increment submissions_count when submitted status doesn't change
{:ok, phase} = ChallengeGov.Phases.get(phase.id)
assert phase.submissions_count == 1
Expand Down

0 comments on commit 091e8cc

Please sign in to comment.