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

  subnet integer not null default '1',
  --HELP_EN_INFO:Subnet ID
  --HELP_EN_LONG:This is the id of the subnet
  --HELP_NL_INFO:
  --HELP_NL_LONG:

  ipaddress character varying(15) not null default '',
  --HELP_EN_INFO:IP Address
  --HELP_EN_LONG:IP Address of the client
  --HELP_NL_INFO:
  --HELP_NL_LONG:

  mac character varying(20) not null default '',
  --HELP_EN_INFO:MAC Address
  --HELP_EN_LONG:The Unique Hardware address of the client
  --HELP_NL_INFO:
  --HELP_NL_LONG:

  starts timestamp without time zone,
  --HELP_EN_INFO:Lease Start
  --HELP_EN_LONG:The date and time when the lease begins
  --HELP_NL_INFO:
  --HELP_NL_LONG:

  ends timestamp without time zone,
  --HELP_EN_INFO:Lease End
  --HELP_EN_LONG:The date and time when the lease ends.
  --HELP_NL_INFO:
  --HELP_NL_LONG:

  PRIMARY KEY (id)
);
GRANT UPDATE, SELECT, INSERT, DELETE ON lease TO astium;
GRANT UPDATE, SELECT, INSERT, DELETE ON lease_id_seq TO astium;

CREATE TRIGGER update_lastupdate_trigger BEFORE UPDATE ON lease FOR EACH ROW EXECUTE PROCEDURE update_lastupdate_column();

