From 2a7a19c93ee0e0d77e4e388d43f36a721c7ab715 Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Fri, 20 Oct 2023 21:27:06 -0400 Subject: Added post voting --- db/migrate/20231020194529_create_votes.rb | 11 +++++++++++ db/migrate/20231020195330_make_blog_votable.rb | 8 ++++++++ 2 files changed, 19 insertions(+) create mode 100644 db/migrate/20231020194529_create_votes.rb create mode 100644 db/migrate/20231020195330_make_blog_votable.rb (limited to 'db/migrate') diff --git a/db/migrate/20231020194529_create_votes.rb b/db/migrate/20231020194529_create_votes.rb new file mode 100644 index 0000000..947652b --- /dev/null +++ b/db/migrate/20231020194529_create_votes.rb @@ -0,0 +1,11 @@ +class CreateVotes < ActiveRecord::Migration[7.0] + def change + create_table :votes do |t| + t.references :votable, polymorphic: true + t.integer :upvote + t.string :ip + + t.timestamps + end + end +end diff --git a/db/migrate/20231020195330_make_blog_votable.rb b/db/migrate/20231020195330_make_blog_votable.rb new file mode 100644 index 0000000..4d1e42a --- /dev/null +++ b/db/migrate/20231020195330_make_blog_votable.rb @@ -0,0 +1,8 @@ +class MakeBlogVotable < ActiveRecord::Migration[7.0] + def change + change_table :blogs do |t| + t.integer :upvotes, default: 0, null: false + t.integer :downvotes, default: 0, null: false + end + end +end -- cgit 1.4.1