2019-08-14 09:48:44 +00:00
|
|
|
# This file is auto-generated from the current state of the database. Instead
|
|
|
|
# of editing this file, please use the migrations feature of Active Record to
|
|
|
|
# incrementally modify your database, and then regenerate this schema definition.
|
|
|
|
#
|
2021-08-03 14:41:52 +00:00
|
|
|
# This file is the source Rails uses to define your schema when running `bin/rails
|
|
|
|
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
|
2019-08-19 08:19:57 +00:00
|
|
|
# be faster and is potentially less error prone than running all of your
|
|
|
|
# migrations from scratch. Old migrations may fail to apply correctly if those
|
|
|
|
# migrations use external dependencies or application code.
|
2019-08-14 09:48:44 +00:00
|
|
|
#
|
|
|
|
# It's strongly recommended that you check this file into your version control system.
|
|
|
|
|
2022-02-18 14:32:50 +00:00
|
|
|
ActiveRecord::Schema.define(version: 2022_02_18_120357) do
|
2020-03-10 18:32:15 +00:00
|
|
|
|
2019-10-20 10:49:12 +00:00
|
|
|
# These are extensions that must be enabled in order to support this database
|
2020-10-18 18:02:22 +00:00
|
|
|
enable_extension "pg_stat_statements"
|
2020-04-30 14:50:26 +00:00
|
|
|
enable_extension "pgcrypto"
|
2020-03-10 18:32:15 +00:00
|
|
|
enable_extension "plpgsql"
|
|
|
|
|
|
|
|
create_table "access_tokens", force: :cascade do |t|
|
|
|
|
t.string "owner_type"
|
|
|
|
t.bigint "owner_id"
|
|
|
|
t.string "token"
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
t.index ["owner_type", "owner_id"], name: "index_access_tokens_on_owner_type_and_owner_id"
|
|
|
|
t.index ["token"], name: "index_access_tokens_on_token", unique: true
|
|
|
|
end
|
2020-02-29 15:11:09 +00:00
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "account_users", force: :cascade do |t|
|
|
|
|
t.bigint "account_id"
|
|
|
|
t.bigint "user_id"
|
|
|
|
t.integer "role", default: 0
|
|
|
|
t.bigint "inviter_id"
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
2020-05-26 17:08:48 +00:00
|
|
|
t.datetime "active_at"
|
2021-10-07 07:51:46 +00:00
|
|
|
t.integer "availability", default: 0, null: false
|
|
|
|
t.boolean "auto_offline", default: true, null: false
|
2020-03-10 18:32:15 +00:00
|
|
|
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 ["user_id"], name: "index_account_users_on_user_id"
|
2020-03-07 06:48:16 +00:00
|
|
|
end
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "accounts", id: :serial, force: :cascade do |t|
|
|
|
|
t.string "name", null: false
|
|
|
|
t.datetime "created_at", null: false
|
|
|
|
t.datetime "updated_at", null: false
|
2020-03-29 06:46:31 +00:00
|
|
|
t.integer "locale", default: 0
|
2020-04-30 14:50:26 +00:00
|
|
|
t.string "domain", limit: 100
|
|
|
|
t.string "support_email", limit: 100
|
|
|
|
t.integer "settings_flags", default: 0, null: false
|
2020-05-04 17:36:42 +00:00
|
|
|
t.integer "feature_flags", default: 0, null: false
|
2020-11-01 07:23:25 +00:00
|
|
|
t.integer "auto_resolve_duration"
|
2021-12-09 06:37:48 +00:00
|
|
|
t.jsonb "limits", default: {}
|
2020-04-30 14:50:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
create_table "action_mailbox_inbound_emails", force: :cascade do |t|
|
|
|
|
t.integer "status", default: 0, null: false
|
|
|
|
t.string "message_id", null: false
|
|
|
|
t.string "message_checksum", null: false
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
t.index ["message_id", "message_checksum"], name: "index_action_mailbox_inbound_emails_uniqueness", unique: true
|
2020-02-29 15:11:09 +00:00
|
|
|
end
|
2020-02-14 17:49:17 +00:00
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "active_storage_attachments", force: :cascade do |t|
|
|
|
|
t.string "name", null: false
|
|
|
|
t.string "record_type", null: false
|
|
|
|
t.bigint "record_id", null: false
|
|
|
|
t.bigint "blob_id", null: false
|
|
|
|
t.datetime "created_at", null: false
|
|
|
|
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
|
|
|
|
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
|
2020-02-14 17:49:17 +00:00
|
|
|
end
|
2019-10-20 10:49:12 +00:00
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "active_storage_blobs", force: :cascade do |t|
|
|
|
|
t.string "key", null: false
|
|
|
|
t.string "filename", null: false
|
|
|
|
t.string "content_type"
|
|
|
|
t.text "metadata"
|
|
|
|
t.bigint "byte_size", null: false
|
|
|
|
t.string "checksum", null: false
|
|
|
|
t.datetime "created_at", null: false
|
2021-08-03 14:41:52 +00:00
|
|
|
t.string "service_name", null: false
|
2020-03-10 18:32:15 +00:00
|
|
|
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
|
2019-10-20 10:49:12 +00:00
|
|
|
end
|
|
|
|
|
2021-08-03 14:41:52 +00:00
|
|
|
create_table "active_storage_variant_records", force: :cascade do |t|
|
|
|
|
t.bigint "blob_id", null: false
|
|
|
|
t.string "variation_digest", null: false
|
|
|
|
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
|
|
|
|
end
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "agent_bot_inboxes", force: :cascade do |t|
|
|
|
|
t.integer "inbox_id"
|
|
|
|
t.integer "agent_bot_id"
|
|
|
|
t.integer "status", default: 0
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
t.integer "account_id"
|
2020-03-05 20:13:12 +00:00
|
|
|
end
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "agent_bots", force: :cascade do |t|
|
|
|
|
t.string "name"
|
|
|
|
t.string "description"
|
|
|
|
t.string "outgoing_url"
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
2021-06-01 17:04:25 +00:00
|
|
|
t.bigint "account_id"
|
|
|
|
t.index ["account_id"], name: "index_agent_bots_on_account_id"
|
2020-03-05 20:13:12 +00:00
|
|
|
end
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "attachments", id: :serial, force: :cascade do |t|
|
|
|
|
t.integer "file_type", default: 0
|
|
|
|
t.string "external_url"
|
|
|
|
t.float "coordinates_lat", default: 0.0
|
|
|
|
t.float "coordinates_long", default: 0.0
|
|
|
|
t.integer "message_id", null: false
|
|
|
|
t.integer "account_id", null: false
|
|
|
|
t.datetime "created_at", null: false
|
|
|
|
t.datetime "updated_at", null: false
|
|
|
|
t.string "fallback_title"
|
|
|
|
t.string "extension"
|
2019-12-10 04:59:35 +00:00
|
|
|
end
|
|
|
|
|
2022-01-10 07:11:59 +00:00
|
|
|
create_table "automation_rules", force: :cascade do |t|
|
|
|
|
t.bigint "account_id", null: false
|
|
|
|
t.string "name", null: false
|
|
|
|
t.text "description"
|
|
|
|
t.string "event_name", null: false
|
|
|
|
t.jsonb "conditions", default: "{}", null: false
|
|
|
|
t.jsonb "actions", default: "{}", null: false
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
2022-01-13 05:51:06 +00:00
|
|
|
t.boolean "active", default: true, null: false
|
2022-01-10 07:11:59 +00:00
|
|
|
t.index ["account_id"], name: "index_automation_rules_on_account_id"
|
|
|
|
end
|
|
|
|
|
2021-04-29 16:53:32 +00:00
|
|
|
create_table "campaigns", force: :cascade do |t|
|
|
|
|
t.integer "display_id", null: false
|
|
|
|
t.string "title", null: false
|
|
|
|
t.text "description"
|
2021-04-30 13:15:24 +00:00
|
|
|
t.text "message", null: false
|
2021-04-29 16:53:32 +00:00
|
|
|
t.integer "sender_id"
|
|
|
|
t.boolean "enabled", default: true
|
|
|
|
t.bigint "account_id", null: false
|
|
|
|
t.bigint "inbox_id", null: false
|
|
|
|
t.jsonb "trigger_rules", default: {}
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
2021-07-14 06:54:09 +00:00
|
|
|
t.integer "campaign_type", default: 0, null: false
|
|
|
|
t.integer "campaign_status", default: 0, null: false
|
|
|
|
t.jsonb "audience", default: []
|
|
|
|
t.datetime "scheduled_at"
|
2021-10-12 12:28:33 +00:00
|
|
|
t.boolean "trigger_only_during_business_hours", default: false
|
2021-04-29 16:53:32 +00:00
|
|
|
t.index ["account_id"], name: "index_campaigns_on_account_id"
|
2021-07-14 06:54:09 +00:00
|
|
|
t.index ["campaign_status"], name: "index_campaigns_on_campaign_status"
|
|
|
|
t.index ["campaign_type"], name: "index_campaigns_on_campaign_type"
|
2021-04-29 16:53:32 +00:00
|
|
|
t.index ["inbox_id"], name: "index_campaigns_on_inbox_id"
|
2021-07-14 06:54:09 +00:00
|
|
|
t.index ["scheduled_at"], name: "index_campaigns_on_scheduled_at"
|
2021-04-29 16:53:32 +00:00
|
|
|
end
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "canned_responses", id: :serial, force: :cascade do |t|
|
|
|
|
t.integer "account_id", null: false
|
|
|
|
t.string "short_code"
|
|
|
|
t.text "content"
|
|
|
|
t.datetime "created_at", null: false
|
|
|
|
t.datetime "updated_at", null: false
|
2019-12-10 04:59:35 +00:00
|
|
|
end
|
|
|
|
|
2020-07-21 06:45:24 +00:00
|
|
|
create_table "channel_api", force: :cascade do |t|
|
|
|
|
t.integer "account_id", null: false
|
2021-05-13 09:33:25 +00:00
|
|
|
t.string "webhook_url"
|
2020-07-21 06:45:24 +00:00
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
2021-06-15 14:39:17 +00:00
|
|
|
t.string "identifier"
|
|
|
|
t.string "hmac_token"
|
|
|
|
t.boolean "hmac_mandatory", default: false
|
|
|
|
t.index ["hmac_token"], name: "index_channel_api_on_hmac_token", unique: true
|
|
|
|
t.index ["identifier"], name: "index_channel_api_on_identifier", unique: true
|
2020-07-21 06:45:24 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
create_table "channel_email", force: :cascade do |t|
|
|
|
|
t.integer "account_id", null: false
|
|
|
|
t.string "email", null: false
|
2021-03-04 08:29:59 +00:00
|
|
|
t.string "forward_to_email", null: false
|
2020-07-21 06:45:24 +00:00
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
2021-11-19 06:22:27 +00:00
|
|
|
t.boolean "imap_enabled", default: false
|
|
|
|
t.string "imap_address", default: ""
|
|
|
|
t.integer "imap_port", default: 0
|
|
|
|
t.string "imap_email", default: ""
|
|
|
|
t.string "imap_password", default: ""
|
|
|
|
t.boolean "imap_enable_ssl", default: true
|
|
|
|
t.datetime "imap_inbox_synced_at"
|
|
|
|
t.boolean "smtp_enabled", default: false
|
|
|
|
t.string "smtp_address", default: ""
|
|
|
|
t.integer "smtp_port", default: 0
|
|
|
|
t.string "smtp_email", default: ""
|
|
|
|
t.string "smtp_password", default: ""
|
|
|
|
t.string "smtp_domain", default: ""
|
|
|
|
t.boolean "smtp_enable_starttls_auto", default: true
|
|
|
|
t.string "smtp_authentication", default: "login"
|
2022-02-08 11:26:13 +00:00
|
|
|
t.string "smtp_openssl_verify_mode", default: "none"
|
|
|
|
t.boolean "smtp_enable_ssl_tls", default: false
|
2020-07-21 06:45:24 +00:00
|
|
|
t.index ["email"], name: "index_channel_email_on_email", unique: true
|
2021-03-04 08:29:59 +00:00
|
|
|
t.index ["forward_to_email"], name: "index_channel_email_on_forward_to_email", unique: true
|
2020-07-21 06:45:24 +00:00
|
|
|
end
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "channel_facebook_pages", id: :serial, force: :cascade do |t|
|
|
|
|
t.string "page_id", null: false
|
|
|
|
t.string "user_access_token", null: false
|
|
|
|
t.string "page_access_token", null: false
|
|
|
|
t.integer "account_id", null: false
|
|
|
|
t.datetime "created_at", null: false
|
|
|
|
t.datetime "updated_at", null: false
|
2021-10-05 09:05:32 +00:00
|
|
|
t.string "instagram_id"
|
2020-03-10 18:32:15 +00:00
|
|
|
t.index ["page_id", "account_id"], name: "index_channel_facebook_pages_on_page_id_and_account_id", unique: true
|
|
|
|
t.index ["page_id"], name: "index_channel_facebook_pages_on_page_id"
|
2019-10-20 10:49:12 +00:00
|
|
|
end
|
|
|
|
|
2021-09-10 20:01:17 +00:00
|
|
|
create_table "channel_line", force: :cascade do |t|
|
|
|
|
t.integer "account_id", null: false
|
|
|
|
t.string "line_channel_id", null: false
|
|
|
|
t.string "line_channel_secret", null: false
|
|
|
|
t.string "line_channel_token", null: false
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
t.index ["line_channel_id"], name: "index_channel_line_on_line_channel_id", unique: true
|
|
|
|
end
|
|
|
|
|
2022-02-03 23:22:13 +00:00
|
|
|
create_table "channel_sms", force: :cascade do |t|
|
|
|
|
t.integer "account_id", null: false
|
|
|
|
t.string "phone_number", null: false
|
|
|
|
t.string "provider", default: "default"
|
|
|
|
t.jsonb "provider_config", default: {}
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
t.index ["phone_number"], name: "index_channel_sms_on_phone_number", unique: true
|
|
|
|
end
|
|
|
|
|
2021-09-09 18:30:52 +00:00
|
|
|
create_table "channel_telegram", force: :cascade do |t|
|
|
|
|
t.string "bot_name"
|
|
|
|
t.integer "account_id", null: false
|
|
|
|
t.string "bot_token", null: false
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
t.index ["bot_token"], name: "index_channel_telegram_on_bot_token", unique: true
|
|
|
|
end
|
|
|
|
|
2020-04-05 16:41:27 +00:00
|
|
|
create_table "channel_twilio_sms", force: :cascade do |t|
|
|
|
|
t.string "phone_number", null: false
|
|
|
|
t.string "auth_token", null: false
|
|
|
|
t.string "account_sid", null: false
|
|
|
|
t.integer "account_id", null: false
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
2020-04-29 20:11:13 +00:00
|
|
|
t.integer "medium", default: 0
|
2020-04-05 16:41:27 +00:00
|
|
|
t.index ["account_id", "phone_number"], name: "index_channel_twilio_sms_on_account_id_and_phone_number", unique: true
|
|
|
|
end
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "channel_twitter_profiles", force: :cascade do |t|
|
|
|
|
t.string "profile_id", null: false
|
|
|
|
t.string "twitter_access_token", null: false
|
|
|
|
t.string "twitter_access_token_secret", null: false
|
|
|
|
t.integer "account_id", null: false
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
2021-12-15 18:54:50 +00:00
|
|
|
t.boolean "tweets_enabled", default: true
|
2020-04-05 16:41:27 +00:00
|
|
|
t.index ["account_id", "profile_id"], name: "index_channel_twitter_profiles_on_account_id_and_profile_id", unique: true
|
2019-10-20 10:49:12 +00:00
|
|
|
end
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "channel_web_widgets", id: :serial, force: :cascade do |t|
|
|
|
|
t.string "website_url"
|
|
|
|
t.integer "account_id"
|
|
|
|
t.datetime "created_at", null: false
|
|
|
|
t.datetime "updated_at", null: false
|
|
|
|
t.string "website_token"
|
|
|
|
t.string "widget_color", default: "#1f93ff"
|
2020-04-19 18:10:28 +00:00
|
|
|
t.string "welcome_title"
|
|
|
|
t.string "welcome_tagline"
|
2020-08-05 12:16:17 +00:00
|
|
|
t.integer "feature_flags", default: 3, null: false
|
2020-10-18 18:02:22 +00:00
|
|
|
t.integer "reply_time", default: 0
|
2021-01-17 17:14:03 +00:00
|
|
|
t.string "hmac_token"
|
2021-02-15 18:44:13 +00:00
|
|
|
t.boolean "pre_chat_form_enabled", default: false
|
|
|
|
t.jsonb "pre_chat_form_options", default: {}
|
2021-06-15 14:39:17 +00:00
|
|
|
t.boolean "hmac_mandatory", default: false
|
2022-01-26 23:59:48 +00:00
|
|
|
t.boolean "continuity_via_email", default: true, null: false
|
2021-01-17 17:14:03 +00:00
|
|
|
t.index ["hmac_token"], name: "index_channel_web_widgets_on_hmac_token", unique: true
|
2020-03-10 18:32:15 +00:00
|
|
|
t.index ["website_token"], name: "index_channel_web_widgets_on_website_token", unique: true
|
2019-10-20 10:49:12 +00:00
|
|
|
end
|
|
|
|
|
2021-10-05 18:05:06 +00:00
|
|
|
create_table "channel_whatsapp", force: :cascade do |t|
|
|
|
|
t.integer "account_id", null: false
|
|
|
|
t.string "phone_number", null: false
|
|
|
|
t.string "provider", default: "default"
|
|
|
|
t.jsonb "provider_config", default: {}
|
2021-10-05 09:05:32 +00:00
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
2021-11-30 15:20:35 +00:00
|
|
|
t.jsonb "message_templates", default: {}
|
|
|
|
t.datetime "message_templates_last_updated"
|
2021-10-05 18:05:06 +00:00
|
|
|
t.index ["phone_number"], name: "index_channel_whatsapp_on_phone_number", unique: true
|
2021-10-05 09:05:32 +00:00
|
|
|
end
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "contact_inboxes", force: :cascade do |t|
|
|
|
|
t.bigint "contact_id"
|
|
|
|
t.bigint "inbox_id"
|
|
|
|
t.string "source_id", null: false
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
2021-01-17 17:14:03 +00:00
|
|
|
t.boolean "hmac_verified", default: false
|
2021-11-22 18:02:17 +00:00
|
|
|
t.string "pubsub_token"
|
2020-03-10 18:32:15 +00:00
|
|
|
t.index ["contact_id"], name: "index_contact_inboxes_on_contact_id"
|
|
|
|
t.index ["inbox_id", "source_id"], name: "index_contact_inboxes_on_inbox_id_and_source_id", unique: true
|
|
|
|
t.index ["inbox_id"], name: "index_contact_inboxes_on_inbox_id"
|
2021-11-22 18:02:17 +00:00
|
|
|
t.index ["pubsub_token"], name: "index_contact_inboxes_on_pubsub_token", unique: true
|
2020-03-10 18:32:15 +00:00
|
|
|
t.index ["source_id"], name: "index_contact_inboxes_on_source_id"
|
2020-02-02 19:09:00 +00:00
|
|
|
end
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "contacts", id: :serial, force: :cascade do |t|
|
|
|
|
t.string "name"
|
|
|
|
t.string "email"
|
|
|
|
t.string "phone_number"
|
|
|
|
t.integer "account_id", null: false
|
|
|
|
t.datetime "created_at", null: false
|
|
|
|
t.datetime "updated_at", null: false
|
|
|
|
t.string "pubsub_token"
|
2020-10-27 20:44:36 +00:00
|
|
|
t.jsonb "additional_attributes", default: {}
|
2020-04-03 07:34:58 +00:00
|
|
|
t.string "identifier"
|
2020-08-21 14:00:27 +00:00
|
|
|
t.jsonb "custom_attributes", default: {}
|
2021-05-13 08:02:19 +00:00
|
|
|
t.datetime "last_activity_at"
|
2020-03-10 18:32:15 +00:00
|
|
|
t.index ["account_id"], name: "index_contacts_on_account_id"
|
2020-04-03 07:34:58 +00:00
|
|
|
t.index ["email", "account_id"], name: "uniq_email_per_account_contact", unique: true
|
|
|
|
t.index ["identifier", "account_id"], name: "uniq_identifier_per_account_contact", unique: true
|
2021-07-23 13:09:24 +00:00
|
|
|
t.index ["phone_number", "account_id"], name: "index_contacts_on_phone_number_and_account_id"
|
2020-03-10 18:32:15 +00:00
|
|
|
t.index ["pubsub_token"], name: "index_contacts_on_pubsub_token", unique: true
|
2019-10-20 10:49:12 +00:00
|
|
|
end
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "conversations", id: :serial, force: :cascade do |t|
|
|
|
|
t.integer "account_id", null: false
|
|
|
|
t.integer "inbox_id", null: false
|
|
|
|
t.integer "status", default: 0, null: false
|
|
|
|
t.integer "assignee_id"
|
2021-01-06 06:06:45 +00:00
|
|
|
t.datetime "created_at", null: false
|
|
|
|
t.datetime "updated_at", null: false
|
2020-03-10 18:32:15 +00:00
|
|
|
t.bigint "contact_id"
|
|
|
|
t.integer "display_id", null: false
|
2020-09-10 13:49:15 +00:00
|
|
|
t.datetime "contact_last_seen_at"
|
2020-03-10 18:32:15 +00:00
|
|
|
t.datetime "agent_last_seen_at"
|
2020-10-27 20:44:36 +00:00
|
|
|
t.jsonb "additional_attributes", default: {}
|
2020-03-10 18:32:15 +00:00
|
|
|
t.bigint "contact_inbox_id"
|
2021-10-06 14:04:34 +00:00
|
|
|
t.uuid "uuid", default: -> { "public.gen_random_uuid()" }, null: false
|
2020-06-12 18:49:43 +00:00
|
|
|
t.string "identifier"
|
2021-01-06 06:06:45 +00:00
|
|
|
t.datetime "last_activity_at", default: -> { "CURRENT_TIMESTAMP" }, null: false
|
2021-01-17 18:26:56 +00:00
|
|
|
t.bigint "team_id"
|
2021-04-29 16:53:32 +00:00
|
|
|
t.bigint "campaign_id"
|
2021-07-23 09:54:07 +00:00
|
|
|
t.datetime "snoozed_until"
|
2021-09-22 05:16:48 +00:00
|
|
|
t.jsonb "custom_attributes", default: {}
|
2021-09-23 15:29:10 +00:00
|
|
|
t.datetime "assignee_last_seen_at"
|
2020-03-10 18:32:15 +00:00
|
|
|
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"
|
2021-07-23 13:09:24 +00:00
|
|
|
t.index ["assignee_id", "account_id"], name: "index_conversations_on_assignee_id_and_account_id"
|
2021-04-29 16:53:32 +00:00
|
|
|
t.index ["campaign_id"], name: "index_conversations_on_campaign_id"
|
2020-03-10 18:32:15 +00:00
|
|
|
t.index ["contact_inbox_id"], name: "index_conversations_on_contact_inbox_id"
|
2021-07-23 13:09:24 +00:00
|
|
|
t.index ["status", "account_id"], name: "index_conversations_on_status_and_account_id"
|
2021-01-17 18:26:56 +00:00
|
|
|
t.index ["team_id"], name: "index_conversations_on_team_id"
|
2019-10-27 07:44:36 +00:00
|
|
|
end
|
|
|
|
|
2021-06-29 15:29:41 +00:00
|
|
|
create_table "csat_survey_responses", force: :cascade do |t|
|
|
|
|
t.bigint "account_id", null: false
|
|
|
|
t.bigint "conversation_id", null: false
|
|
|
|
t.bigint "message_id", null: false
|
|
|
|
t.integer "rating", null: false
|
|
|
|
t.text "feedback_message"
|
|
|
|
t.bigint "contact_id", null: false
|
|
|
|
t.bigint "assigned_agent_id"
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
t.index ["account_id"], name: "index_csat_survey_responses_on_account_id"
|
|
|
|
t.index ["assigned_agent_id"], name: "index_csat_survey_responses_on_assigned_agent_id"
|
|
|
|
t.index ["contact_id"], name: "index_csat_survey_responses_on_contact_id"
|
|
|
|
t.index ["conversation_id"], name: "index_csat_survey_responses_on_conversation_id"
|
|
|
|
t.index ["message_id"], name: "index_csat_survey_responses_on_message_id", unique: true
|
2021-07-23 11:34:33 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
create_table "custom_attribute_definitions", force: :cascade do |t|
|
|
|
|
t.string "attribute_display_name"
|
|
|
|
t.string "attribute_key"
|
|
|
|
t.integer "attribute_display_type", default: 0
|
|
|
|
t.integer "default_value"
|
|
|
|
t.integer "attribute_model", default: 0
|
|
|
|
t.bigint "account_id"
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
2021-08-24 15:47:23 +00:00
|
|
|
t.text "attribute_description"
|
2021-11-18 13:29:28 +00:00
|
|
|
t.jsonb "attribute_values", default: []
|
2021-07-23 11:34:33 +00:00
|
|
|
t.index ["account_id"], name: "index_custom_attribute_definitions_on_account_id"
|
2021-12-08 14:45:27 +00:00
|
|
|
t.index ["attribute_key", "attribute_model", "account_id"], name: "attribute_key_model_index", unique: true
|
2021-06-29 15:29:41 +00:00
|
|
|
end
|
|
|
|
|
2021-06-29 13:59:57 +00:00
|
|
|
create_table "custom_filters", force: :cascade do |t|
|
|
|
|
t.string "name", null: false
|
|
|
|
t.integer "filter_type", default: 0, null: false
|
|
|
|
t.jsonb "query", default: "{}", null: false
|
|
|
|
t.bigint "account_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 ["account_id"], name: "index_custom_filters_on_account_id"
|
|
|
|
t.index ["user_id"], name: "index_custom_filters_on_user_id"
|
|
|
|
end
|
|
|
|
|
2021-02-03 13:54:51 +00:00
|
|
|
create_table "data_imports", force: :cascade do |t|
|
|
|
|
t.bigint "account_id", null: false
|
|
|
|
t.string "data_type", null: false
|
|
|
|
t.integer "status", default: 0, null: false
|
|
|
|
t.text "processing_errors"
|
|
|
|
t.integer "total_records"
|
|
|
|
t.integer "processed_records"
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
t.index ["account_id"], name: "index_data_imports_on_account_id"
|
|
|
|
end
|
|
|
|
|
2020-08-06 09:51:06 +00:00
|
|
|
create_table "email_templates", force: :cascade do |t|
|
|
|
|
t.string "name", null: false
|
|
|
|
t.text "body", null: false
|
|
|
|
t.integer "account_id"
|
|
|
|
t.integer "template_type", default: 1
|
|
|
|
t.integer "locale", default: 0, null: false
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
t.index ["name", "account_id"], name: "index_email_templates_on_name_and_account_id", unique: true
|
|
|
|
end
|
|
|
|
|
2020-03-18 11:23:35 +00:00
|
|
|
create_table "events", force: :cascade do |t|
|
|
|
|
t.string "name"
|
|
|
|
t.float "value"
|
|
|
|
t.integer "account_id"
|
|
|
|
t.integer "inbox_id"
|
|
|
|
t.integer "user_id"
|
|
|
|
t.integer "conversation_id"
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
t.index ["account_id"], name: "index_events_on_account_id"
|
|
|
|
t.index ["created_at"], name: "index_events_on_created_at"
|
|
|
|
t.index ["inbox_id"], name: "index_events_on_inbox_id"
|
|
|
|
t.index ["name"], name: "index_events_on_name"
|
|
|
|
t.index ["user_id"], name: "index_events_on_user_id"
|
|
|
|
end
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "inbox_members", id: :serial, force: :cascade do |t|
|
|
|
|
t.integer "user_id", null: false
|
|
|
|
t.integer "inbox_id", null: false
|
|
|
|
t.datetime "created_at", null: false
|
|
|
|
t.datetime "updated_at", null: false
|
2021-12-21 17:18:01 +00:00
|
|
|
t.index ["inbox_id", "user_id"], name: "index_inbox_members_on_inbox_id_and_user_id", unique: true
|
2020-03-10 18:32:15 +00:00
|
|
|
t.index ["inbox_id"], name: "index_inbox_members_on_inbox_id"
|
2019-10-20 10:49:12 +00:00
|
|
|
end
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "inboxes", id: :serial, force: :cascade do |t|
|
|
|
|
t.integer "channel_id", null: false
|
|
|
|
t.integer "account_id", null: false
|
|
|
|
t.string "name", null: false
|
|
|
|
t.datetime "created_at", null: false
|
|
|
|
t.datetime "updated_at", null: false
|
|
|
|
t.string "channel_type"
|
|
|
|
t.boolean "enable_auto_assignment", default: true
|
2020-06-09 18:24:35 +00:00
|
|
|
t.boolean "greeting_enabled", default: false
|
|
|
|
t.string "greeting_message"
|
2020-10-11 17:54:11 +00:00
|
|
|
t.string "email_address"
|
2020-10-31 18:44:33 +00:00
|
|
|
t.boolean "working_hours_enabled", default: false
|
|
|
|
t.string "out_of_office_message"
|
2021-02-23 06:41:15 +00:00
|
|
|
t.string "timezone", default: "UTC"
|
2021-06-10 09:34:03 +00:00
|
|
|
t.boolean "enable_email_collect", default: true
|
2021-06-18 10:25:48 +00:00
|
|
|
t.boolean "csat_survey_enabled", default: false
|
2022-01-11 23:14:55 +00:00
|
|
|
t.boolean "allow_messages_after_resolved", default: true
|
2020-03-10 18:32:15 +00:00
|
|
|
t.index ["account_id"], name: "index_inboxes_on_account_id"
|
2019-10-20 10:49:12 +00:00
|
|
|
end
|
|
|
|
|
2020-05-10 17:10:36 +00:00
|
|
|
create_table "installation_configs", force: :cascade do |t|
|
|
|
|
t.string "name", null: false
|
2020-10-27 20:44:36 +00:00
|
|
|
t.jsonb "serialized_value", default: {}, null: false
|
2020-05-10 17:10:36 +00:00
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
2021-01-15 07:51:53 +00:00
|
|
|
t.boolean "locked", default: true, null: false
|
2020-05-10 17:10:36 +00:00
|
|
|
t.index ["name", "created_at"], name: "index_installation_configs_on_name_and_created_at", unique: true
|
2021-01-15 07:51:53 +00:00
|
|
|
t.index ["name"], name: "index_installation_configs_on_name", unique: true
|
2020-05-10 17:10:36 +00:00
|
|
|
end
|
|
|
|
|
2020-06-12 17:42:47 +00:00
|
|
|
create_table "integrations_hooks", force: :cascade do |t|
|
|
|
|
t.integer "status", default: 0
|
|
|
|
t.integer "inbox_id"
|
|
|
|
t.integer "account_id"
|
|
|
|
t.string "app_id"
|
|
|
|
t.integer "hook_type", default: 0
|
|
|
|
t.string "reference_id"
|
|
|
|
t.string "access_token"
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
2021-05-05 15:36:11 +00:00
|
|
|
t.jsonb "settings", default: {}
|
2020-06-12 17:42:47 +00:00
|
|
|
end
|
|
|
|
|
2020-09-25 21:02:34 +00:00
|
|
|
create_table "kbase_articles", force: :cascade do |t|
|
|
|
|
t.integer "account_id", null: false
|
|
|
|
t.integer "portal_id", null: false
|
|
|
|
t.integer "category_id"
|
|
|
|
t.integer "folder_id"
|
|
|
|
t.integer "author_id"
|
|
|
|
t.string "title"
|
|
|
|
t.text "description"
|
|
|
|
t.text "content"
|
|
|
|
t.integer "status"
|
|
|
|
t.integer "views"
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
end
|
|
|
|
|
|
|
|
create_table "kbase_categories", force: :cascade do |t|
|
|
|
|
t.integer "account_id", null: false
|
|
|
|
t.integer "portal_id", null: false
|
|
|
|
t.string "name"
|
|
|
|
t.text "description"
|
|
|
|
t.integer "position"
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
end
|
|
|
|
|
|
|
|
create_table "kbase_folders", force: :cascade do |t|
|
|
|
|
t.integer "account_id", null: false
|
|
|
|
t.integer "category_id", null: false
|
|
|
|
t.string "name"
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
end
|
|
|
|
|
|
|
|
create_table "kbase_portals", force: :cascade do |t|
|
|
|
|
t.integer "account_id", null: false
|
|
|
|
t.string "name", null: false
|
|
|
|
t.string "slug", null: false
|
|
|
|
t.string "custom_domain"
|
|
|
|
t.string "color"
|
|
|
|
t.string "homepage_link"
|
|
|
|
t.string "page_title"
|
|
|
|
t.text "header_text"
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
t.index ["slug"], name: "index_kbase_portals_on_slug", unique: true
|
|
|
|
end
|
|
|
|
|
2020-06-07 05:47:13 +00:00
|
|
|
create_table "labels", force: :cascade do |t|
|
|
|
|
t.string "title"
|
|
|
|
t.text "description"
|
2020-06-25 16:03:56 +00:00
|
|
|
t.string "color", default: "#1f93ff", null: false
|
2020-06-07 05:47:13 +00:00
|
|
|
t.boolean "show_on_sidebar"
|
|
|
|
t.bigint "account_id"
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
t.index ["account_id"], name: "index_labels_on_account_id"
|
2020-06-25 15:34:03 +00:00
|
|
|
t.index ["title", "account_id"], name: "index_labels_on_title_and_account_id", unique: true
|
2020-06-07 05:47:13 +00:00
|
|
|
end
|
|
|
|
|
2021-12-09 05:50:14 +00:00
|
|
|
create_table "mentions", force: :cascade do |t|
|
|
|
|
t.bigint "user_id", null: false
|
|
|
|
t.bigint "conversation_id", null: false
|
|
|
|
t.bigint "account_id", null: false
|
|
|
|
t.datetime "mentioned_at", null: false
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
t.index ["account_id"], name: "index_mentions_on_account_id"
|
|
|
|
t.index ["conversation_id"], name: "index_mentions_on_conversation_id"
|
|
|
|
t.index ["user_id", "conversation_id"], name: "index_mentions_on_user_id_and_conversation_id", unique: true
|
|
|
|
t.index ["user_id"], name: "index_mentions_on_user_id"
|
|
|
|
end
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "messages", id: :serial, force: :cascade do |t|
|
|
|
|
t.text "content"
|
|
|
|
t.integer "account_id", null: false
|
|
|
|
t.integer "inbox_id", null: false
|
|
|
|
t.integer "conversation_id", null: false
|
|
|
|
t.integer "message_type", null: false
|
|
|
|
t.datetime "created_at", null: false
|
|
|
|
t.datetime "updated_at", null: false
|
|
|
|
t.boolean "private", default: false
|
|
|
|
t.integer "status", default: 0
|
|
|
|
t.string "source_id"
|
2021-10-05 18:40:29 +00:00
|
|
|
t.integer "content_type", default: 0, null: false
|
2020-03-10 18:32:15 +00:00
|
|
|
t.json "content_attributes", default: {}
|
2020-06-27 16:04:53 +00:00
|
|
|
t.string "sender_type"
|
|
|
|
t.bigint "sender_id"
|
2020-08-28 20:09:41 +00:00
|
|
|
t.jsonb "external_source_ids", default: {}
|
2020-03-18 11:23:35 +00:00
|
|
|
t.index ["account_id"], name: "index_messages_on_account_id"
|
2020-03-10 18:32:15 +00:00
|
|
|
t.index ["conversation_id"], name: "index_messages_on_conversation_id"
|
2020-03-18 11:23:35 +00:00
|
|
|
t.index ["inbox_id"], name: "index_messages_on_inbox_id"
|
2020-06-27 16:04:53 +00:00
|
|
|
t.index ["sender_type", "sender_id"], name: "index_messages_on_sender_type_and_sender_id"
|
2020-03-10 18:32:15 +00:00
|
|
|
t.index ["source_id"], name: "index_messages_on_source_id"
|
2019-10-20 10:49:12 +00:00
|
|
|
end
|
|
|
|
|
2021-06-21 09:46:26 +00:00
|
|
|
create_table "notes", force: :cascade do |t|
|
|
|
|
t.text "content", null: false
|
|
|
|
t.bigint "account_id", null: false
|
|
|
|
t.bigint "contact_id", null: false
|
|
|
|
t.bigint "user_id"
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
t.index ["account_id"], name: "index_notes_on_account_id"
|
|
|
|
t.index ["contact_id"], name: "index_notes_on_contact_id"
|
|
|
|
t.index ["user_id"], name: "index_notes_on_user_id"
|
|
|
|
end
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "notification_settings", force: :cascade do |t|
|
|
|
|
t.integer "account_id"
|
|
|
|
t.integer "user_id"
|
|
|
|
t.integer "email_flags", default: 0, null: false
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
2020-05-01 09:23:43 +00:00
|
|
|
t.integer "push_flags", default: 0, null: false
|
2020-03-10 18:32:15 +00:00
|
|
|
t.index ["account_id", "user_id"], name: "by_account_user", unique: true
|
2019-10-20 10:49:12 +00:00
|
|
|
end
|
|
|
|
|
2020-05-01 09:23:43 +00:00
|
|
|
create_table "notification_subscriptions", force: :cascade do |t|
|
|
|
|
t.bigint "user_id", null: false
|
|
|
|
t.integer "subscription_type", null: false
|
2020-10-27 20:44:36 +00:00
|
|
|
t.jsonb "subscription_attributes", default: {}, null: false
|
2020-05-01 09:23:43 +00:00
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
2020-05-05 18:40:56 +00:00
|
|
|
t.string "identifier"
|
|
|
|
t.index ["identifier"], name: "index_notification_subscriptions_on_identifier", unique: true
|
2020-05-01 09:23:43 +00:00
|
|
|
t.index ["user_id"], name: "index_notification_subscriptions_on_user_id"
|
|
|
|
end
|
|
|
|
|
|
|
|
create_table "notifications", force: :cascade do |t|
|
|
|
|
t.bigint "account_id", null: false
|
|
|
|
t.bigint "user_id", null: false
|
|
|
|
t.integer "notification_type", null: false
|
|
|
|
t.string "primary_actor_type", null: false
|
|
|
|
t.bigint "primary_actor_id", null: false
|
|
|
|
t.string "secondary_actor_type"
|
|
|
|
t.bigint "secondary_actor_id"
|
|
|
|
t.datetime "read_at"
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
t.index ["account_id"], name: "index_notifications_on_account_id"
|
|
|
|
t.index ["primary_actor_type", "primary_actor_id"], name: "uniq_primary_actor_per_account_notifications"
|
|
|
|
t.index ["secondary_actor_type", "secondary_actor_id"], name: "uniq_secondary_actor_per_account_notifications"
|
|
|
|
t.index ["user_id"], name: "index_notifications_on_user_id"
|
|
|
|
end
|
|
|
|
|
2021-01-14 15:05:22 +00:00
|
|
|
create_table "platform_app_permissibles", force: :cascade do |t|
|
|
|
|
t.bigint "platform_app_id", null: false
|
|
|
|
t.string "permissible_type", null: false
|
|
|
|
t.bigint "permissible_id", null: false
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
t.index ["permissible_type", "permissible_id"], name: "index_platform_app_permissibles_on_permissibles"
|
|
|
|
t.index ["platform_app_id", "permissible_id", "permissible_type"], name: "unique_permissibles_index", unique: true
|
|
|
|
t.index ["platform_app_id"], name: "index_platform_app_permissibles_on_platform_app_id"
|
|
|
|
end
|
|
|
|
|
|
|
|
create_table "platform_apps", force: :cascade do |t|
|
|
|
|
t.string "name", null: false
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
end
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "taggings", id: :serial, force: :cascade do |t|
|
|
|
|
t.integer "tag_id"
|
|
|
|
t.string "taggable_type"
|
|
|
|
t.integer "taggable_id"
|
|
|
|
t.string "tagger_type"
|
|
|
|
t.integer "tagger_id"
|
|
|
|
t.string "context", limit: 128
|
|
|
|
t.datetime "created_at"
|
|
|
|
t.index ["context"], name: "index_taggings_on_context"
|
|
|
|
t.index ["tag_id", "taggable_id", "taggable_type", "context", "tagger_id", "tagger_type"], name: "taggings_idx", unique: true
|
|
|
|
t.index ["tag_id"], name: "index_taggings_on_tag_id"
|
|
|
|
t.index ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context"
|
|
|
|
t.index ["taggable_id", "taggable_type", "tagger_id", "context"], name: "taggings_idy"
|
|
|
|
t.index ["taggable_id"], name: "index_taggings_on_taggable_id"
|
|
|
|
t.index ["taggable_type"], name: "index_taggings_on_taggable_type"
|
|
|
|
t.index ["tagger_id", "tagger_type"], name: "index_taggings_on_tagger_id_and_tagger_type"
|
|
|
|
t.index ["tagger_id"], name: "index_taggings_on_tagger_id"
|
2019-10-20 10:49:12 +00:00
|
|
|
end
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "tags", id: :serial, force: :cascade do |t|
|
|
|
|
t.string "name"
|
|
|
|
t.integer "taggings_count", default: 0
|
|
|
|
t.index ["name"], name: "index_tags_on_name", unique: true
|
2019-10-20 10:49:12 +00:00
|
|
|
end
|
|
|
|
|
2021-01-17 18:26:56 +00:00
|
|
|
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
|
2021-01-29 07:04:52 +00:00
|
|
|
t.index ["team_id", "user_id"], name: "index_team_members_on_team_id_and_user_id", unique: true
|
2021-01-17 18:26:56 +00:00
|
|
|
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"
|
2021-01-29 07:04:52 +00:00
|
|
|
t.index ["name", "account_id"], name: "index_teams_on_name_and_account_id", unique: true
|
2021-01-17 18:26:56 +00:00
|
|
|
end
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "telegram_bots", id: :serial, force: :cascade do |t|
|
|
|
|
t.string "name"
|
|
|
|
t.string "auth_key"
|
|
|
|
t.integer "account_id"
|
|
|
|
t.datetime "created_at", null: false
|
|
|
|
t.datetime "updated_at", null: false
|
2019-10-20 10:49:12 +00:00
|
|
|
end
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "users", id: :serial, force: :cascade do |t|
|
|
|
|
t.string "provider", default: "email", null: false
|
|
|
|
t.string "uid", default: "", null: false
|
|
|
|
t.string "encrypted_password", default: "", null: false
|
|
|
|
t.string "reset_password_token"
|
|
|
|
t.datetime "reset_password_sent_at"
|
|
|
|
t.datetime "remember_created_at"
|
|
|
|
t.integer "sign_in_count", default: 0, null: false
|
|
|
|
t.datetime "current_sign_in_at"
|
|
|
|
t.datetime "last_sign_in_at"
|
|
|
|
t.string "current_sign_in_ip"
|
|
|
|
t.string "last_sign_in_ip"
|
|
|
|
t.string "confirmation_token"
|
|
|
|
t.datetime "confirmed_at"
|
|
|
|
t.datetime "confirmation_sent_at"
|
|
|
|
t.string "unconfirmed_email"
|
|
|
|
t.string "name", null: false
|
2020-07-20 12:58:14 +00:00
|
|
|
t.string "display_name"
|
2020-03-10 18:32:15 +00:00
|
|
|
t.string "email"
|
|
|
|
t.json "tokens"
|
|
|
|
t.datetime "created_at", null: false
|
|
|
|
t.datetime "updated_at", null: false
|
|
|
|
t.string "pubsub_token"
|
2020-07-04 06:12:47 +00:00
|
|
|
t.integer "availability", default: 0
|
2021-01-10 13:55:33 +00:00
|
|
|
t.jsonb "ui_settings", default: {}
|
2021-09-02 12:59:45 +00:00
|
|
|
t.jsonb "custom_attributes", default: {}
|
2022-01-26 00:58:49 +00:00
|
|
|
t.string "type"
|
2022-02-02 14:07:33 +00:00
|
|
|
t.text "message_signature"
|
2020-03-10 18:32:15 +00:00
|
|
|
t.index ["email"], name: "index_users_on_email"
|
|
|
|
t.index ["pubsub_token"], name: "index_users_on_pubsub_token", unique: true
|
|
|
|
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
|
|
|
t.index ["uid", "provider"], name: "index_users_on_uid_and_provider", unique: true
|
2019-10-20 10:49:12 +00:00
|
|
|
end
|
|
|
|
|
2020-03-10 18:32:15 +00:00
|
|
|
create_table "webhooks", force: :cascade do |t|
|
|
|
|
t.integer "account_id"
|
|
|
|
t.integer "inbox_id"
|
|
|
|
t.string "url"
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
|
|
|
t.integer "webhook_type", default: 0
|
2020-04-05 16:41:27 +00:00
|
|
|
t.index ["account_id", "url"], name: "index_webhooks_on_account_id_and_url", unique: true
|
2019-10-20 10:49:12 +00:00
|
|
|
end
|
|
|
|
|
2020-10-31 18:44:33 +00:00
|
|
|
create_table "working_hours", force: :cascade do |t|
|
|
|
|
t.bigint "inbox_id"
|
|
|
|
t.bigint "account_id"
|
|
|
|
t.integer "day_of_week", null: false
|
|
|
|
t.boolean "closed_all_day", default: false
|
|
|
|
t.integer "open_hour"
|
|
|
|
t.integer "open_minutes"
|
|
|
|
t.integer "close_hour"
|
|
|
|
t.integer "close_minutes"
|
|
|
|
t.datetime "created_at", precision: 6, null: false
|
|
|
|
t.datetime "updated_at", precision: 6, null: false
|
2022-02-22 09:28:49 +00:00
|
|
|
t.boolean "open_all_day", default: false
|
2020-10-31 18:44:33 +00:00
|
|
|
t.index ["account_id"], name: "index_working_hours_on_account_id"
|
|
|
|
t.index ["inbox_id"], name: "index_working_hours_on_inbox_id"
|
|
|
|
end
|
|
|
|
|
2021-12-19 04:17:07 +00:00
|
|
|
add_foreign_key "account_users", "accounts", on_delete: :cascade
|
|
|
|
add_foreign_key "account_users", "users", on_delete: :cascade
|
2020-03-10 18:32:15 +00:00
|
|
|
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
2021-08-03 14:41:52 +00:00
|
|
|
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
2021-12-19 04:17:07 +00:00
|
|
|
add_foreign_key "agent_bots", "accounts", on_delete: :cascade
|
|
|
|
add_foreign_key "campaigns", "accounts", on_delete: :cascade
|
|
|
|
add_foreign_key "campaigns", "inboxes", on_delete: :cascade
|
2021-12-08 12:33:27 +00:00
|
|
|
add_foreign_key "contact_inboxes", "contacts", on_delete: :cascade
|
|
|
|
add_foreign_key "contact_inboxes", "inboxes", on_delete: :cascade
|
2021-12-19 04:17:07 +00:00
|
|
|
add_foreign_key "conversations", "campaigns", on_delete: :cascade
|
2021-12-08 12:33:27 +00:00
|
|
|
add_foreign_key "conversations", "contact_inboxes", on_delete: :cascade
|
2021-12-19 04:17:07 +00:00
|
|
|
add_foreign_key "conversations", "teams", on_delete: :cascade
|
|
|
|
add_foreign_key "csat_survey_responses", "accounts", on_delete: :cascade
|
|
|
|
add_foreign_key "csat_survey_responses", "contacts", on_delete: :cascade
|
|
|
|
add_foreign_key "csat_survey_responses", "conversations", on_delete: :cascade
|
|
|
|
add_foreign_key "csat_survey_responses", "messages", on_delete: :cascade
|
|
|
|
add_foreign_key "csat_survey_responses", "users", column: "assigned_agent_id", on_delete: :cascade
|
|
|
|
add_foreign_key "data_imports", "accounts", on_delete: :cascade
|
|
|
|
add_foreign_key "mentions", "conversations", on_delete: :cascade
|
|
|
|
add_foreign_key "mentions", "users", on_delete: :cascade
|
|
|
|
add_foreign_key "notes", "accounts", on_delete: :cascade
|
|
|
|
add_foreign_key "notes", "contacts", on_delete: :cascade
|
|
|
|
add_foreign_key "notes", "users", on_delete: :cascade
|
|
|
|
add_foreign_key "team_members", "teams", on_delete: :cascade
|
|
|
|
add_foreign_key "team_members", "users", on_delete: :cascade
|
|
|
|
add_foreign_key "teams", "accounts", on_delete: :cascade
|
2021-01-05 14:37:04 +00:00
|
|
|
create_trigger("accounts_after_insert_row_tr", :generated => true, :compatibility => 1).
|
|
|
|
on("accounts").
|
|
|
|
after(:insert).
|
|
|
|
for_each(:row) do
|
|
|
|
"execute format('create sequence IF NOT EXISTS conv_dpid_seq_%s', NEW.id);"
|
|
|
|
end
|
|
|
|
|
|
|
|
create_trigger("conversations_before_insert_row_tr", :generated => true, :compatibility => 1).
|
|
|
|
on("conversations").
|
|
|
|
before(:insert).
|
|
|
|
for_each(:row) do
|
|
|
|
"NEW.display_id := nextval('conv_dpid_seq_' || NEW.account_id);"
|
|
|
|
end
|
|
|
|
|
2021-04-29 16:53:32 +00:00
|
|
|
create_trigger("camp_dpid_before_insert", :generated => true, :compatibility => 1).
|
|
|
|
on("accounts").
|
|
|
|
name("camp_dpid_before_insert").
|
|
|
|
after(:insert).
|
|
|
|
for_each(:row) do
|
|
|
|
"execute format('create sequence IF NOT EXISTS camp_dpid_seq_%s', NEW.id);"
|
|
|
|
end
|
|
|
|
|
|
|
|
create_trigger("campaigns_before_insert_row_tr", :generated => true, :compatibility => 1).
|
|
|
|
on("campaigns").
|
|
|
|
before(:insert).
|
|
|
|
for_each(:row) do
|
|
|
|
"NEW.display_id := nextval('camp_dpid_seq_' || NEW.account_id);"
|
|
|
|
end
|
|
|
|
|
2022-01-11 23:14:55 +00:00
|
|
|
end
|