summaryrefslogtreecommitdiff
path: root/priv/repo/migrations/20220415015055_create_post_votes.exs
blob: 444a89c360b335abd5688823f9acf6ff304a7d5c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
defmodule Aggiedit.Repo.Migrations.CreatePostVotes do
  use Ecto.Migration

  def change do
    create table(:post_votes) do
      add :is_up, :boolean
      add :user_id, references(:users, on_delete: :nothing)
      add :post_id, references(:posts, on_delete: :delete_all)

      timestamps()
    end

    create unique_index(:post_votes, [:user_id, :post_id])
  end
end