From 9ea42ebff22149b4abf6e8f7b5021f310a71448f Mon Sep 17 00:00:00 2001 From: Muhsin Keloth Date: Tue, 16 Nov 2021 23:25:19 +0530 Subject: [PATCH] chore: Add the support for list and checkbox in custom attribute model (#3400) ref: #3399 --- app/models/custom_attribute_definition.rb | 5 +++-- ...11116131740_add_values_to_custom_attribute_definitions.rb | 5 +++++ db/schema.rb | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20211116131740_add_values_to_custom_attribute_definitions.rb diff --git a/app/models/custom_attribute_definition.rb b/app/models/custom_attribute_definition.rb index d3f40e0f4..a79b8ca95 100644 --- a/app/models/custom_attribute_definition.rb +++ b/app/models/custom_attribute_definition.rb @@ -3,12 +3,13 @@ # Table name: custom_attribute_definitions # # id :bigint not null, primary key +# attribute_description :text # attribute_display_name :string # attribute_display_type :integer default("text") -# attribute_description :text # attribute_key :string # attribute_model :integer default("conversation_attribute") # default_value :integer +# values :jsonb # created_at :datetime not null # updated_at :datetime not null # account_id :bigint @@ -30,7 +31,7 @@ class CustomAttributeDefinition < ApplicationRecord validates :attribute_model, presence: true enum attribute_model: { conversation_attribute: 0, contact_attribute: 1 } - enum attribute_display_type: { text: 0, number: 1, currency: 2, percent: 3, link: 4, date: 5 } + enum attribute_display_type: { text: 0, number: 1, currency: 2, percent: 3, link: 4, date: 5, list: 6, checkbox: 7 } belongs_to :account end diff --git a/db/migrate/20211116131740_add_values_to_custom_attribute_definitions.rb b/db/migrate/20211116131740_add_values_to_custom_attribute_definitions.rb new file mode 100644 index 000000000..2625fe30c --- /dev/null +++ b/db/migrate/20211116131740_add_values_to_custom_attribute_definitions.rb @@ -0,0 +1,5 @@ +class AddValuesToCustomAttributeDefinitions < ActiveRecord::Migration[6.1] + def change + add_column :custom_attribute_definitions, :values, :jsonb, default: [] + end +end diff --git a/db/schema.rb b/db/schema.rb index 9ad249a38..946f2829e 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_09_29_150415) do +ActiveRecord::Schema.define(version: 2021_11_16_131740) do # These are extensions that must be enabled in order to support this database enable_extension "pg_stat_statements" @@ -355,6 +355,7 @@ ActiveRecord::Schema.define(version: 2021_09_29_150415) do 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.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