コミットを比較
1
コミット
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
5840987162 |
@@ -0,0 +1,5 @@
|
|||||||
|
class AddLinkedTagIdsToNicoTagVersions < ActiveRecord::Migration[8.0]
|
||||||
|
def change
|
||||||
|
add_column :nico_tag_versions, :linked_tag_ids, :text
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
class MigrateLinkedTagsInNicoTagVersions < ActiveRecord::Migration[8.0]
|
||||||
|
class MigrationTagVersion < ActiveRecord::Base
|
||||||
|
self.table_name = 'tag_versions'
|
||||||
|
end
|
||||||
|
|
||||||
|
class MigrationNicoTagVersion < ActiveRecord::Base
|
||||||
|
self.table_name = 'nico_tag_versions'
|
||||||
|
end
|
||||||
|
|
||||||
|
def up
|
||||||
|
# 除票外部タグの恢復はないので除票履歴があれば全消しでよいはず.
|
||||||
|
execute <<~SQL
|
||||||
|
DELETE
|
||||||
|
t1
|
||||||
|
FROM
|
||||||
|
nico_tag_versions t1
|
||||||
|
INNER JOIN
|
||||||
|
nico_tag_versions t2
|
||||||
|
ON
|
||||||
|
t1.tag_id = t2.tag_id
|
||||||
|
AND t2.event_type = 'discard'
|
||||||
|
SQL
|
||||||
|
|
||||||
|
MigrationNicoTagVersion.find_each do |ntv|
|
||||||
|
linked_tag_ids = ntv.linked_tags.split.map { |name|
|
||||||
|
# 厳密には一意ぢゃないけどめんだぅだからこれでいいや.
|
||||||
|
MigrationTagVersion
|
||||||
|
.order(created_at: :desc, id: :desc)
|
||||||
|
.find_by("names ->> '$.ja.name' = ?", name)
|
||||||
|
&.tag_id
|
||||||
|
}.compact.uniq.sort.join(' ')
|
||||||
|
|
||||||
|
ntv.update_columns(linked_tag_ids:)
|
||||||
|
end
|
||||||
|
|
||||||
|
change_column_null :nico_tag_versions, :linked_tag_ids, false
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
raise ActiveRecord::IrreversibleMigration, '戻せません.'
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
class RemoveLinkedTagsFromNicoTagVersions < ActiveRecord::Migration[8.0]
|
||||||
|
def change
|
||||||
|
remove_column :nico_tag_versions, :linked_tags
|
||||||
|
remove_column :nico_tag_versions, :name
|
||||||
|
end
|
||||||
|
end
|
||||||
生成ファイル
+2
-3
@@ -10,7 +10,7 @@
|
|||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[8.0].define(version: 2026_10_15_010000) do
|
ActiveRecord::Schema[8.0].define(version: 2026_11_08_020000) do
|
||||||
create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||||
t.string "name", null: false
|
t.string "name", null: false
|
||||||
t.string "record_type", null: false
|
t.string "record_type", null: false
|
||||||
@@ -301,10 +301,9 @@ ActiveRecord::Schema[8.0].define(version: 2026_10_15_010000) do
|
|||||||
t.bigint "tag_id", null: false
|
t.bigint "tag_id", null: false
|
||||||
t.integer "version_no", null: false
|
t.integer "version_no", null: false
|
||||||
t.string "event_type", null: false
|
t.string "event_type", null: false
|
||||||
t.string "name", null: false
|
|
||||||
t.text "linked_tags", null: false
|
|
||||||
t.datetime "created_at", null: false
|
t.datetime "created_at", null: false
|
||||||
t.bigint "created_by_user_id"
|
t.bigint "created_by_user_id"
|
||||||
|
t.text "linked_tag_ids", null: false
|
||||||
t.index ["created_at"], name: "index_nico_tag_versions_on_created_at"
|
t.index ["created_at"], name: "index_nico_tag_versions_on_created_at"
|
||||||
t.index ["created_by_user_id", "created_at"], name: "index_nico_tag_versions_on_created_by_user_id_and_created_at", order: { created_at: :desc }
|
t.index ["created_by_user_id", "created_at"], name: "index_nico_tag_versions_on_created_by_user_id_and_created_at", order: { created_at: :desc }
|
||||||
t.index ["tag_id", "created_at"], name: "index_nico_tag_versions_on_tag_id_and_created_at", order: { created_at: :desc }
|
t.index ["tag_id", "created_at"], name: "index_nico_tag_versions_on_tag_id_and_created_at", order: { created_at: :desc }
|
||||||
|
|||||||
新しいイシューから参照
ユーザーをブロックする