From 72d24c8c8081173ad6c3942bc9b4bcb2a8f9d030 Mon Sep 17 00:00:00 2001 From: miteruzo Date: Mon, 16 Mar 2026 12:33:14 +0900 Subject: [PATCH] #295 --- .../migrate/20260316082500_create_theatres.rb | 15 ++++++++ .../20260316083500_create_theatre_comments.rb | 12 ++++++ backend/db/schema.rb | 37 ++++++++++++++++++- 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 backend/db/migrate/20260316082500_create_theatres.rb create mode 100644 backend/db/migrate/20260316083500_create_theatre_comments.rb diff --git a/backend/db/migrate/20260316082500_create_theatres.rb b/backend/db/migrate/20260316082500_create_theatres.rb new file mode 100644 index 0000000..828623a --- /dev/null +++ b/backend/db/migrate/20260316082500_create_theatres.rb @@ -0,0 +1,15 @@ +class CreateTheatres < ActiveRecord::Migration[8.0] + def change + create_table :theatres do |t| + t.string :name + t.datetime :opens_at, null: false, index: true + t.datetime :closes_at, index: true + t.references :current_post, foreign_key: { to_table: :posts }, index: true + t.datetime :current_post_started_at + t.integer :next_comment_no, null: false, default: 1 + t.references :created_by_user, null: false, foreign_key: { to_table: :users }, index: true + t.timestamps + t.datetime :discarded_at, index: true + end + end +end diff --git a/backend/db/migrate/20260316083500_create_theatre_comments.rb b/backend/db/migrate/20260316083500_create_theatre_comments.rb new file mode 100644 index 0000000..070156b --- /dev/null +++ b/backend/db/migrate/20260316083500_create_theatre_comments.rb @@ -0,0 +1,12 @@ +class CreateTheatreComments < ActiveRecord::Migration[8.0] + def change + create_table :theatre_comments, primary_key: [:theatre_id, :no] do |t| + t.references :theatre, null: false, foreign_key: { to_table: :theatres } + t.integer :no, null: false + t.references :user, foreign_key: { to_table: :users } + t.text :content, null: false + t.timestamps + t.datetime :discarded_at, index: true + end + end +end diff --git a/backend/db/schema.rb b/backend/db/schema.rb index b6eb1f3..05b9aa0 100644 --- a/backend/db/schema.rb +++ b/backend/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.0].define(version: 2026_03_11_232300) do +ActiveRecord::Schema[8.0].define(version: 2026_03_16_083500) do create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.string "name", null: false t.string "record_type", null: false @@ -167,6 +167,37 @@ ActiveRecord::Schema[8.0].define(version: 2026_03_11_232300) do t.index ["tag_name_id"], name: "index_tags_on_tag_name_id", unique: true end + create_table "theatre_comments", primary_key: ["theatre_id", "no"], charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.bigint "theatre_id", null: false + t.integer "no", null: false + t.bigint "user_id" + t.text "content", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.datetime "discarded_at" + t.index ["discarded_at"], name: "index_theatre_comments_on_discarded_at" + t.index ["theatre_id"], name: "index_theatre_comments_on_theatre_id" + t.index ["user_id"], name: "index_theatre_comments_on_user_id" + end + + create_table "theatres", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.string "name" + t.datetime "opens_at", null: false + t.datetime "closes_at" + t.bigint "current_post_id" + t.datetime "current_post_started_at" + t.integer "next_comment_no", default: 1, null: false + t.bigint "created_by_user_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.datetime "discarded_at" + t.index ["closes_at"], name: "index_theatres_on_closes_at" + t.index ["created_by_user_id"], name: "index_theatres_on_created_by_user_id" + t.index ["current_post_id"], name: "index_theatres_on_current_post_id" + t.index ["discarded_at"], name: "index_theatres_on_discarded_at" + t.index ["opens_at"], name: "index_theatres_on_opens_at" + end + create_table "user_ips", primary_key: ["user_id", "ip_address_id"], charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| t.bigint "user_id", null: false t.bigint "ip_address_id", null: false @@ -262,6 +293,10 @@ ActiveRecord::Schema[8.0].define(version: 2026_03_11_232300) do add_foreign_key "tag_similarities", "tags" add_foreign_key "tag_similarities", "tags", column: "target_tag_id" add_foreign_key "tags", "tag_names" + add_foreign_key "theatre_comments", "theatres" + add_foreign_key "theatre_comments", "users" + add_foreign_key "theatres", "posts", column: "current_post_id" + add_foreign_key "theatres", "users", column: "created_by_user_id" add_foreign_key "user_ips", "ip_addresses" add_foreign_key "user_ips", "users" add_foreign_key "user_post_views", "posts"