2

I have been have ripping my hair out for the past week trying to get back my Foreign Key constraints on my contact table in Elastix.

The constraints I am trying to replicate are the following: Replicate these foreign keys

I have tried:

ALTER TABLE contact ADD CONSTRAINT (id_agent) REFERENCES agent(id);

but to no avail. I get the response:

 SQL query: ALTER TABLE call_entry ADD CONSTRAINT call_entry_ibfk_3 FOREIGN KEY(id_contact) REFERENCES contact.id MySQL said: #1005 - Can't create table 'call_center.#sql-888_37e3e' (errno: 150) 

All the databases agent,queue_call_entry,campaign_entry exist and have data. The structure of the contact table is here: contact table structure

Any help will be highly appreciated, thank you for your time.

  • "but to no avail" is not a very good description of the problem you're having. What do you expect to happen and what happens instead? Are there any error messages that could help others pinpoint the problem? – kristaps Sep 25 '18 at 09:11
  • Please review https://dev.mysql.com/doc/refman/5.6/en/create-table-foreign-keys.html – P.Salmon Sep 25 '18 at 09:23
  • @kristaps I would query this: ALTER TABLE call_entry ADD CONSTRAINT call_entry_ibfk_1 FOREIGN KEY (id_agent) REFERENCES `agent`.`id`; and get this in return: #1005 - Can't create table 'call_center.#sql-888_37d8c' –  Sep 25 '18 at 09:38
  • @P.Salmon already been through there mate. It is not very specific for adding foreign keys to table already in use. –  Sep 25 '18 at 09:44
  • So I tried this based off the mysql documentation ALTER TABLE call_entry ADD CONSTRAINT call_entry_ibfk_3 FOREIGN KEY(id_contact) REFERENCES contact.id; And I get: SQL query: ALTER TABLE call_entry ADD CONSTRAINT call_entry_ibfk_3 FOREIGN KEY(id_contact) REFERENCES contact.id MySQL said: #1005 - Can't create table 'call_center.#sql-888_37e3e' (errno: 150) –  Sep 25 '18 at 09:54
  • Please add table schemas (show create table and sample data. – P.Salmon Sep 25 '18 at 11:17
  • @P.Salmon Elastix creates the db's mate. I will scratch around the source to find the .php (if I am lucky) file responsible for the creation. –  Sep 25 '18 at 12:23

0 Answers0