-- Copyright (c) 1997-now, NeoNova BV, The Netherlands. All rights Reserved.
--
-- This software is the copyrighted work of NeoNova BV.
-- Use of the software is subject to the general business terms and conditions of NeoNova BV
-- and its related transaction documents like license sheets or other written notices.#
-- Any reproduction or redistribution of the software not in accordance with the license terms
-- is expressly prohibited by law, and may result in severe civil and criminally penalties.
-- Violators will be prosecuted to the maximum extent possible.

BEGIN;
CREATE TABLE cidnum_to_alert (
 id serial,

 created timestamp with time zone not null default CURRENT_TIMESTAMP,
--HELP_EN_INFO:Creation Date
--HELP_EN_LONG:The date and time this record was created.
--HELP_NL_INFO:Datum aanmaak
--HELP_NL_LONG:De tijd en datum waarop dit is aangemaakt.

 lastupdate timestamp with time zone not null default CURRENT_TIMESTAMP,
--HELP_EN_INFO:Last Update
--HELP_EN_LONG:The date and time this record was updated.
--HELP_NL_INFO:Laatste wijziging
--HELP_NL_LONG:De tijd en datum van laatste wijziging.

 company integer NOT NULL default '1',
--HELP_EN_INFO:company
--HELP_EN_LONG:The company this cidnum_to_alert belongs to.
--HELP_NL_INFO:bedrijf
--HELP_NL_LONG:Het bedrijf waar dit telefoonboek bij hoort.

 cidnum varchar(15) NOT NULL default '',
--HELP_EN_INFO:phone number
--HELP_EN_LONG:The caller id to respond to.
--HELP_NL_INFO:Telefoonnummer
--HELP_NL_LONG:Het afzendernummer waarop gereageerd moet worden.

 message varchar(24) default NULL,
--HELP_EN_INFO:message
--HELP_EN_LONG:The alert message to send
--HELP_NL_INFO:melding
--HELP_NL_LONG:De meldingstekst die gegenereerd moet worden

 description varchar(256) NOT NULL default '',
--HELP_EN_INFO:Description
--HELP_EN_LONG:The description for this rule
--HELP_NL_INFO:Omschrijving
--HELP_NL_LONG:Een omschrijving voor deze actie

 status varchar(8) NOT NULL default 'active'
   CHECK (status IN ('active', 'deleted')),
--HELP_EN_INFO:state
--HELP_EN_LONG:rule status.
--HELP_NL_INFO:status
--HELP_NL_LONG:De status van dit record.

 PRIMARY KEY  (id)
);

GRANT UPDATE, SELECT, INSERT, DELETE ON cidnum_to_alert TO astium;
GRANT UPDATE, SELECT, INSERT, DELETE ON cidnum_to_alert_id_seq TO astium;

INSERT INTO cidnum_to_alert (cidnum, company, description, message, status) VALUES ('none', 1, 'empty', 'none', 'deleted');

ALTER TABLE cidnum_to_alert ADD CONSTRAINT cidnum_to_alert_company_constraint FOREIGN KEY (company) REFERENCES company (id);

COMMIT;
