DROP TABLE IF EXISTS AUDIT_LOG_EXTMAP;
DROP TABLE IF EXISTS AUDIT_LOG_ENTRIES;
DROP SEQUENCE IF EXISTS AUDIT_LOG_SEQ;

CREATE SEQUENCE AUDIT_LOG_SEQ START 1;
CREATE TABLE AUDIT_LOG_ENTRIES (
  ENTRY_ID DECIMAL UNIQUE NOT NULL,
  LOG_LEVEL INTEGER,
  MESSAGE VARCHAR(2048),
  USERID VARCHAR(255),
  IPADDR VARCHAR(255),
  ADDED TIMESTAMP WITH TIME ZONE DEFAULT now(),
  HAPPENED TIMESTAMP WITH TIME ZONE
);

CREATE TABLE AUDIT_LOG_EXTMAP(
  E_ID DECIMAL REFERENCES AUDIT_LOG_ENTRIES (ENTRY_ID),
  E_KEY VARCHAR(255),
  E_VALUE VARCHAR(2048)
);

DROP TABLE IF EXISTS AUDIT_LOG_EXTMAP;
DROP TABLE IF EXISTS AUDIT_LOG_ENTRIES;
DROP SEQUENCE IF EXISTS AUDIT_LOG_SEQ;

CREATE SEQUENCE AUDIT_LOG_SEQ START 1;
CREATE TABLE AUDIT_LOG_ENTRIES (
  ENTRY_ID DECIMAL UNIQUE NOT NULL,
  LOG_LEVEL INTEGER,
  MESSAGE VARCHAR,
  USERID VARCHAR,
  IPADDR VARCHAR,
  ADDED TIMESTAMP WITH TIME ZONE DEFAULT now(),
  HAPPENED TIMESTAMP WITH TIME ZONE
);

CREATE TABLE AUDIT_LOG_EXTMAP(
  E_ID DECIMAL REFERENCES AUDIT_LOG_ENTRIES (ENTRY_ID),
  E_KEY VARCHAR,
  E_VALUE VARCHAR
);

Remove varchar constraing length for PostgreSQL queries.
Remove varchar constraing length for PostgreSQL queries.
