summaryrefslogtreecommitdiff
path: root/priv/repo/migrations/20220415015055_create_post_votes.exs
diff options
context:
space:
mode:
Diffstat (limited to 'priv/repo/migrations/20220415015055_create_post_votes.exs')
-rw-r--r--priv/repo/migrations/20220415015055_create_post_votes.exs15
1 files changed, 15 insertions, 0 deletions
diff --git a/priv/repo/migrations/20220415015055_create_post_votes.exs b/priv/repo/migrations/20220415015055_create_post_votes.exs
new file mode 100644
index 0000000..444a89c
--- /dev/null
+++ b/priv/repo/migrations/20220415015055_create_post_votes.exs
@@ -0,0 +1,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