537 B · text 5af55d9
defmodule GitGud.Labels.RepositoryOptOut do
use Ecto.Schema
import Ecto.Changeset
alias GitGud.Labels.Label
alias GitGud.Repositories.Repository
schema "repository_label_opt_outs" do
belongs_to :repository, Repository
belongs_to :label, Label
timestamps(type: :utc_datetime, updated_at: false)
end
def changeset(struct, attrs) do
struct
|> cast(attrs, [:repository_id, :label_id])
|> validate_required([:repository_id, :label_id])
|> unique_constraint([:repository_id, :label_id])
end
end