Insert failed on 'asteriskcdrdb:cel'. CEL failed: INSERT INTO cel


I have setup FreePBX 14 on SNG7 official Distro, and I am getting the following error when I watch a call in the asterisk CLI.

[2017-03-17 14:09:10] WARNING[16629]: res_odbc.c:460 ast_odbc_print_errors: SQL Execute returned an error: 23000 [MySQL][ODBC 5.2(w) Driver][mysqld-5.5.52-MariaDB]Duplicate entry '0' for key 'PRIMARY'
[2017-03-17 14:09:10] WARNING[16629]: res_odbc.c:404 ast_odbc_prepare_and_execute: SQL Execute error -1!
[2017-03-17 14:09:10] WARNING[16629]: cel_odbc.c:773 odbc_log: Insert failed on 'asteriskcdrdb:cel'.  CEL failed: INSERT INTO cel

Any idea what is going on here>? I’m not sure how to debug this…

Well, based on reading, I have a primary key which = 0, and I can’t enable auto_increment untill I delete that row,

so I did the following:

drop table from cel where id = 0;

alter table cel modify id int auto_increment;

Just not sure how this happened, is this a bug, should I create a Jira ticket?

I’m not sure how that could have possibly worked.

delete from cel where id = 0;
drop table cel;

are two different commands. The first might work, but you still run the risk of the primary key constraint still be unsatisfied if other data elements have duplicate keys. You should, without deleting anything, be able to rung the “alter table” command and get where you are trying to go. After that, deleting the item with the ‘0’ primary key should solve the problem.

I was unable to run the alter command w/o deleting the Primary key = 0. It gave the same error, regarding duplicate Primary key.

This error seemed to be on all my tables, here is what I ran

MariaDB [survey]> delete from bsurvey_cdrs where id = "0";

Query OK, 1 row affected (0.00 sec)

MariaDB [survey]> alter table bsurvey_cdrs modify id int auto_increment;