-- 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.

CREATE TABLE router (
  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.

  name varchar(50) default NULL,
--GENERATE:/etc/dhcpd.conf:
--SERVICE:dhcpd:reload
--HELP_EN_INFO:Name of this router
--HELP_EN_LONG:The name of this router.
--HELP_NL_INFO:Naam van dit router
--HELP_NL_LONG:De naam van dit router.

  subnet1 integer NOT NULL default '1',
--HELP_EN_INFO:subnet 1
--HELP_EN_LONG:The first subnet which is connected to this router
--HELP_NL_INFO:subnet 1
--HELP_NL_LONG:Het eerste subnet waarmee deze router is verbonden

  ipaddress1 varchar(15) NOT NULL default '',
--HELP_EN_INFO:ipaddress 1
--HELP_EN_LONG:the route rip address on subnet 1
--HELP_NL_INFO:ip addres 1
--HELP_NL_LONG:Het ip adres van de router in subnet 1

  subnet2 integer NOT NULL default '1',
--HELP_EN_INFO:subnet2
--HELP_EN_LONG:The other subnet which is connected to this router
--HELP_NL_INFO:subnet 2
--HELP_NL_LONG:Het andere subnet waarmee deze router is verbonden

  ipaddress2 varchar(15) NOT NULL default '',
--HELP_EN_INFO:ipaddress 2
--HELP_EN_LONG:the route rip address on subnet 2
--HELP_NL_INFO:ip addres 2
--HELP_NL_LONG:Het ip adres van de router in subnet 2

  status varchar(8) NOT NULL default 'active'
   CHECK (status IN ('active', 'inactive', 'deleted')),
--GENERATE:/etc/dhcpd.conf:
--SERVICE:dhcpd:reload
--HELP_EN_INFO:
--HELP_EN_LONG:
--HELP_NL_INFO:
--HELP_NL_LONG:

 notes text,
--HELP_EN_INFO:
--HELP_EN_LONG:
--HELP_NL_INFO:
--HELP_NL_LONG:

 PRIMARY KEY  (id)
);

GRANT UPDATE, SELECT, INSERT, DELETE ON router TO astium;
GRANT UPDATE, SELECT, INSERT, DELETE ON router_id_seq TO astium;
INSERT INTO router (name, status) VALUES ('empty', 'deleted');

ALTER TABLE router ADD CONSTRAINT router_subnet1_constraint FOREIGN KEY (subnet1) REFERENCES subnet (id);
ALTER TABLE router ADD CONSTRAINT router_subnet2_constraint FOREIGN KEY (subnet2) REFERENCES subnet (id);


