This commit is contained in:
2025-10-13 01:57:10 +09:00
parent 19a17e7ba7
commit 14f67b02e2
9 changed files with 171 additions and 54 deletions
@@ -0,0 +1,18 @@
class AddDiscardToPostTags < ActiveRecord::Migration[8.0]
def change
add_column :post_tags, :discarded_at, :datetime
add_index :post_tags, :discarded_at
add_column :post_tags, :is_active, :boolean,
as: 'discarded_at IS NULL', stored: true
add_column :post_tags, :active_unique_key, :string,
as: "CASE WHEN discarded_at IS NULL THEN CONCAT(post_id, ':', tag_id) ELSE NULL END",
stored: true
add_index :post_tags, :active_unique_key, unique: true, name: 'idx_post_tags_active_unique'
add_index :post_tags, [:post_id, :discarded_at]
add_index :post_tags, [:tag_id, :discarded_at]
end
end