MySQL/MariaDB CDR Schema

Home » Initial Configuration of Asterisk » MySQL/MariaDB CDR Schema

If you are using MySQL or MariaDB, this table schema for CDR table could be useful:
 

CREATE TABLE `cdr` (                                                                                                                        
  `calldate` DATETIME NOT NULL DEFAULT ‘0000-00-00 00:00:00’,
  `clid` VARCHAR(80) COLLATE utf8_unicode_ci NOT NULL,
  `src` VARCHAR(80) COLLATE utf8_unicode_ci NOT NULL,
  `dst` VARCHAR(80) COLLATE utf8_unicode_ci NOT NULL,
  `dcontext` VARCHAR(80) COLLATE utf8_unicode_ci NOT NULL,
  `channel` VARCHAR(80) COLLATE utf8_unicode_ci NOT NULL,
  `dstchannel` VARCHAR(80) COLLATE utf8_unicode_ci NOT NULL,
  `lastapp` VARCHAR(80) COLLATE utf8_unicode_ci NOT NULL,
  `lastdata` VARCHAR(80) COLLATE utf8_unicode_ci NOT NULL,
  `duration` INT(11) NOT NULL DEFAULT ‘0’,
  `billsec` INT(11) NOT NULL DEFAULT ‘0’,
  `disposition` VARCHAR(45) COLLATE utf8_unicode_ci NOT NULL,
  `amaflags` INT(11) NOT NULL DEFAULT ‘0’,
  `accountcode` VARCHAR(20) COLLATE utf8_unicode_ci NOT NULL,
  `uniqueid` VARCHAR(32) COLLATE utf8_unicode_ci NOT NULL,
  `userfield` VARCHAR(255) COLLATE utf8_unicode_ci NOT NULL,
  KEY `uniqueid` (`uniqueid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
 

 
Notes: In this case, the default engine for the database is MyISAM, you can also use InnoDB or XtraDB (drop-in replacement for InnoDB in MariaDB).