From fce622b5b1959892b6f6ea94bfe3a1c4eb52d8dd Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Sat, 14 Oct 2023 11:12:05 -0400 Subject: Added comment replying --- db/migrate/20231014141657_add_reply_to_comment.rb | 5 +++++ db/schema.rb | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20231014141657_add_reply_to_comment.rb (limited to 'db') diff --git a/db/migrate/20231014141657_add_reply_to_comment.rb b/db/migrate/20231014141657_add_reply_to_comment.rb new file mode 100644 index 0000000..8e7b445 --- /dev/null +++ b/db/migrate/20231014141657_add_reply_to_comment.rb @@ -0,0 +1,5 @@ +class AddReplyToComment < ActiveRecord::Migration[7.0] + def change + add_reference :comments, :reply_to, foreign_key: { to_table: :comments } + end +end diff --git a/db/schema.rb b/db/schema.rb index 56fd9bb..49c7925 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_10_14_140431) do +ActiveRecord::Schema[7.0].define(version: 2023_10_14_141657) do create_table "audits", force: :cascade do |t| t.integer "auditable_id" t.string "auditable_type" @@ -68,7 +68,9 @@ ActiveRecord::Schema[7.0].define(version: 2023_10_14_140431) do t.datetime "published_at" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.integer "reply_to_id" t.index ["blog_id"], name: "index_comments_on_blog_id" + t.index ["reply_to_id"], name: "index_comments_on_reply_to_id" end create_table "games", force: :cascade do |t| @@ -362,6 +364,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_10_14_140431) do add_foreign_key "blogs", "users" add_foreign_key "comments", "blogs" + add_foreign_key "comments", "comments", column: "reply_to_id" add_foreign_key "pokeviewer_items", "pokeviewer_moves", column: "move_id" add_foreign_key "pokeviewer_pokedex_entries", "pokeviewer_species", column: "species_id" add_foreign_key "pokeviewer_pokedex_entries", "pokeviewer_trainers", column: "trainer_id" -- cgit 1.4.1