summaryrefslogtreecommitdiff
path: root/priv/repo/migrations
diff options
context:
space:
mode:
authorLogan Hunt <loganhunt@simponic.xyz>2022-04-15 13:00:42 -0600
committerLogan Hunt <loganhunt@simponic.xyz>2022-04-15 13:00:42 -0600
commit3cf9f4a364ac91cca30799c8379a682139425e71 (patch)
treedb94f64634e0a840b0a5d1eeef43460ef4e8dd21 /priv/repo/migrations
parentdb7c2321cd0af59f9e810e84c7d4eb83ec416458 (diff)
downloadaggiedit-3cf9f4a364ac91cca30799c8379a682139425e71.tar.gz
aggiedit-3cf9f4a364ac91cca30799c8379a682139425e71.zip
Add comments and vote models; pub/sub voting on posts
Diffstat (limited to 'priv/repo/migrations')
-rw-r--r--priv/repo/migrations/20220406185124_create_posts.exs1
-rw-r--r--priv/repo/migrations/20220415015055_create_post_votes.exs15
-rw-r--r--priv/repo/migrations/20220415021530_create_post_comments.exs16
3 files changed, 32 insertions, 0 deletions
diff --git a/priv/repo/migrations/20220406185124_create_posts.exs b/priv/repo/migrations/20220406185124_create_posts.exs
index 223265c..9febae8 100644
--- a/priv/repo/migrations/20220406185124_create_posts.exs
+++ b/priv/repo/migrations/20220406185124_create_posts.exs
@@ -5,6 +5,7 @@ defmodule Aggiedit.Repo.Migrations.CreatePosts do
create table(:posts) do
add :title, :text
add :body, :text
+ add :score, :integer, default: 0
add :user_id, references(:users, on_delete: :nothing)
add :upload_id, references(:uploads, on_delete: :nothing)
add :room_id, references(:rooms, on_delete: :nothing)
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
diff --git a/priv/repo/migrations/20220415021530_create_post_comments.exs b/priv/repo/migrations/20220415021530_create_post_comments.exs
new file mode 100644
index 0000000..14797a2
--- /dev/null
+++ b/priv/repo/migrations/20220415021530_create_post_comments.exs
@@ -0,0 +1,16 @@
+defmodule Aggiedit.Repo.Migrations.CreatePostComments do
+ use Ecto.Migration
+
+ def change do
+ create table(:post_comments) do
+ add :comment, :text
+ add :user_id, references(:users, on_delete: :delete_all)
+ add :post_id, references(:posts, on_delete: :delete_all)
+
+ timestamps()
+ end
+
+ create index(:post_comments, [:user_id])
+ create index(:post_comments, [:post_id])
+ end
+end