This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user