feat: prevent join requests with equal mail
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
40a4461d23
commit
086ecdcb1b
22 changed files with 534 additions and 11 deletions
|
|
@ -0,0 +1,30 @@
|
|||
defmodule Mv.Repo.Migrations.AddReviewedByDisplayToJoinRequests do
|
||||
@moduledoc """
|
||||
Adds reviewed_by_display to join_requests for showing reviewer in UI without loading User.
|
||||
|
||||
Backfills existing rows from users.email where reviewed_by_user_id is set.
|
||||
"""
|
||||
|
||||
use Ecto.Migration
|
||||
|
||||
def up do
|
||||
alter table(:join_requests) do
|
||||
add :reviewed_by_display, :text
|
||||
end
|
||||
|
||||
# Backfill from users.email for rows that have reviewed_by_user_id
|
||||
execute """
|
||||
UPDATE join_requests j
|
||||
SET reviewed_by_display = u.email
|
||||
FROM users u
|
||||
WHERE j.reviewed_by_user_id = u.id
|
||||
AND j.reviewed_by_user_id IS NOT NULL
|
||||
"""
|
||||
end
|
||||
|
||||
def down do
|
||||
alter table(:join_requests) do
|
||||
remove :reviewed_by_display
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue