votes: add is_deleted flag to post_votes table.

Add an is_deleted flag to post_votes so they can be soft-deleted in the future.
This commit is contained in:
evazion
2021-11-21 02:35:19 -06:00
parent 35c97d0836
commit be5173c8dd
3 changed files with 29 additions and 2 deletions

View File

@@ -0,0 +1,9 @@
class AddIsDeletedToPostVotes < ActiveRecord::Migration[6.1]
disable_ddl_transaction!
def change
add_column :post_votes, :is_deleted, :boolean, default: false, null: :false
add_index :post_votes, :is_deleted, where: "is_deleted = TRUE", algorithm: :concurrently
add_index :post_votes, [:user_id, :post_id], unique: true, where: "is_deleted = FALSE", algorithm: :concurrently
end
end