chore: Add the ability to use same key for conversation and contact (#3526)
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
# attribute_key_index (attribute_key,account_id) UNIQUE
|
# attribute_key_model_index (attribute_key,attribute_model,account_id) UNIQUE
|
||||||
# index_custom_attribute_definitions_on_account_id (account_id)
|
# index_custom_attribute_definitions_on_account_id (account_id)
|
||||||
#
|
#
|
||||||
class CustomAttributeDefinition < ApplicationRecord
|
class CustomAttributeDefinition < ApplicationRecord
|
||||||
@@ -25,7 +25,7 @@ class CustomAttributeDefinition < ApplicationRecord
|
|||||||
|
|
||||||
validates :attribute_key,
|
validates :attribute_key,
|
||||||
presence: true,
|
presence: true,
|
||||||
uniqueness: { scope: :account_id }
|
uniqueness: { scope: [:account_id, :attribute_model] }
|
||||||
|
|
||||||
validates :attribute_display_type, presence: true
|
validates :attribute_display_type, presence: true
|
||||||
validates :attribute_model, presence: true
|
validates :attribute_model, presence: true
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
class AddAttributeModelIndexOnCustomAttributeDefinition < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
remove_index :custom_attribute_definitions, [:attribute_key, :account_id], name: 'attribute_key_index',
|
||||||
|
if_exists: true
|
||||||
|
add_index :custom_attribute_definitions, [:attribute_key, :attribute_model, :account_id], unique: true, name: 'attribute_key_model_index',
|
||||||
|
if_not_exists: true
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -368,7 +368,7 @@ ActiveRecord::Schema.define(version: 2021_12_08_085931) do
|
|||||||
t.text "attribute_description"
|
t.text "attribute_description"
|
||||||
t.jsonb "attribute_values", default: []
|
t.jsonb "attribute_values", default: []
|
||||||
t.index ["account_id"], name: "index_custom_attribute_definitions_on_account_id"
|
t.index ["account_id"], name: "index_custom_attribute_definitions_on_account_id"
|
||||||
t.index ["attribute_key", "account_id"], name: "attribute_key_index", unique: true
|
t.index ["attribute_key", "attribute_model", "account_id"], name: "attribute_key_model_index", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "custom_filters", force: :cascade do |t|
|
create_table "custom_filters", force: :cascade do |t|
|
||||||
|
|||||||
Reference in New Issue
Block a user