Merge remote-tracking branch 'origin/main' into feature/351
このコミットが含まれているのは:
@@ -0,0 +1,10 @@
|
||||
class CreateTheatreProgrammes < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :theatre_programmes, primary_key: [:theatre_id, :position] do |t|
|
||||
t.references :theatre, null: false, foreign_key: true
|
||||
t.integer :position, null: false
|
||||
t.references :post, null: false, foreign_key: true
|
||||
t.datetime :created_at, null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,36 @@
|
||||
class CreateTheatreSkipVotesAndEvents < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :theatre_skip_votes, primary_key: [:theatre_id, :post_id, :user_id] do |t|
|
||||
t.references :theatre, null: false, foreign_key: true
|
||||
t.references :post, null: false, foreign_key: true
|
||||
t.references :user, null: false, foreign_key: true
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
create_table :theatre_skip_events do |t|
|
||||
t.references :theatre, null: false, foreign_key: true
|
||||
t.references :post, null: false, foreign_key: true
|
||||
t.references :skipped_by_user, null: false, foreign_key: { to_table: :users }
|
||||
t.integer :programme_position
|
||||
t.datetime :created_at, null: false
|
||||
end
|
||||
|
||||
create_table :theatre_skip_event_voters, primary_key: [:theatre_skip_event_id, :user_id] do |t|
|
||||
t.references :theatre_skip_event, null: false, foreign_key: true
|
||||
t.references :user, null: false, foreign_key: true
|
||||
end
|
||||
|
||||
create_table :theatre_skip_event_tags, primary_key: [:theatre_skip_event_id, :tag_id] do |t|
|
||||
t.references :theatre_skip_event, null: false, foreign_key: true
|
||||
t.references :tag, null: false, foreign_key: true
|
||||
end
|
||||
|
||||
add_index :theatre_skip_events, [:theatre_id, :created_at]
|
||||
add_index :theatre_skip_votes, [:theatre_id, :post_id, :created_at],
|
||||
name: 'idx_theatre_skip_votes_theatre_post_created'
|
||||
add_index :theatre_skip_event_voters, [:user_id, :theatre_skip_event_id],
|
||||
name: 'idx_theatre_skip_event_voters_user_event'
|
||||
add_index :theatre_skip_event_tags, [:tag_id, :theatre_skip_event_id],
|
||||
name: 'idx_theatre_skip_event_tags_tag_event'
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
class CreateGekanatorGames < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :gekanator_games do |t|
|
||||
t.references :user, null: false, foreign_key: true
|
||||
t.references :guessed_post, null: false, foreign_key: { to_table: :posts }
|
||||
t.references :correct_post, null: false, foreign_key: { to_table: :posts }
|
||||
t.boolean :won, null: false
|
||||
t.integer :question_count, null: false
|
||||
t.json :answers, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_check_constraint :gekanator_games,
|
||||
'question_count >= 0',
|
||||
name: 'chk_gekanator_games_question_count_nonnegative'
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,14 @@
|
||||
class CreateGekanatorQuestionSuggestions < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :gekanator_question_suggestions do |t|
|
||||
t.references :gekanator_game,
|
||||
null: false,
|
||||
foreign_key: { on_delete: :cascade }
|
||||
t.references :user, null: false, foreign_key: true
|
||||
t.text :question_text, null: false
|
||||
t.boolean :processed, null: false, default: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddAnswerToGekanatorQuestionSuggestions < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
add_column :gekanator_question_suggestions, :answer, :string, null: false
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,19 @@
|
||||
class CreateGekanatorQuestions < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :gekanator_questions do |t|
|
||||
t.string :text, null: false
|
||||
t.string :kind, null: false
|
||||
t.json :condition, null: false
|
||||
t.string :source, null: false, default: 'ai_generated'
|
||||
t.string :status, null: false, default: 'pending'
|
||||
t.float :priority_weight, null: false, default: 1.0
|
||||
t.references :gekanator_question_suggestion,
|
||||
null: true,
|
||||
foreign_key: true
|
||||
t.references :created_by,
|
||||
null: true,
|
||||
foreign_key: { to_table: :users }
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
class CreateGekanatorAiRuns < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :gekanator_ai_runs do |t|
|
||||
t.string :model, null: false
|
||||
t.integer :input_tokens, null: false, default: 0
|
||||
t.integer :output_tokens, null: false, default: 0
|
||||
t.decimal :estimated_cost_jpy, precision: 8, scale: 3, null: false, default: 0
|
||||
t.string :status, null: false, default: 'pending'
|
||||
t.references :gekanator_question_suggestion, null: false, foreign_key: true
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,19 @@
|
||||
class CreateGekanatorQuestionExamples < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
create_table :gekanator_question_examples do |t|
|
||||
t.references :gekanator_question, null: false, foreign_key: true
|
||||
t.references :post, null: false, foreign_key: true
|
||||
t.references :user, null: false, foreign_key: true
|
||||
t.references :gekanator_game, null: true, foreign_key: true
|
||||
t.string :answer, null: false
|
||||
t.string :source, null: false, default: 'post_game_extra'
|
||||
t.float :weight, null: false, default: 1.0
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_index :gekanator_question_examples,
|
||||
[:gekanator_question_id, :post_id, :user_id],
|
||||
unique: true,
|
||||
name: 'idx_gekanator_question_examples_on_question_post_user'
|
||||
end
|
||||
end
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
class AddAnswerStatisticsToGekanatorQuestionExamples < ActiveRecord::Migration[8.0]
|
||||
class MigrationGekanatorQuestionExample < ApplicationRecord
|
||||
self.table_name = 'gekanator_question_examples'
|
||||
end
|
||||
|
||||
def up
|
||||
add_column :gekanator_question_examples,
|
||||
:answer_counts,
|
||||
:json,
|
||||
null: true
|
||||
add_column :gekanator_question_examples,
|
||||
:sample_count,
|
||||
:integer,
|
||||
null: false,
|
||||
default: 1
|
||||
|
||||
MigrationGekanatorQuestionExample.reset_column_information
|
||||
MigrationGekanatorQuestionExample.find_each do |example|
|
||||
counts = {
|
||||
'yes' => 0,
|
||||
'no' => 0,
|
||||
'partial' => 0,
|
||||
'probably_no' => 0,
|
||||
'unknown' => 0
|
||||
}
|
||||
counts[example.answer] = 1 if counts.key?(example.answer)
|
||||
|
||||
example.update_columns(
|
||||
answer_counts: counts,
|
||||
sample_count: 1)
|
||||
end
|
||||
|
||||
change_column_null :gekanator_question_examples, :answer_counts, false
|
||||
end
|
||||
|
||||
def down
|
||||
remove_column :gekanator_question_examples, :sample_count
|
||||
remove_column :gekanator_question_examples, :answer_counts
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
class AddDeprecatedAtToTags < ActiveRecord::Migration[8.0]
|
||||
def up
|
||||
add_column :tags, :deprecated_at, :datetime, after: :category
|
||||
add_column :tag_versions, :deprecated_at, :datetime, after: :parent_tag_ids
|
||||
|
||||
add_index :tags, :deprecated_at
|
||||
|
||||
add_check_constraint :tags, "deprecated_at IS NULL OR category <> 'nico'",
|
||||
name: 'chk_tags_deprecated_at_not_nico'
|
||||
end
|
||||
|
||||
def down
|
||||
remove_check_constraint :tags, name: 'chk_tags_deprecated_at_not_nico'
|
||||
|
||||
remove_index :tags, :deprecated_at
|
||||
|
||||
remove_column :tag_versions, :deprecated_at, :datetime
|
||||
remove_column :tags, :deprecated_at
|
||||
end
|
||||
end
|
||||
生成ファイル
+151
-1
@@ -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_05_19_013100) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2026_06_21_000000) 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
|
||||
@@ -48,6 +48,79 @@ ActiveRecord::Schema[8.0].define(version: 2026_05_19_013100) do
|
||||
t.index ["tag_id"], name: "index_deerjikists_on_tag_id"
|
||||
end
|
||||
|
||||
create_table "gekanator_ai_runs", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||
t.string "model", null: false
|
||||
t.integer "input_tokens", default: 0, null: false
|
||||
t.integer "output_tokens", default: 0, null: false
|
||||
t.decimal "estimated_cost_jpy", precision: 8, scale: 3, default: "0.0", null: false
|
||||
t.string "status", default: "pending", null: false
|
||||
t.bigint "gekanator_question_suggestion_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["gekanator_question_suggestion_id"], name: "index_gekanator_ai_runs_on_gekanator_question_suggestion_id"
|
||||
end
|
||||
|
||||
create_table "gekanator_games", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||
t.bigint "user_id", null: false
|
||||
t.bigint "guessed_post_id", null: false
|
||||
t.bigint "correct_post_id", null: false
|
||||
t.boolean "won", null: false
|
||||
t.integer "question_count", null: false
|
||||
t.json "answers", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["correct_post_id"], name: "index_gekanator_games_on_correct_post_id"
|
||||
t.index ["guessed_post_id"], name: "index_gekanator_games_on_guessed_post_id"
|
||||
t.index ["user_id"], name: "index_gekanator_games_on_user_id"
|
||||
t.check_constraint "`question_count` >= 0", name: "chk_gekanator_games_question_count_nonnegative"
|
||||
end
|
||||
|
||||
create_table "gekanator_question_examples", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||
t.bigint "gekanator_question_id", null: false
|
||||
t.bigint "post_id", null: false
|
||||
t.bigint "user_id", null: false
|
||||
t.bigint "gekanator_game_id"
|
||||
t.string "answer", null: false
|
||||
t.string "source", default: "post_game_extra", null: false
|
||||
t.float "weight", default: 1.0, null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.json "answer_counts", null: false
|
||||
t.integer "sample_count", default: 1, null: false
|
||||
t.index ["gekanator_game_id"], name: "index_gekanator_question_examples_on_gekanator_game_id"
|
||||
t.index ["gekanator_question_id", "post_id", "user_id"], name: "idx_gekanator_question_examples_on_question_post_user", unique: true
|
||||
t.index ["gekanator_question_id"], name: "index_gekanator_question_examples_on_gekanator_question_id"
|
||||
t.index ["post_id"], name: "index_gekanator_question_examples_on_post_id"
|
||||
t.index ["user_id"], name: "index_gekanator_question_examples_on_user_id"
|
||||
end
|
||||
|
||||
create_table "gekanator_question_suggestions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||
t.bigint "gekanator_game_id", null: false
|
||||
t.bigint "user_id", null: false
|
||||
t.text "question_text", null: false
|
||||
t.boolean "processed", default: false, null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "answer", null: false
|
||||
t.index ["gekanator_game_id"], name: "index_gekanator_question_suggestions_on_gekanator_game_id"
|
||||
t.index ["user_id"], name: "index_gekanator_question_suggestions_on_user_id"
|
||||
end
|
||||
|
||||
create_table "gekanator_questions", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||
t.string "text", null: false
|
||||
t.string "kind", null: false
|
||||
t.json "condition", null: false
|
||||
t.string "source", default: "ai_generated", null: false
|
||||
t.string "status", default: "pending", null: false
|
||||
t.float "priority_weight", default: 1.0, null: false
|
||||
t.bigint "gekanator_question_suggestion_id"
|
||||
t.bigint "created_by_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["created_by_id"], name: "index_gekanator_questions_on_created_by_id"
|
||||
t.index ["gekanator_question_suggestion_id"], name: "index_gekanator_questions_on_gekanator_question_suggestion_id"
|
||||
end
|
||||
|
||||
create_table "ip_addresses", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||
t.binary "ip_address", limit: 16, null: false
|
||||
t.datetime "banned_at"
|
||||
@@ -262,6 +335,7 @@ ActiveRecord::Schema[8.0].define(version: 2026_05_19_013100) do
|
||||
t.string "event_type", null: false
|
||||
t.string "name", null: false
|
||||
t.string "category", null: false
|
||||
t.datetime "deprecated_at"
|
||||
t.text "aliases", null: false
|
||||
t.text "parent_tag_ids", null: false
|
||||
t.datetime "created_at", null: false
|
||||
@@ -279,10 +353,13 @@ ActiveRecord::Schema[8.0].define(version: 2026_05_19_013100) do
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "post_count", default: 0, null: false
|
||||
t.datetime "deprecated_at"
|
||||
t.datetime "discarded_at"
|
||||
t.integer "version_no", null: false
|
||||
t.index ["deprecated_at"], name: "index_tags_on_deprecated_at"
|
||||
t.index ["discarded_at"], name: "index_tags_on_discarded_at"
|
||||
t.index ["tag_name_id"], name: "index_tags_on_tag_name_id", unique: true
|
||||
t.check_constraint "(`deprecated_at` is null) or (`category` <> _utf8mb4'nico')", name: "chk_tags_deprecated_at_not_nico"
|
||||
t.check_constraint "`version_no` > 0", name: "chk_tags_version_no_positive"
|
||||
end
|
||||
|
||||
@@ -299,6 +376,55 @@ ActiveRecord::Schema[8.0].define(version: 2026_05_19_013100) do
|
||||
t.index ["user_id"], name: "index_theatre_comments_on_user_id"
|
||||
end
|
||||
|
||||
create_table "theatre_programmes", primary_key: ["theatre_id", "position"], charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||
t.bigint "theatre_id", null: false
|
||||
t.integer "position", null: false
|
||||
t.bigint "post_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.index ["post_id"], name: "index_theatre_programmes_on_post_id"
|
||||
t.index ["theatre_id"], name: "index_theatre_programmes_on_theatre_id"
|
||||
end
|
||||
|
||||
create_table "theatre_skip_event_tags", primary_key: ["theatre_skip_event_id", "tag_id"], charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||
t.bigint "theatre_skip_event_id", null: false
|
||||
t.bigint "tag_id", null: false
|
||||
t.index ["tag_id", "theatre_skip_event_id"], name: "idx_theatre_skip_event_tags_tag_event"
|
||||
t.index ["tag_id"], name: "index_theatre_skip_event_tags_on_tag_id"
|
||||
t.index ["theatre_skip_event_id"], name: "index_theatre_skip_event_tags_on_theatre_skip_event_id"
|
||||
end
|
||||
|
||||
create_table "theatre_skip_event_voters", primary_key: ["theatre_skip_event_id", "user_id"], charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||
t.bigint "theatre_skip_event_id", null: false
|
||||
t.bigint "user_id", null: false
|
||||
t.index ["theatre_skip_event_id"], name: "index_theatre_skip_event_voters_on_theatre_skip_event_id"
|
||||
t.index ["user_id", "theatre_skip_event_id"], name: "idx_theatre_skip_event_voters_user_event"
|
||||
t.index ["user_id"], name: "index_theatre_skip_event_voters_on_user_id"
|
||||
end
|
||||
|
||||
create_table "theatre_skip_events", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||
t.bigint "theatre_id", null: false
|
||||
t.bigint "post_id", null: false
|
||||
t.bigint "skipped_by_user_id", null: false
|
||||
t.integer "programme_position"
|
||||
t.datetime "created_at", null: false
|
||||
t.index ["post_id"], name: "index_theatre_skip_events_on_post_id"
|
||||
t.index ["skipped_by_user_id"], name: "index_theatre_skip_events_on_skipped_by_user_id"
|
||||
t.index ["theatre_id", "created_at"], name: "index_theatre_skip_events_on_theatre_id_and_created_at"
|
||||
t.index ["theatre_id"], name: "index_theatre_skip_events_on_theatre_id"
|
||||
end
|
||||
|
||||
create_table "theatre_skip_votes", primary_key: ["theatre_id", "post_id", "user_id"], charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||
t.bigint "theatre_id", null: false
|
||||
t.bigint "post_id", null: false
|
||||
t.bigint "user_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["post_id"], name: "index_theatre_skip_votes_on_post_id"
|
||||
t.index ["theatre_id", "post_id", "created_at"], name: "idx_theatre_skip_votes_theatre_post_created"
|
||||
t.index ["theatre_id"], name: "index_theatre_skip_votes_on_theatre_id"
|
||||
t.index ["user_id"], name: "index_theatre_skip_votes_on_user_id"
|
||||
end
|
||||
|
||||
create_table "theatre_watching_users", primary_key: ["theatre_id", "user_id"], charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||
t.bigint "theatre_id", null: false
|
||||
t.bigint "user_id", null: false
|
||||
@@ -446,6 +572,18 @@ ActiveRecord::Schema[8.0].define(version: 2026_05_19_013100) do
|
||||
|
||||
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
||||
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
||||
add_foreign_key "gekanator_ai_runs", "gekanator_question_suggestions"
|
||||
add_foreign_key "gekanator_games", "posts", column: "correct_post_id"
|
||||
add_foreign_key "gekanator_games", "posts", column: "guessed_post_id"
|
||||
add_foreign_key "gekanator_games", "users"
|
||||
add_foreign_key "gekanator_question_examples", "gekanator_games"
|
||||
add_foreign_key "gekanator_question_examples", "gekanator_questions"
|
||||
add_foreign_key "gekanator_question_examples", "posts"
|
||||
add_foreign_key "gekanator_question_examples", "users"
|
||||
add_foreign_key "gekanator_question_suggestions", "gekanator_games", on_delete: :cascade
|
||||
add_foreign_key "gekanator_question_suggestions", "users"
|
||||
add_foreign_key "gekanator_questions", "gekanator_question_suggestions"
|
||||
add_foreign_key "gekanator_questions", "users", column: "created_by_id"
|
||||
add_foreign_key "material_versions", "materials"
|
||||
add_foreign_key "material_versions", "materials", column: "parent_id"
|
||||
add_foreign_key "material_versions", "tags"
|
||||
@@ -483,6 +621,18 @@ ActiveRecord::Schema[8.0].define(version: 2026_05_19_013100) do
|
||||
add_foreign_key "tags", "tag_names"
|
||||
add_foreign_key "theatre_comments", "theatres"
|
||||
add_foreign_key "theatre_comments", "users"
|
||||
add_foreign_key "theatre_programmes", "posts"
|
||||
add_foreign_key "theatre_programmes", "theatres"
|
||||
add_foreign_key "theatre_skip_event_tags", "tags"
|
||||
add_foreign_key "theatre_skip_event_tags", "theatre_skip_events"
|
||||
add_foreign_key "theatre_skip_event_voters", "theatre_skip_events"
|
||||
add_foreign_key "theatre_skip_event_voters", "users"
|
||||
add_foreign_key "theatre_skip_events", "posts"
|
||||
add_foreign_key "theatre_skip_events", "theatres"
|
||||
add_foreign_key "theatre_skip_events", "users", column: "skipped_by_user_id"
|
||||
add_foreign_key "theatre_skip_votes", "posts"
|
||||
add_foreign_key "theatre_skip_votes", "theatres"
|
||||
add_foreign_key "theatre_skip_votes", "users"
|
||||
add_foreign_key "theatre_watching_users", "theatres"
|
||||
add_foreign_key "theatre_watching_users", "users"
|
||||
add_foreign_key "theatres", "posts", column: "current_post_id"
|
||||
|
||||
新しい課題から参照
ユーザをブロックする