Add valuation boolean flag to Comment model

Why:

Budget Investment's valuators need to be able to comment on investments
without making those comments public. We need a way to clearly make a
distinction to avoid "leaking" internal valuation comments.

How:

Adding a boolean `valuation` attribute defaulted to false to the Comments
table, and index on it with concurrent algorithm as explained at
https://robots.thoughtbot.com/how-to-create-postgres-indexes-concurrently-in

The name `valuation` was chosen instead of `internal` because of the more
specific meaning as well as avoiding a collision with existing internal_comments
attribute on Budget::Investment model (soon to be deprecated & removed)
This commit is contained in:
Bertocq
2018-01-29 21:47:01 +01:00
parent e0e67c959b
commit c84b2f0704
3 changed files with 17 additions and 3 deletions

View File

@@ -0,0 +1,5 @@
class AddValuationFlagToComments < ActiveRecord::Migration
def change
add_column :comments, :valuation, :boolean, default: false
end
end

View File

@@ -0,0 +1,7 @@
class AddIndexToValuationComments < ActiveRecord::Migration
disable_ddl_transaction!
def change
add_index :comments, :valuation, algorithm: :concurrently
end
end

View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180119073228) do
ActiveRecord::Schema.define(version: 20180129190950) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -234,7 +234,7 @@ ActiveRecord::Schema.define(version: 20180119073228) do
t.string "commentable_type"
t.text "body"
t.string "subject"
t.integer "user_id", null: false
t.integer "user_id", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.datetime "hidden_at"
@@ -247,7 +247,8 @@ ActiveRecord::Schema.define(version: 20180119073228) do
t.integer "cached_votes_down", default: 0
t.datetime "confirmed_hide_at"
t.string "ancestry"
t.integer "confidence_score", default: 0, null: false
t.integer "confidence_score", default: 0, null: false
t.boolean "valuation", default: false
end
add_index "comments", ["ancestry"], name: "index_comments_on_ancestry", using: :btree
@@ -257,6 +258,7 @@ ActiveRecord::Schema.define(version: 20180119073228) do
add_index "comments", ["commentable_id", "commentable_type"], name: "index_comments_on_commentable_id_and_commentable_type", using: :btree
add_index "comments", ["hidden_at"], name: "index_comments_on_hidden_at", using: :btree
add_index "comments", ["user_id"], name: "index_comments_on_user_id", using: :btree
add_index "comments", ["valuation"], name: "index_comments_on_valuation", using: :btree
create_table "communities", force: :cascade do |t|
t.datetime "created_at", null: false