CREATE TABLE calling_list_template (dbid INT AUTO_INCREMENT, status VARCHAR(10) DEFAULT 'NOT_DIALED', number TEXT NOT NULL, custom VARCHAR(250), last_attempt_datetime DATETIME, nbattempts INT DEFAULT '0', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE calling_list_test (dbid INT AUTO_INCREMENT, status VARCHAR(10), current_treament_type VARCHAR(17), number VARCHAR(50), last_attempt_datetime DATETIME, occurent_attempt INT, occurent_treament_attempt INT, time_zone VARCHAR(30), created_at DATETIME, updated_at DATETIME, PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_agent (dbid INT AUTO_INCREMENT, username VARCHAR(100), shortusername VARCHAR(100), group_fk INT, setting_fk INT, info_fk INT, user_fk INT, jbuser_fk INT, tenant_fk INT, extension VARCHAR(100), active VARCHAR(3) DEFAULT 'yes', isconnected VARCHAR(3) DEFAULT 'no', pbx_username VARCHAR(100), pbx_password VARCHAR(100), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX setting_fk_idx (setting_fk), INDEX info_fk_idx (info_fk), INDEX user_fk_idx (user_fk), INDEX jbuser_fk_idx (jbuser_fk), INDEX group_fk_idx (group_fk), INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_agent_group (dbid INT AUTO_INCREMENT, group_fk INT, agent_fk INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX group_fk_idx (group_fk), INDEX agent_fk_idx (agent_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_agent_info (dbid INT AUTO_INCREMENT, firstname VARCHAR(100), lastname VARCHAR(100), email VARCHAR(100), birthdate DATE, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_agent_setting (dbid INT AUTO_INCREMENT, autoreadyatstart VARCHAR(3) DEFAULT 'no', autoready VARCHAR(3) DEFAULT 'no', canbrowse VARCHAR(3) DEFAULT 'no', active VARCHAR(3) DEFAULT 'yes', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_agent_skill (dbid INT AUTO_INCREMENT, agent_fk INT, skill_fk INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX agent_fk_idx (agent_fk), INDEX skill_fk_idx (skill_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_calling_list (dbid INT AUTO_INCREMENT, campaign_dbid INT NOT NULL, calling_list_name TEXT, calling_list_table_name TEXT, maximum_try INT, dialing_weight INT DEFAULT '1' NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX campaign_dbid_idx (campaign_dbid), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_campaign (dbid INT AUTO_INCREMENT, campaign_name TEXT NOT NULL, last_status VARCHAR(7) DEFAULT 'STOPPED', is_paused TINYINT DEFAULT '0', dialplan_id INT NOT NULL, caller_id_name TEXT, caller_id_number TEXT, campaign_mode VARCHAR(11) NOT NULL, voicerecordingpolicy_fk INT, tenant_fk INT, week_schedule_fk INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplan_id_idx (dialplan_id), INDEX voicerecordingpolicy_fk_idx (voicerecordingpolicy_fk), INDEX tenant_fk_idx (tenant_fk), INDEX week_schedule_fk_idx (week_schedule_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialing_time (dbid INT AUTO_INCREMENT, frequency VARCHAR(14), campaign_dbid INT, start_date DATE, end_date DATE, start_time TIME, end_time TIME, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan (dbid INT AUTO_INCREMENT, tenant_fk INT, dialplan VARCHAR(50), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan_calculatornode (dbid INT AUTO_INCREMENT, dialplan_node_id INT NOT NULL, calcscript TEXT, storevariable VARCHAR(50), onnext VARCHAR(10), onerror VARCHAR(10), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplan_node_id_idx (dialplan_node_id), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan_clocknode (dbid INT AUTO_INCREMENT, dialplan_node_id INT NOT NULL, clockname VARCHAR(250), action VARCHAR(250), onnext VARCHAR(10), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplan_node_id_idx (dialplan_node_id), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan_constant (dbid INT AUTO_INCREMENT, dialplan_id INT, constname VARCHAR(250), constvalue VARCHAR(250), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplan_id_idx (dialplan_id), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan_counternode (dbid INT AUTO_INCREMENT, dialplan_node_id INT, countername VARCHAR(250), startat VARCHAR(250) DEFAULT '0', increment VARCHAR(250) DEFAULT '1', maxvalue VARCHAR(250), onnext VARCHAR(10), onmaxvalue VARCHAR(10), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplan_node_id_idx (dialplan_node_id), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan_dblnk (dbid INT AUTO_INCREMENT, dialplan_id INT, linkname VARCHAR(200), host VARCHAR(100), username VARCHAR(100), password VARCHAR(100), databasename VARCHAR(100), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplan_id_idx (dialplan_id), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan_dbnode (dbid INT AUTO_INCREMENT, dialplan_node_id INT NOT NULL, db_link INT, sqlquery TEXT, resultvar VARCHAR(255), onnext VARCHAR(10), onsqlerror VARCHAR(10), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplan_node_id_idx (dialplan_node_id), INDEX db_link_idx (db_link), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan_dialnode (dbid INT AUTO_INCREMENT, dialplan_node_id INT NOT NULL, phonenumber VARCHAR(250), timeout VARCHAR(250), var_dialresult VARCHAR(250), var_dialtime VARCHAR(250), var_answertime VARCHAR(250), var_conversationtime VARCHAR(250), waitforanswer_moh VARCHAR(250), callee_announcement VARCHAR(250), caller_digit_tocancel VARCHAR(250), caller_dtmf_tosend VARCHAR(250), callee_dtmf_tosend VARCHAR(250), caller_can_hanguponstar VARCHAR(20), callee_can_hanguponstar VARCHAR(20), call_conect_audio VARCHAR(250), call_limit_time VARCHAR(250), call_limit_warning_time VARCHAR(250), call_limit_warning_repeat_time VARCHAR(250), call_limit_end_audio VARCHAR(250), call_limit_warning_audio VARCHAR(250), call_limit_playtocaller VARCHAR(250), call_limit_playtocallee VARCHAR(250), callee_run_dialplan INT, caller_dtmf_torecord_ondemand VARCHAR(250), callee_dtmf_torecord_ondemand VARCHAR(250), call_record_ondemand_filename VARCHAR(250), caller_dtmf_totransfer VARCHAR(250), caller_transfer_dialplan INT, callee_dtmf_totransfer VARCHAR(250), callee_transfer_dialplan INT, onanswered VARCHAR(10), onnoanswer VARCHAR(10), onbusy VARCHAR(10), oncongestion VARCHAR(10), oncanceled VARCHAR(10), onchanunavail VARCHAR(10), onerror VARCHAR(10), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplan_node_id_idx (dialplan_node_id), INDEX callee_run_dialplan_idx (callee_run_dialplan), INDEX caller_transfer_dialplan_idx (caller_transfer_dialplan), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan_exitnode (dbid INT AUTO_INCREMENT, dialplan_node_id INT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplan_node_id_idx (dialplan_node_id), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan_gototagnode (dbid INT AUTO_INCREMENT, dialplan_node_id INT NOT NULL, tag_node_id VARCHAR(250), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplan_node_id_idx (dialplan_node_id), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan_ifnode (dbid INT AUTO_INCREMENT, dialplan_node_id INT NOT NULL, callproperty VARCHAR(50), operand VARCHAR(14) DEFAULT 'EQUAL', svalue VARCHAR(250), ontrue VARCHAR(10), onfalse VARCHAR(10), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplan_node_id_idx (dialplan_node_id), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan_node (dbid INT AUTO_INCREMENT, dialplanid INT, nodedatatype VARCHAR(11) NOT NULL, isroot VARCHAR(3) DEFAULT 'no', jumponhangup VARCHAR(3) DEFAULT 'no', tag VARCHAR(100), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplanid_idx (dialplanid), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan_nodelayout (dbid INT AUTO_INCREMENT, dialplan_node_id INT, x INT, y INT, page INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplan_node_id_idx (dialplan_node_id), INDEX page_idx (page), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan_page (dbid INT AUTO_INCREMENT, dialplan_id INT, pagename VARCHAR(255), pos INT DEFAULT '0', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplan_id_idx (dialplan_id), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan_pbxexecnode (dbid INT AUTO_INCREMENT, dialplan_node_id INT NOT NULL, application TEXT, onnext VARCHAR(10), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplan_node_id_idx (dialplan_node_id), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan_playbacknode (dbid INT AUTO_INCREMENT, dialplan_node_id INT NOT NULL, prompts TEXT, lang VARCHAR(250), is_controllable VARCHAR(3) DEFAULT 'no', do_getuserdata VARCHAR(3) DEFAULT 'no', control_rw VARCHAR(5), control_ff VARCHAR(5), control_stop VARCHAR(5), control_pause VARCHAR(5), control_restart VARCHAR(5), control_skipms VARCHAR(10), getuserdata_minlength VARCHAR(250), getuserdata_maxlength VARCHAR(250), getuserdata_delayms VARCHAR(250), getuserdata_delimit VARCHAR(250), getuserdata_maxerrors INT, getuserdata_errprompts TEXT, getuserdata_storevariable VARCHAR(250), onnext VARCHAR(10), onmaxerror VARCHAR(10), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplan_node_id_idx (dialplan_node_id), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan_propertynode (dbid INT AUTO_INCREMENT, dialplan_node_id INT NOT NULL, xml_actions TEXT, onnext VARCHAR(10), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplan_node_id_idx (dialplan_node_id), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan_queuenode (dbid INT AUTO_INCREMENT, dialplan_node_id INT, queue_fk INT, onok VARCHAR(20), onfull VARCHAR(20), ontimeout VARCHAR(20), onempty VARCHAR(20), onleave VARCHAR(20), onabandon VARCHAR(20), onerror VARCHAR(20), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplan_node_id_idx (dialplan_node_id), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan_sendmailnode (dbid INT AUTO_INCREMENT, dialplan_node_id INT, fromemail VARCHAR(250), toemail VARCHAR(250), subject VARCHAR(250), body TEXT, replyto VARCHAR(250), cc VARCHAR(250), bcc VARCHAR(250), contenttype VARCHAR(250), attachments TEXT, onnext VARCHAR(10), onerror VARCHAR(10), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplan_node_id_idx (dialplan_node_id), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan_subdialplannode (dbid INT AUTO_INCREMENT, dialplan_node_id INT NOT NULL, included_dialplan_id INT, onnext VARCHAR(10), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplan_node_id_idx (dialplan_node_id), INDEX included_dialplan_id_idx (included_dialplan_id), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_dialplan_transfernode (dbid INT AUTO_INCREMENT, dialplan_node_id INT NOT NULL, transfer_type VARCHAR(250), transfer_data VARCHAR(250), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX dialplan_node_id_idx (dialplan_node_id), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_did (dbid INT AUTO_INCREMENT, tenant_fk INT, phonenumber VARCHAR(100), cidmatch VARCHAR(100), description VARCHAR(255), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_extern_logdb (dbid INT AUTO_INCREMENT, name VARCHAR(50), dsn TEXT, username VARCHAR(200), password VARCHAR(200), active VARCHAR(3) DEFAULT 'yes', insert_log_agent_call VARCHAR(3) DEFAULT 'yes', insert_log_agent_event VARCHAR(3) DEFAULT 'yes', insert_log_call_record VARCHAR(3) DEFAULT 'yes', insert_log_campaign_activity VARCHAR(3) DEFAULT 'yes', insert_log_campaign_dialing VARCHAR(3) DEFAULT 'yes', connected VARCHAR(3) DEFAULT 'no', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_group (dbid INT AUTO_INCREMENT, tenant_fk INT, name VARCHAR(100), jb_group_fk INT, setting_fk INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX jb_group_fk_idx (jb_group_fk), INDEX setting_fk_idx (setting_fk), INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_inbound (dbid INT AUTO_INCREMENT, tenant_fk INT, inbound_name TEXT, last_status TEXT, is_service TINYINT DEFAULT '0' NOT NULL, dialplan_id INT, service_dialplan_id INT, closehours_dialplan_id INT, voicerecordingpolicy_fk INT, week_schedule_fk INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX voicerecordingpolicy_fk_idx (voicerecordingpolicy_fk), INDEX tenant_fk_idx (tenant_fk), INDEX week_schedule_fk_idx (week_schedule_fk), INDEX closehours_dialplan_id_idx (closehours_dialplan_id), INDEX dialplan_id_idx (dialplan_id), INDEX service_dialplan_id_idx (service_dialplan_id), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_inbound_did (id INT AUTO_INCREMENT, did_id INT, inbound_id INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX did_id_idx (did_id), INDEX inbound_id_idx (inbound_id), PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE conf_inbound_time (dbid INT AUTO_INCREMENT, frequency VARCHAR(14), is_open VARCHAR(5) DEFAULT 'OPEN', inbound_dbid INT, start_date DATE, end_date DATE, start_time TIME, end_time TIME, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX inbound_dbid_idx (inbound_dbid), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_live_stat (dbid INT AUTO_INCREMENT, typename VARCHAR(50), name VARCHAR(40), associated_table VARCHAR(100), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_pbx (dbid INT AUTO_INCREMENT, pbx_name TEXT, password VARCHAR(100), can_outbound VARCHAR(3) DEFAULT 'yes', can_register_agent VARCHAR(3) DEFAULT 'yes', registration_host VARCHAR(100), registration_port VARCHAR(100), jbuser_fk INT, isconnected VARCHAR(3) DEFAULT 'no', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX jbuser_fk_idx (jbuser_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_queue (dbid INT AUTO_INCREMENT, tenant_fk INT, queuetype VARCHAR(7) DEFAULT 'static', name VARCHAR(250), moh VARCHAR(100), agent_announce VARCHAR(200), strategy VARCHAR(26) DEFAULT 'fewestmeanconversationtime', servicelevel VARCHAR(100) DEFAULT '60', ringtimeout VARCHAR(100) DEFAULT '30', totalwaittime VARCHAR(100) DEFAULT '0', priority VARCHAR(100) DEFAULT '1', wrapuptime VARCHAR(100) DEFAULT '15', maxwaitingpeople VARCHAR(100), enterifempty VARCHAR(3) DEFAULT 'yes', announce_frequency VARCHAR(100), periodic_announce_frequency VARCHAR(100), random_periodic_announce VARCHAR(3) DEFAULT 'no', announce_position VARCHAR(5) DEFAULT 'no', announce_holdtime VARCHAR(4) DEFAULT 'no', announce_position_limit VARCHAR(100) DEFAULT '5', announce_round_seconds VARCHAR(100) DEFAULT '10', queue_youarenext VARCHAR(100), queue_thereare VARCHAR(100), queue_callswaiting VARCHAR(100), queue_holdtime VARCHAR(100), queue_minutes VARCHAR(100), queue_seconds VARCHAR(100), queue_thankyou VARCHAR(100), queue_reporthold VARCHAR(100), periodic_announce VARCHAR(100), url TEXT, dtmf_toleave VARCHAR(20), agentselect_expression TEXT, callbased_filter_expression TEXT, voicerecordingpolicy_fk INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX voicerecordingpolicy_fk_idx (voicerecordingpolicy_fk), INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_report (dbid INT AUTO_INCREMENT, name VARCHAR(100), requesturl VARCHAR(200), category VARCHAR(8), builtin VARCHAR(3) DEFAULT 'no', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_skill (dbid INT AUTO_INCREMENT, tenant_fk INT, name VARCHAR(100), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_storageserver (dbid INT AUTO_INCREMENT, storagename VARCHAR(100), password VARCHAR(100), pathformat VARCHAR(250), directory VARCHAR(100), jbuser_fk INT, isconnected VARCHAR(3) DEFAULT 'no', ftp_host VARCHAR(250), ftp_username VARCHAR(100), ftp_password VARCHAR(100), ftp_port INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX jbuser_fk_idx (jbuser_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_tenant (dbid INT AUTO_INCREMENT, name VARCHAR(50), fullname VARCHAR(100), description TEXT, active VARCHAR(3) DEFAULT 'yes', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_treatment (dbid INT AUTO_INCREMENT, campaign_dbid INT, type VARCHAR(17) NOT NULL, delay INT NOT NULL, number_of_try INT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_user (dbid INT AUTO_INCREMENT, tenant_fk INT, firstname VARCHAR(50), lastname VARCHAR(50), sf_user_fk INT, username VARCHAR(50), email VARCHAR(100), profile_fk INT, is_super_tenant VARCHAR(3) DEFAULT 'no', deletable VARCHAR(3) DEFAULT 'yes', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX sf_user_fk_idx (sf_user_fk), INDEX profile_fk_idx (profile_fk), INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_user_profile (dbid INT AUTO_INCREMENT, tenant_fk INT, name VARCHAR(200), sf_group_fk INT, builtin VARCHAR(3) DEFAULT 'no', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX sf_group_fk_idx (sf_group_fk), INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_voicerecording_policy (dbid INT AUTO_INCREMENT, nameformat VARCHAR(100), dorecord VARCHAR(8) DEFAULT 'off', onduplicate VARCHAR(9) DEFAULT 'append', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE conf_week_schedule (dbid INT AUTO_INCREMENT, monday_sched VARCHAR(8) DEFAULT 'FULLTIME', monday_start TIME DEFAULT '00:00:00', monday_end TIME DEFAULT '00:00:00', tuesday_sched VARCHAR(8) DEFAULT 'FULLTIME', tuesday_start TIME DEFAULT '00:00:00', tuesday_end TIME DEFAULT '00:00:00', wednesday_sched VARCHAR(8) DEFAULT 'FULLTIME', wednesday_start TIME DEFAULT '00:00:00', wednesday_end TIME DEFAULT '00:00:00', thursday_sched VARCHAR(8) DEFAULT 'FULLTIME', thursday_start TIME DEFAULT '00:00:00', thursday_end TIME DEFAULT '00:00:00', friday_sched VARCHAR(8) DEFAULT 'FULLTIME', friday_start TIME DEFAULT '00:00:00', friday_end TIME DEFAULT '00:00:00', saturday_sched VARCHAR(8) DEFAULT 'FULLTIME', saturday_start TIME DEFAULT '00:00:00', saturday_end TIME DEFAULT '00:00:00', sunday_sched VARCHAR(8) DEFAULT 'FULLTIME', sunday_start TIME DEFAULT '00:00:00', sunday_end TIME DEFAULT '00:00:00', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE jb_group (dbid INT AUTO_INCREMENT, name VARCHAR(100), description TEXT, builtin VARCHAR(3) DEFAULT 'no', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE jb_user (dbid INT AUTO_INCREMENT, type VARCHAR(20) DEFAULT 'others', username VARCHAR(100), password VARCHAR(200), email VARCHAR(80), builtin VARCHAR(3) DEFAULT 'no', active VARCHAR(3) DEFAULT 'yes', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE jb_user_group (dbid INT AUTO_INCREMENT, username_fk VARCHAR(200), groupname_fk VARCHAR(200), isadmin VARCHAR(3) DEFAULT 'no', builtin VARCHAR(3) DEFAULT 'no', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX username_fk_idx (username_fk), INDEX groupname_fk_idx (groupname_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE license_info (dbid INT AUTO_INCREMENT, infokey VARCHAR(100) DEFAULT '' NOT NULL, infovalue VARCHAR(100), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE livestat_agent (statkey VARCHAR(100), agentdbid INT, agentusername VARCHAR(50), firstname VARCHAR(250), lastname VARCHAR(250), currentstatus VARCHAR(50), currentstatussince DATETIME, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(statkey)) ENGINE = INNODB;
CREATE TABLE livestat_inbound (statkey VARCHAR(50), currentcalls INT DEFAULT '0', totalcalls INT DEFAULT '0', totaltime BIGINT DEFAULT '0', name VARCHAR(100), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(statkey)) ENGINE = INNODB;
CREATE TABLE livestat_outbound (statkey VARCHAR(50), name VARCHAR(50), currentcalls INT, totalcalls INT, totaltime BIGINT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(statkey)) ENGINE = INNODB;
CREATE TABLE livestat_queue (statkey VARCHAR(100), nbcalls INT DEFAULT '0', nbelligibleagents INT DEFAULT '0', nbwaitingagents INT DEFAULT '0', totalreceivedcalls INT DEFAULT '0', queuename VARCHAR(100), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(statkey)) ENGINE = INNODB;
CREATE TABLE log_agent_call (dbid INT AUTO_INCREMENT, tenant_fk INT, tracknumber VARCHAR(40), callername VARCHAR(100), callernumber VARCHAR(100), callednum VARCHAR(40), is_inbound VARCHAR(5), is_manual VARCHAR(5), campaign_id INT, dialplan_id INT, queue_id INT, agentdialing_seconds INT, agentanswered_seconds INT, agentdbid INT, groupdbid INT, callreceived_at DATETIME, callresult VARCHAR(50), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE log_agent_event (dbid BIGINT AUTO_INCREMENT, tenant_fk INT, agentdbid VARCHAR(50) DEFAULT '' NOT NULL, groupdbid INT, agentstatus VARCHAR(50), started_at DATETIME, duration INT, iscurrent VARCHAR(3) DEFAULT 'yes', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE log_call_record (dbid BIGINT AUTO_INCREMENT, tenant_fk INT, tracknumber VARCHAR(40), callername VARCHAR(100), callernumber VARCHAR(100), callednumber VARCHAR(50), is_inbound VARCHAR(5), campaign_id INT, dialplan_id INT, dialplan_type VARCHAR(10), callresult VARCHAR(20), call_init_time DATETIME, dialplan_start_time DATETIME, dialplan_end_time DATETIME, call_free_time DATETIME, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE log_call_voicerecording (dbid BIGINT UNSIGNED AUTO_INCREMENT, tenant_fk INT, calltracknumber VARCHAR(50), recordid VARCHAR(50), location VARCHAR(7), location_pbx_fk INT, location_storage_fk INT, filename TEXT, filesize INT UNSIGNED, started_at DATETIME, duration INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX location_pbx_fk_idx (location_pbx_fk), INDEX location_storage_fk_idx (location_storage_fk), INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE log_campaign_activity (id BIGINT AUTO_INCREMENT, campaign_id INT, tenant_fk INT, activity VARCHAR(200), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE log_dialing (dbid INT AUTO_INCREMENT, tenant_fk INT, tracknumber VARCHAR(20), event VARCHAR(50), campaign_dbid INT, callinglist_id INT, phone_number_dbid INT, phone_number VARCHAR(50), dialing_seconds INT, billable_seconds INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE log_queue_record (dbid BIGINT AUTO_INCREMENT, tenant_fk INT, tracknumber VARCHAR(40), callername VARCHAR(100), callernumber VARCHAR(100), callednumber VARCHAR(50), queueresult VARCHAR(50), is_inbound VARCHAR(5), campaign_id INT, dialplan_id INT, dialplan_type VARCHAR(10) DEFAULT 'normal', queue_id INT, queue_enter_time DATETIME, queue_bridge_time DATETIME, queue_exit_time DATETIME, queue_agentdialing_result VARCHAR(40), queue_agentdialing_seconds INT, queue_agentanswered_seconds INT, agentdbid INT, groupdbid INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE log_resume_daily_agent_call (dbid INT AUTO_INCREMENT, tenant_fk INT, covereddate DATETIME, agentdbid INT, groupdbid INT, totalinbounds INT, totaloutbounds INT, totalmanuals INT, totaldialing_seconds INT, totalanswered_seconds INT, callresult VARCHAR(50), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE log_resume_daily_agent_event (dbid BIGINT AUTO_INCREMENT, tenant_fk INT, covereddate DATETIME, agentdbid VARCHAR(50), groupdbid INT, agentstatus VARCHAR(70), nbstates INT, totalduration INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE log_resume_daily_call_record (dbid INT AUTO_INCREMENT, tenant_fk INT, covereddate DATETIME, is_inbound VARCHAR(5), campaign_id INT, dialplan_type VARCHAR(10), callresult VARCHAR(20), nbcalls INT, dialingtime INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE log_resume_daily_queue_record (dbid INT AUTO_INCREMENT, tenant_fk INT, covereddate DATETIME, queue_id INT, queueresult VARCHAR(50), is_inbound VARCHAR(5), campaign_id INT, dialplan_id INT, dialplan_type VARCHAR(20), nbcalls INT, totalqueueseconds INT, totalbridgeseconds INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE log_resume_hourly_agent_call (dbid INT AUTO_INCREMENT, tenant_fk INT, covereddate DATETIME, agentdbid INT, groupdbid INT, totalinbounds INT, totaloutbounds INT, totalmanuals INT, totaldialing_seconds INT, totalanswered_seconds INT, callresult VARCHAR(50), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE log_resume_hourly_agent_event (dbid BIGINT AUTO_INCREMENT, tenant_fk INT, covereddate DATETIME, agentdbid VARCHAR(50), groupdbid INT, agentstatus VARCHAR(70), nbstates INT, totalduration INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE log_resume_hourly_call_record (dbid INT AUTO_INCREMENT, tenant_fk INT, covereddate DATETIME, is_inbound VARCHAR(5), campaign_id INT, dialplan_type VARCHAR(10), callresult VARCHAR(20), nbcalls INT, dialingtime INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE log_resume_hourly_queue_record (dbid INT AUTO_INCREMENT, tenant_fk INT, covereddate DATETIME, queue_id INT, queueresult VARCHAR(50), is_inbound VARCHAR(5), campaign_id INT, dialplan_id INT, dialplan_type VARCHAR(20), nbcalls INT, totalqueueseconds INT, totalbridgeseconds INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX tenant_fk_idx (tenant_fk), PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE server_config (dbid INT AUTO_INCREMENT, category VARCHAR(7) DEFAULT 'GENERAL', setting VARCHAR(250), value VARCHAR(100), defaultvalue VARCHAR(100), editable VARCHAR(3) DEFAULT 'yes', ispublic VARCHAR(3) DEFAULT 'yes', neededbyserver VARCHAR(3) DEFAULT 'no', created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE sf_guard_group (id INT AUTO_INCREMENT, name VARCHAR(255), description TEXT, created_at DATETIME, updated_at DATETIME, PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE sf_guard_group_permission (group_id BIGINT, permission_id BIGINT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(group_id, permission_id)) ENGINE = INNODB;
CREATE TABLE sf_guard_permission (id BIGINT AUTO_INCREMENT, name VARCHAR(255) UNIQUE, description TEXT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE sf_guard_remember_key (id BIGINT AUTO_INCREMENT, user_id BIGINT, remember_key VARCHAR(32), ip_address VARCHAR(50), created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX user_id_idx (user_id), PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE sf_guard_user (id BIGINT AUTO_INCREMENT, first_name VARCHAR(255), last_name VARCHAR(255), email_address VARCHAR(255) NOT NULL UNIQUE, username VARCHAR(128) NOT NULL UNIQUE, algorithm VARCHAR(128) DEFAULT 'sha1' NOT NULL, salt VARCHAR(128), password VARCHAR(128), is_active TINYINT(1) DEFAULT '1', is_super_admin TINYINT(1) DEFAULT '0', last_login DATETIME, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX is_active_idx_idx (is_active), PRIMARY KEY(id)) ENGINE = INNODB;
CREATE TABLE sf_guard_user_group (user_id BIGINT, group_id BIGINT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(user_id, group_id)) ENGINE = INNODB;
CREATE TABLE sf_guard_user_permission (user_id BIGINT, permission_id BIGINT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(user_id, permission_id)) ENGINE = INNODB;
CREATE TABLE user_password_request (dbid INT AUTO_INCREMENT, generatedkey VARCHAR(250), username VARCHAR(100), user_fk INT, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(dbid)) ENGINE = INNODB;
CREATE TABLE sf_guard_forgot_password (id BIGINT AUTO_INCREMENT, user_id BIGINT NOT NULL, unique_key VARCHAR(255), expires_at DATETIME NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX user_id_idx (user_id), PRIMARY KEY(id)) ENGINE = INNODB;
ALTER TABLE conf_agent ADD CONSTRAINT conf_agent_user_fk_sf_guard_user_id FOREIGN KEY (user_fk) REFERENCES sf_guard_user(id);
ALTER TABLE conf_agent ADD CONSTRAINT conf_agent_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE conf_agent ADD CONSTRAINT conf_agent_setting_fk_conf_agent_setting_dbid FOREIGN KEY (setting_fk) REFERENCES conf_agent_setting(dbid);
ALTER TABLE conf_agent ADD CONSTRAINT conf_agent_jbuser_fk_jb_user_dbid FOREIGN KEY (jbuser_fk) REFERENCES jb_user(dbid);
ALTER TABLE conf_agent ADD CONSTRAINT conf_agent_info_fk_conf_agent_info_dbid FOREIGN KEY (info_fk) REFERENCES conf_agent_info(dbid);
ALTER TABLE conf_agent ADD CONSTRAINT conf_agent_group_fk_conf_group_dbid FOREIGN KEY (group_fk) REFERENCES conf_group(dbid);
ALTER TABLE conf_agent_group ADD CONSTRAINT conf_agent_group_group_fk_conf_group_dbid FOREIGN KEY (group_fk) REFERENCES conf_group(dbid);
ALTER TABLE conf_agent_group ADD CONSTRAINT conf_agent_group_agent_fk_conf_agent_dbid FOREIGN KEY (agent_fk) REFERENCES conf_agent(dbid);
ALTER TABLE conf_agent_skill ADD CONSTRAINT conf_agent_skill_skill_fk_conf_skill_dbid FOREIGN KEY (skill_fk) REFERENCES conf_skill(dbid);
ALTER TABLE conf_agent_skill ADD CONSTRAINT conf_agent_skill_agent_fk_conf_agent_dbid FOREIGN KEY (agent_fk) REFERENCES conf_agent(dbid);
ALTER TABLE conf_calling_list ADD CONSTRAINT conf_calling_list_campaign_dbid_conf_campaign_dbid FOREIGN KEY (campaign_dbid) REFERENCES conf_campaign(dbid);
ALTER TABLE conf_campaign ADD CONSTRAINT cvcd FOREIGN KEY (voicerecordingpolicy_fk) REFERENCES conf_voicerecording_policy(dbid);
ALTER TABLE conf_campaign ADD CONSTRAINT conf_campaign_week_schedule_fk_conf_week_schedule_dbid FOREIGN KEY (week_schedule_fk) REFERENCES conf_week_schedule(dbid);
ALTER TABLE conf_campaign ADD CONSTRAINT conf_campaign_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE conf_campaign ADD CONSTRAINT conf_campaign_dialplan_id_conf_dialplan_dbid FOREIGN KEY (dialplan_id) REFERENCES conf_dialplan(dbid);
ALTER TABLE conf_dialplan ADD CONSTRAINT conf_dialplan_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE conf_dialplan_calculatornode ADD CONSTRAINT cdcd FOREIGN KEY (dialplan_node_id) REFERENCES conf_dialplan_node(dbid);
ALTER TABLE conf_dialplan_clocknode ADD CONSTRAINT conf_dialplan_clocknode_dialplan_node_id_conf_dialplan_node_dbid FOREIGN KEY (dialplan_node_id) REFERENCES conf_dialplan_node(dbid);
ALTER TABLE conf_dialplan_constant ADD CONSTRAINT conf_dialplan_constant_dialplan_id_conf_dialplan_dbid FOREIGN KEY (dialplan_id) REFERENCES conf_dialplan(dbid);
ALTER TABLE conf_dialplan_counternode ADD CONSTRAINT cdcd_1 FOREIGN KEY (dialplan_node_id) REFERENCES conf_dialplan_node(dbid);
ALTER TABLE conf_dialplan_dblnk ADD CONSTRAINT conf_dialplan_dblnk_dialplan_id_conf_dialplan_dbid FOREIGN KEY (dialplan_id) REFERENCES conf_dialplan(dbid);
ALTER TABLE conf_dialplan_dbnode ADD CONSTRAINT conf_dialplan_dbnode_dialplan_node_id_conf_dialplan_node_dbid FOREIGN KEY (dialplan_node_id) REFERENCES conf_dialplan_node(dbid);
ALTER TABLE conf_dialplan_dbnode ADD CONSTRAINT conf_dialplan_dbnode_db_link_conf_dialplan_dblnk_dbid FOREIGN KEY (db_link) REFERENCES conf_dialplan_dblnk(dbid);
ALTER TABLE conf_dialplan_dialnode ADD CONSTRAINT conf_dialplan_dialnode_dialplan_node_id_conf_dialplan_node_dbid FOREIGN KEY (dialplan_node_id) REFERENCES conf_dialplan_node(dbid);
ALTER TABLE conf_dialplan_dialnode ADD CONSTRAINT conf_dialplan_dialnode_callee_run_dialplan_conf_dialplan_dbid FOREIGN KEY (callee_run_dialplan) REFERENCES conf_dialplan(dbid);
ALTER TABLE conf_dialplan_dialnode ADD CONSTRAINT cccd FOREIGN KEY (caller_transfer_dialplan) REFERENCES conf_dialplan(dbid);
ALTER TABLE conf_dialplan_exitnode ADD CONSTRAINT conf_dialplan_exitnode_dialplan_node_id_conf_dialplan_node_dbid FOREIGN KEY (dialplan_node_id) REFERENCES conf_dialplan_node(dbid);
ALTER TABLE conf_dialplan_gototagnode ADD CONSTRAINT cdcd_2 FOREIGN KEY (dialplan_node_id) REFERENCES conf_dialplan_node(dbid);
ALTER TABLE conf_dialplan_ifnode ADD CONSTRAINT conf_dialplan_ifnode_dialplan_node_id_conf_dialplan_node_dbid FOREIGN KEY (dialplan_node_id) REFERENCES conf_dialplan_node(dbid);
ALTER TABLE conf_dialplan_node ADD CONSTRAINT conf_dialplan_node_dialplanid_conf_dialplan_dbid FOREIGN KEY (dialplanid) REFERENCES conf_dialplan(dbid);
ALTER TABLE conf_dialplan_nodelayout ADD CONSTRAINT conf_dialplan_nodelayout_page_conf_dialplan_page_dbid FOREIGN KEY (page) REFERENCES conf_dialplan_page(dbid);
ALTER TABLE conf_dialplan_nodelayout ADD CONSTRAINT cdcd_13 FOREIGN KEY (dialplan_node_id) REFERENCES conf_dialplan_node(dbid);
ALTER TABLE conf_dialplan_page ADD CONSTRAINT conf_dialplan_page_dialplan_id_conf_dialplan_dbid FOREIGN KEY (dialplan_id) REFERENCES conf_dialplan(dbid);
ALTER TABLE conf_dialplan_pbxexecnode ADD CONSTRAINT cdcd_14 FOREIGN KEY (dialplan_node_id) REFERENCES conf_dialplan_node(dbid);
ALTER TABLE conf_dialplan_playbacknode ADD CONSTRAINT cdcd_15 FOREIGN KEY (dialplan_node_id) REFERENCES conf_dialplan_node(dbid);
ALTER TABLE conf_dialplan_propertynode ADD CONSTRAINT cdcd_16 FOREIGN KEY (dialplan_node_id) REFERENCES conf_dialplan_node(dbid);
ALTER TABLE conf_dialplan_queuenode ADD CONSTRAINT conf_dialplan_queuenode_dialplan_node_id_conf_dialplan_node_dbid FOREIGN KEY (dialplan_node_id) REFERENCES conf_dialplan_node(dbid);
ALTER TABLE conf_dialplan_sendmailnode ADD CONSTRAINT cdcd_17 FOREIGN KEY (dialplan_node_id) REFERENCES conf_dialplan_node(dbid);
ALTER TABLE conf_dialplan_subdialplannode ADD CONSTRAINT cicd FOREIGN KEY (included_dialplan_id) REFERENCES conf_dialplan(dbid);
ALTER TABLE conf_dialplan_subdialplannode ADD CONSTRAINT cdcd_18 FOREIGN KEY (dialplan_node_id) REFERENCES conf_dialplan_node(dbid);
ALTER TABLE conf_dialplan_transfernode ADD CONSTRAINT cdcd_19 FOREIGN KEY (dialplan_node_id) REFERENCES conf_dialplan_node(dbid);
ALTER TABLE conf_did ADD CONSTRAINT conf_did_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE conf_group ADD CONSTRAINT conf_group_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE conf_group ADD CONSTRAINT conf_group_setting_fk_conf_agent_setting_dbid FOREIGN KEY (setting_fk) REFERENCES conf_agent_setting(dbid);
ALTER TABLE conf_group ADD CONSTRAINT conf_group_jb_group_fk_jb_group_dbid FOREIGN KEY (jb_group_fk) REFERENCES jb_group(dbid);
ALTER TABLE conf_inbound ADD CONSTRAINT cvcd_1 FOREIGN KEY (voicerecordingpolicy_fk) REFERENCES conf_voicerecording_policy(dbid);
ALTER TABLE conf_inbound ADD CONSTRAINT conf_inbound_week_schedule_fk_conf_week_schedule_dbid FOREIGN KEY (week_schedule_fk) REFERENCES conf_week_schedule(dbid);
ALTER TABLE conf_inbound ADD CONSTRAINT conf_inbound_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE conf_inbound ADD CONSTRAINT conf_inbound_service_dialplan_id_conf_dialplan_dbid FOREIGN KEY (service_dialplan_id) REFERENCES conf_dialplan(dbid);
ALTER TABLE conf_inbound ADD CONSTRAINT conf_inbound_dialplan_id_conf_dialplan_dbid FOREIGN KEY (dialplan_id) REFERENCES conf_dialplan(dbid);
ALTER TABLE conf_inbound ADD CONSTRAINT conf_inbound_closehours_dialplan_id_conf_dialplan_dbid FOREIGN KEY (closehours_dialplan_id) REFERENCES conf_dialplan(dbid);
ALTER TABLE conf_inbound_did ADD CONSTRAINT conf_inbound_did_inbound_id_conf_inbound_dbid FOREIGN KEY (inbound_id) REFERENCES conf_inbound(dbid);
ALTER TABLE conf_inbound_did ADD CONSTRAINT conf_inbound_did_did_id_conf_did_dbid FOREIGN KEY (did_id) REFERENCES conf_did(dbid);
ALTER TABLE conf_inbound_time ADD CONSTRAINT conf_inbound_time_inbound_dbid_conf_inbound_dbid FOREIGN KEY (inbound_dbid) REFERENCES conf_inbound(dbid);
ALTER TABLE conf_pbx ADD CONSTRAINT conf_pbx_jbuser_fk_jb_user_dbid FOREIGN KEY (jbuser_fk) REFERENCES jb_user(dbid);
ALTER TABLE conf_queue ADD CONSTRAINT cvcd_2 FOREIGN KEY (voicerecordingpolicy_fk) REFERENCES conf_voicerecording_policy(dbid);
ALTER TABLE conf_queue ADD CONSTRAINT conf_queue_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE conf_skill ADD CONSTRAINT conf_skill_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE conf_storageserver ADD CONSTRAINT conf_storageserver_jbuser_fk_jb_user_dbid FOREIGN KEY (jbuser_fk) REFERENCES jb_user(dbid);
ALTER TABLE conf_user ADD CONSTRAINT conf_user_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE conf_user ADD CONSTRAINT conf_user_sf_user_fk_sf_guard_user_id FOREIGN KEY (sf_user_fk) REFERENCES sf_guard_user(id);
ALTER TABLE conf_user ADD CONSTRAINT conf_user_profile_fk_conf_user_profile_dbid FOREIGN KEY (profile_fk) REFERENCES conf_user_profile(dbid);
ALTER TABLE conf_user_profile ADD CONSTRAINT conf_user_profile_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE conf_user_profile ADD CONSTRAINT conf_user_profile_sf_group_fk_sf_guard_group_id FOREIGN KEY (sf_group_fk) REFERENCES sf_guard_group(id);
ALTER TABLE jb_user_group ADD CONSTRAINT jb_user_group_username_fk_jb_user_username FOREIGN KEY (username_fk) REFERENCES jb_user(username);
ALTER TABLE jb_user_group ADD CONSTRAINT jb_user_group_groupname_fk_jb_group_name FOREIGN KEY (groupname_fk) REFERENCES jb_group(name);
ALTER TABLE log_agent_call ADD CONSTRAINT log_agent_call_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE log_agent_event ADD CONSTRAINT log_agent_event_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE log_call_record ADD CONSTRAINT log_call_record_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE log_call_voicerecording ADD CONSTRAINT log_call_voicerecording_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE log_call_voicerecording ADD CONSTRAINT log_call_voicerecording_location_pbx_fk_conf_pbx_dbid FOREIGN KEY (location_pbx_fk) REFERENCES conf_pbx(dbid);
ALTER TABLE log_call_voicerecording ADD CONSTRAINT llcd FOREIGN KEY (location_storage_fk) REFERENCES conf_storageserver(dbid);
ALTER TABLE log_campaign_activity ADD CONSTRAINT log_campaign_activity_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE log_dialing ADD CONSTRAINT log_dialing_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE log_queue_record ADD CONSTRAINT log_queue_record_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE log_resume_daily_agent_call ADD CONSTRAINT log_resume_daily_agent_call_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE log_resume_daily_agent_event ADD CONSTRAINT log_resume_daily_agent_event_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE log_resume_daily_call_record ADD CONSTRAINT log_resume_daily_call_record_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE log_resume_daily_queue_record ADD CONSTRAINT log_resume_daily_queue_record_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE log_resume_hourly_agent_call ADD CONSTRAINT log_resume_hourly_agent_call_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE log_resume_hourly_agent_event ADD CONSTRAINT log_resume_hourly_agent_event_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE log_resume_hourly_call_record ADD CONSTRAINT log_resume_hourly_call_record_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE log_resume_hourly_queue_record ADD CONSTRAINT log_resume_hourly_queue_record_tenant_fk_conf_tenant_dbid FOREIGN KEY (tenant_fk) REFERENCES conf_tenant(dbid);
ALTER TABLE sf_guard_group_permission ADD CONSTRAINT sf_guard_group_permission_permission_id_sf_guard_permission_id FOREIGN KEY (permission_id) REFERENCES sf_guard_permission(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_group_permission ADD CONSTRAINT sf_guard_group_permission_group_id_sf_guard_group_id FOREIGN KEY (group_id) REFERENCES sf_guard_group(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_remember_key ADD CONSTRAINT sf_guard_remember_key_user_id_sf_guard_user_id FOREIGN KEY (user_id) REFERENCES sf_guard_user(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_user_group ADD CONSTRAINT sf_guard_user_group_user_id_sf_guard_user_id FOREIGN KEY (user_id) REFERENCES sf_guard_user(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_user_group ADD CONSTRAINT sf_guard_user_group_group_id_sf_guard_group_id FOREIGN KEY (group_id) REFERENCES sf_guard_group(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_user_permission ADD CONSTRAINT sf_guard_user_permission_user_id_sf_guard_user_id FOREIGN KEY (user_id) REFERENCES sf_guard_user(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_user_permission ADD CONSTRAINT sf_guard_user_permission_permission_id_sf_guard_permission_id FOREIGN KEY (permission_id) REFERENCES sf_guard_permission(id) ON DELETE CASCADE;
ALTER TABLE sf_guard_forgot_password ADD CONSTRAINT sf_guard_forgot_password_user_id_sf_guard_user_id FOREIGN KEY (user_id) REFERENCES sf_guard_user(id) ON DELETE CASCADE;
