Initial commit on Forgejo
Fresh repository history for elektrine/tarakan hosted at https://git.elektrine.com/elektrine/tarakan.
This commit is contained in:
commit
af6077b9c3
455 changed files with 78366 additions and 0 deletions
22
priv/repo/migrations/20260712040215_create_votes.exs
Normal file
22
priv/repo/migrations/20260712040215_create_votes.exs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
defmodule Tarakan.Repo.Migrations.CreateVotes do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
create table(:votes) do
|
||||
add :account_id, references(:accounts, on_delete: :delete_all), null: false
|
||||
# Polymorphic by (subject_type, subject_id): "finding" -> scan_findings,
|
||||
# "comment" -> finding_comments. Kept generic so new votable kinds don't
|
||||
# need a new table.
|
||||
add :subject_type, :string, null: false
|
||||
add :subject_id, :bigint, null: false
|
||||
add :value, :integer, null: false
|
||||
|
||||
timestamps(type: :utc_datetime_usec)
|
||||
end
|
||||
|
||||
# One standing vote per account per item; recasting updates value.
|
||||
create unique_index(:votes, [:account_id, :subject_type, :subject_id])
|
||||
create index(:votes, [:subject_type, :subject_id])
|
||||
create constraint(:votes, :votes_value_must_be_unit, check: "value IN (-1, 1)")
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue