Reviewed-on: #418 Co-authored-by: miteruzo <miteruzo@naver.com>
このコミットはプルリクエスト #418 でマージされました。
このコミットが含まれているのは:
@@ -0,0 +1,46 @@
|
||||
class DeleteDiscardedRecordsFromTags < ActiveRecord::Migration[8.0]
|
||||
def up
|
||||
remove_foreign_key :tag_versions, :tags, column: :tag_id
|
||||
remove_foreign_key :nico_tag_versions, :tags, column: :tag_id
|
||||
remove_foreign_key :material_versions, :tags, column: :tag_id
|
||||
|
||||
execute <<~SQL
|
||||
DELETE
|
||||
ntr
|
||||
FROM
|
||||
nico_tag_relations ntr
|
||||
INNER JOIN
|
||||
tags t
|
||||
ON
|
||||
t.discarded_at IS NOT NULL
|
||||
AND t.id IN (ntr.tag_id, ntr.nico_tag_id)
|
||||
SQL
|
||||
|
||||
execute <<~SQL
|
||||
DELETE
|
||||
ti
|
||||
FROM
|
||||
tag_implications ti
|
||||
INNER JOIN
|
||||
tags t
|
||||
ON
|
||||
t.discarded_at IS NOT NULL
|
||||
AND t.id IN (ti.tag_id, ti.parent_tag_id)
|
||||
SQL
|
||||
|
||||
execute <<~SQL
|
||||
DELETE
|
||||
FROM
|
||||
tags
|
||||
WHERE
|
||||
discarded_at IS NOT NULL
|
||||
SQL
|
||||
|
||||
remove_index :tags, :discarded_at
|
||||
remove_column :tags, :discarded_at
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration, '戻せません.'
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,18 @@
|
||||
class DeleteDiscardedRecordsFromTagNames < ActiveRecord::Migration[8.0]
|
||||
def up
|
||||
execute <<~SQL
|
||||
DELETE
|
||||
FROM
|
||||
tag_names
|
||||
WHERE
|
||||
discarded_at IS NOT NULL
|
||||
SQL
|
||||
|
||||
remove_index :tag_names, :discarded_at
|
||||
remove_column :tag_names, :discarded_at
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration, '戻せません.'
|
||||
end
|
||||
end
|
||||
生成ファイル
+1
-8
@@ -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_09_21_010000) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2026_09_21_030000) 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
|
||||
@@ -409,9 +409,7 @@ ActiveRecord::Schema[8.0].define(version: 2026_09_21_010000) do
|
||||
t.bigint "canonical_id"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.datetime "discarded_at"
|
||||
t.index ["canonical_id"], name: "index_tag_names_on_canonical_id"
|
||||
t.index ["discarded_at"], name: "index_tag_names_on_discarded_at"
|
||||
t.index ["name"], name: "index_tag_names_on_name", unique: true
|
||||
end
|
||||
|
||||
@@ -448,10 +446,8 @@ ActiveRecord::Schema[8.0].define(version: 2026_09_21_010000) do
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "post_count", default: 0, null: false
|
||||
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"
|
||||
@@ -698,7 +694,6 @@ ActiveRecord::Schema[8.0].define(version: 2026_09_21_010000) do
|
||||
add_foreign_key "material_sync_suppressions", "users", column: "created_by_user_id"
|
||||
add_foreign_key "material_versions", "materials"
|
||||
add_foreign_key "material_versions", "materials", column: "parent_id"
|
||||
add_foreign_key "material_versions", "tags"
|
||||
add_foreign_key "material_versions", "users", column: "created_by_user_id"
|
||||
add_foreign_key "material_versions", "users", column: "updated_by_user_id"
|
||||
add_foreign_key "materials", "materials", column: "parent_id"
|
||||
@@ -707,7 +702,6 @@ ActiveRecord::Schema[8.0].define(version: 2026_09_21_010000) do
|
||||
add_foreign_key "materials", "users", column: "updated_by_user_id"
|
||||
add_foreign_key "nico_tag_relations", "tags"
|
||||
add_foreign_key "nico_tag_relations", "tags", column: "nico_tag_id"
|
||||
add_foreign_key "nico_tag_versions", "tags"
|
||||
add_foreign_key "nico_tag_versions", "users", column: "created_by_user_id"
|
||||
add_foreign_key "post_implications", "posts"
|
||||
add_foreign_key "post_implications", "posts", column: "parent_post_id"
|
||||
@@ -726,7 +720,6 @@ ActiveRecord::Schema[8.0].define(version: 2026_09_21_010000) do
|
||||
add_foreign_key "tag_names", "tag_names", column: "canonical_id"
|
||||
add_foreign_key "tag_similarities", "tags"
|
||||
add_foreign_key "tag_similarities", "tags", column: "target_tag_id"
|
||||
add_foreign_key "tag_versions", "tags"
|
||||
add_foreign_key "tag_versions", "users", column: "created_by_user_id"
|
||||
add_foreign_key "tags", "tag_names"
|
||||
add_foreign_key "theatre_comments", "theatres"
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする