DROP DATABASE IF EXISTS billing_db;

CREATE DATABASE IF NOT EXISTS billing_db;

USE billing_db;


CREATE TABLE cdr (
  accountcode varchar(45) NOT NULL default '',
  src varchar(45) NOT NULL default '',
  dst varchar(45) NOT NULL default '',
  dcontext varchar(45) NOT NULL default '',
  clid varchar(45) NOT NULL default '',
  channel varchar(45) NOT NULL default '',
  dstchannel varchar(45) NOT NULL default '',
  lastapp varchar(45) NOT NULL default '',
  lastdata varchar(45) NOT NULL default '',
  starttime datetime NOT NULL default '0000-00-00 00:00:00',
  answertime datetime NOT NULL default '0000-00-00 00:00:00',
  endtime datetime NOT NULL default '0000-00-00 00:00:00',
  duration int(11) NOT NULL default '0',
  billsec int(11) NOT NULL default '0',
  disposition varchar(45) NOT NULL default '',
  amaflags varchar(45) NOT NULL default '',
  KEY src (src),
  KEY clid (clid),
  KEY dst (dst),
  KEY accountcode (accountcode)
) COMMENT='Asterisk CDR table';



GRANT SELECT,INSERT,UPDATE,DELETE ON billing_db.*
    TO astuser@localhost
    IDENTIFIED BY 'astpw';

FLUSH TABLE PERMISSIONS



