From bf96e8b68d6488b389d4b82bdba0250a9544e0bf Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Thu, 18 Nov 2021 18:59:28 +0530 Subject: [PATCH] choore: Change `values` to `attribute_values` in custom attributes (#3413) --- .../v1/accounts/custom_attribute_definitions_controller.rb | 2 +- app/models/custom_attribute_definition.rb | 2 +- .../api/v1/models/_custom_attribute_definition.json.jbuilder | 1 + ...es_to_attribute_values_in_custom_attribute_definitions.rb | 5 +++++ db/schema.rb | 4 ++-- 5 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20211118100301_change_values_to_attribute_values_in_custom_attribute_definitions.rb diff --git a/app/controllers/api/v1/accounts/custom_attribute_definitions_controller.rb b/app/controllers/api/v1/accounts/custom_attribute_definitions_controller.rb index 13cba46eac4e..419540438dd8 100644 --- a/app/controllers/api/v1/accounts/custom_attribute_definitions_controller.rb +++ b/app/controllers/api/v1/accounts/custom_attribute_definitions_controller.rb @@ -39,7 +39,7 @@ def permitted_payload :attribute_display_type, :attribute_key, :attribute_model, - :default_value + attribute_values: [] ) end diff --git a/app/models/custom_attribute_definition.rb b/app/models/custom_attribute_definition.rb index a79b8ca957cd..94a41beea1e3 100644 --- a/app/models/custom_attribute_definition.rb +++ b/app/models/custom_attribute_definition.rb @@ -8,8 +8,8 @@ # attribute_display_type :integer default("text") # attribute_key :string # attribute_model :integer default("conversation_attribute") +# attribute_values :jsonb # default_value :integer -# values :jsonb # created_at :datetime not null # updated_at :datetime not null # account_id :bigint diff --git a/app/views/api/v1/models/_custom_attribute_definition.json.jbuilder b/app/views/api/v1/models/_custom_attribute_definition.json.jbuilder index b715b0e50648..0a1036903438 100644 --- a/app/views/api/v1/models/_custom_attribute_definition.json.jbuilder +++ b/app/views/api/v1/models/_custom_attribute_definition.json.jbuilder @@ -3,6 +3,7 @@ json.attribute_display_name resource.attribute_display_name json.attribute_display_type resource.attribute_display_type json.attribute_description resource.attribute_description json.attribute_key resource.attribute_key +json.attribute_values resource.attribute_values json.attribute_model resource.attribute_model json.default_value resource.default_value json.created_at resource.created_at diff --git a/db/migrate/20211118100301_change_values_to_attribute_values_in_custom_attribute_definitions.rb b/db/migrate/20211118100301_change_values_to_attribute_values_in_custom_attribute_definitions.rb new file mode 100644 index 000000000000..fdf8fd661379 --- /dev/null +++ b/db/migrate/20211118100301_change_values_to_attribute_values_in_custom_attribute_definitions.rb @@ -0,0 +1,5 @@ +class ChangeValuesToAttributeValuesInCustomAttributeDefinitions < ActiveRecord::Migration[6.1] + def change + rename_column :custom_attribute_definitions, :values, :attribute_values + end +end diff --git a/db/schema.rb b/db/schema.rb index 946f2829e64e..1e3b876361c3 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_11_16_131740) do +ActiveRecord::Schema.define(version: 2021_11_18_100301) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" @@ -355,7 +355,7 @@ t.datetime "created_at", precision: 6, null: false t.datetime "updated_at", precision: 6, null: false t.text "attribute_description" - t.jsonb "values", default: [] + t.jsonb "attribute_values", default: [] t.index ["account_id"], name: "index_custom_attribute_definitions_on_account_id" t.index ["attribute_key", "attribute_model"], name: "attribute_key_model_index", unique: true end