feat: Team APIs (#1654)

Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
Sojan Jose
2021-01-17 23:56:56 +05:30
committed by GitHub
parent dd90e24d02
commit a0c33254e7
29 changed files with 523 additions and 2 deletions

View File

@@ -0,0 +1,20 @@
class CreateTeams < ActiveRecord::Migration[6.0]
def change
create_table :teams do |t|
t.string :name, null: false
t.text :description
t.boolean :allow_auto_assign, default: true
t.references :account, null: false, foreign_key: true
t.timestamps
end
create_table :team_members do |t|
t.references :team, null: false, foreign_key: true
t.references :user, null: false, foreign_key: true
t.timestamps
end
add_reference :conversations, :team, foreign_key: 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.define(version: 2021_01_13_045116) do
ActiveRecord::Schema.define(version: 2021_01_14_202310) do
# These are extensions that must be enabled in order to support this database
enable_extension "pg_stat_statements"
@@ -234,9 +234,11 @@ ActiveRecord::Schema.define(version: 2021_01_13_045116) do
t.uuid "uuid", default: -> { "gen_random_uuid()" }, null: false
t.string "identifier"
t.datetime "last_activity_at", default: -> { "CURRENT_TIMESTAMP" }, null: false
t.bigint "team_id"
t.index ["account_id", "display_id"], name: "index_conversations_on_account_id_and_display_id", unique: true
t.index ["account_id"], name: "index_conversations_on_account_id"
t.index ["contact_inbox_id"], name: "index_conversations_on_contact_inbox_id"
t.index ["team_id"], name: "index_conversations_on_team_id"
end
create_table "email_templates", force: :cascade do |t|
@@ -491,6 +493,25 @@ ActiveRecord::Schema.define(version: 2021_01_13_045116) do
t.index ["name"], name: "index_tags_on_name", unique: true
end
create_table "team_members", force: :cascade do |t|
t.bigint "team_id", null: false
t.bigint "user_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["team_id"], name: "index_team_members_on_team_id"
t.index ["user_id"], name: "index_team_members_on_user_id"
end
create_table "teams", force: :cascade do |t|
t.string "name", null: false
t.text "description"
t.boolean "allow_auto_assign", default: true
t.bigint "account_id", null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["account_id"], name: "index_teams_on_account_id"
end
create_table "telegram_bots", id: :serial, force: :cascade do |t|
t.string "name"
t.string "auth_key"
@@ -561,6 +582,10 @@ ActiveRecord::Schema.define(version: 2021_01_13_045116) do
add_foreign_key "contact_inboxes", "contacts"
add_foreign_key "contact_inboxes", "inboxes"
add_foreign_key "conversations", "contact_inboxes"
add_foreign_key "conversations", "teams"
add_foreign_key "team_members", "teams"
add_foreign_key "team_members", "users"
add_foreign_key "teams", "accounts"
create_trigger("accounts_after_insert_row_tr", :generated => true, :compatibility => 1).
on("accounts").
after(:insert).