feat: Add APIs to manage custom roles in Chatwoot (#9995)

Co-authored-by: Pranav <pranavrajs@gmail.com>
This commit is contained in:
Sojan Jose
2024-08-23 04:48:28 -07:00
committed by GitHub
parent 41c5e7d3f1
commit b61ad6e41a
24 changed files with 440 additions and 18 deletions

View File

@@ -0,0 +1,16 @@
class AddCustomRoles < ActiveRecord::Migration[7.0]
def change
# Create the roles table
create_table :custom_roles do |t|
t.string :name
t.string :description
t.references :account, null: false
t.text :permissions, array: true, default: []
t.timestamps
end
# Associate the custom role with account user
# Add the custom_role_id column to the account_users table
add_reference :account_users, :custom_role, optional: true
end
end

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2024_05_16_003531) do
ActiveRecord::Schema[7.0].define(version: 2024_07_26_220747) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"
enable_extension "pg_trgm"
@@ -37,8 +37,10 @@ ActiveRecord::Schema[7.0].define(version: 2024_05_16_003531) do
t.datetime "active_at", precision: nil
t.integer "availability", default: 0, null: false
t.boolean "auto_offline", default: true, null: false
t.bigint "custom_role_id"
t.index ["account_id", "user_id"], name: "uniq_user_id_per_account_id", unique: true
t.index ["account_id"], name: "index_account_users_on_account_id"
t.index ["custom_role_id"], name: "index_account_users_on_custom_role_id"
t.index ["user_id"], name: "index_account_users_on_user_id"
end
@@ -538,6 +540,16 @@ ActiveRecord::Schema[7.0].define(version: 2024_05_16_003531) do
t.index ["user_id"], name: "index_custom_filters_on_user_id"
end
create_table "custom_roles", force: :cascade do |t|
t.string "name"
t.string "description"
t.bigint "account_id", null: false
t.text "permissions", default: [], array: true
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["account_id"], name: "index_custom_roles_on_account_id"
end
create_table "dashboard_apps", force: :cascade do |t|
t.string "title", null: false
t.jsonb "content", default: []