CREATE TABLE voicemail (
 id serial,

 status varchar(8) NOT NULL default 'active',
--HELP_EN_INFO:status
--HELP_EN_LONG:record status
--HELP_NL_INFO:status
--HELP_NL_LONG:huidige status van dit record

 created timestamp with time zone not null default now(),
--HELP_EN_INFO:Created
--HELP_EN_LONG:Time and Date when this voicemail was received.
--HELP_NL_INFO:Aangemaakt
--HELP_NL_LONG:Tijd en datum wanneer deze voicemail is ontvangen.

 duration integer not null default '0',
--HELP_EN_INFO:Length
--HELP_EN_LONG:Length of this voicemail
--HELP_NL_INFO:Lengte
--HELP_NL_LONG:De lengte  van deze voicemail

 accessed timestamp,
--HELP_EN_INFO:Accessed
--HELP_EN_LONG:Time and Date when this voicemail was first accessed
--HELP_NL_INFO:Beluisterd
--HELP_NL_LONG:Tijd en datum wanneer deze voicemail is beluisterd

 contact integer NOT NULL default '1',
--GENERATE:/etc/asterisk/company%04d/queues.conf:oldcompany:
--GENERATE:/etc/asterisk/company%04d/queues.conf:company:
--SERVICE:asterisk:reload
--HELP_EN_INFO:contact
--HELP_EN_LONG:contact for this queue
--HELP_NL_INFO:persoon
--HELP_NL_LONG:persoon in deze queue

 phoneline integer DEFAULT 1 NOT NULL,
--GENERATE:/etc/asterisk/sip.conf::
--GENERATE:/etc/asterisk/inbound.conf::
--SERVICE:asterisk:reload
--HELP_EN_INFO:extension
--HELP_EN_LONG:The extension that received this voicemail
--HELP_NL_INFO:Extensie
--HELP_NL_LONG:De extensie waarop deze voicemail is ingesproken
 
 cidnum varchar(15) NOT NULL default '',
--HELP_EN_INFO:Phone number
--HELP_EN_LONG:The phone number of the person who send you this voicemail
--HELP_NL_INFO:Telefoonnummer
--HELP_NL_LONG:Het telefoonnummer van de afzender van deze voicemail

 cidname varchar(255) NOT NULL default '',
--HELP_EN_INFO:Caller Name
--HELP_EN_LONG:The name of the person who send you this voicemail
--HELP_NL_INFO:Naam beller
--HELP_NL_LONG:De naam van de afzender van deze voicemail

 PRIMARY KEY  (id)
);

GRANT UPDATE, SELECT, INSERT, DELETE ON voicemail TO astium;
GRANT UPDATE, SELECT, INSERT, DELETE ON voicemail_id_seq TO astium;

CREATE INDEX voicemail_contact_index ON voicemail (contact);
CREATE INDEX voicemail_created_index ON voicemail (created);

INSERT INTO voicemail (contact, phoneline) VALUES ('1', '1');

ALTER TABLE voicemail ADD CONSTRAINT voicemail_contact_constraint FOREIGN KEY (contact) REFERENCES contact (id);
ALTER TABLE voicemail ADD CONSTRAINT voicemail_phoneline_constraint FOREIGN KEY (phoneline) REFERENCES phoneline (id);

