text: CREATE TABLE DEVICES (
    DEV_ID  INTEGER                             NOT NULL,
    UT      SMALLINT                            NOT NULL,
    LAT     DOUBLE PRECISION DEFAULT 0          NOT NULL,
    LON     DOUBLE PRECISION DEFAULT 0          NOT NULL,
    ALT     INTEGER DEFAULT 0                   NOT NULL,
    SPD     FLOAT DEFAULT 0                     NOT NULL,
    CRS     SMALLINT DEFAULT 0                  NOT NULL,
    STS     VARCHAR(20)  DEFAULT ' ',
    INFO    VARCHAR(250) DEFAULT ' ',
    DTTM    TIMESTAMPTZ DEFAULT CURRENT_TIMESTAMP NOT NULL,
    PS_HASH VARCHAR(32),
    CONSTRAINT DEVICES_PK PRIMARY KEY (DEV_ID, UT)
  );
  
  CREATE TABLE MSGQUEUE (
    ID           BIGINT NOT NULL,
    DEV_ID       INTEGER   NOT NULL,
    UT           SMALLINT  NOT NULL,
    INFO         VARCHAR(250),
    DTTM         TIMESTAMPTZ NOT NULL,
    NEXT_SEND_DT TIMESTAMP NOT NULL,
    TRY_N        INTEGER   NOT NULL,
    EXPIRY_DT    TIMESTAMP NOT NULL,
    CONSTRAINT MSGQUEUE_PK PRIMARY KEY(ID)
  );
  
  CREATE TABLE NOTIFYQUEUE (
    ID           BIGINT NOT NULL,
    DEV_ID       INTEGER       NOT NULL,
    UT           SMALLINT      NOT NULL,
    INFO         VARCHAR(4000) NOT NULL,
    ADDRESS      VARCHAR(200)  NOT NULL,
    NOTIFY_TYPE  INTEGER       NOT NULL,
    USER_ID      INTEGER       NOT NULL,
    DTTM         TIMESTAMPTZ     NOT NULL,
    NEXT_SEND_DT TIMESTAMP     NOT NULL,
    TRY_N        INTEGER       NOT NULL,
    EXPIRY_DT    TIMESTAMP     NOT NULL,
    CONSTRAINT NOTIFYQUEUE_PK PRIMARY KEY(ID)
  );
  
  CREATE TABLE SENDQUEUE (
    ID           BIGINT NOT NULL,
    DEV_ID       INTEGER   NOT NULL,
    UT           SMALLINT  NOT NULL,
    LAT          FLOAT     NOT NULL,
    LON          FLOAT     NOT NULL,
    ALT          INTEGER   NOT NULL,
    SPD          FLOAT     NOT NULL,
    CRS          SMALLINT  NOT NULL,
    DTTM         TIMESTAMPTZ NOT NULL,
    NEXT_SEND_DT TIMESTAMP NOT NULL,
    TRY_N        INTEGER   NOT NULL,
    EXPIRY_DT    TIMESTAMP NOT NULL,
    CONSTRAINT SENDQUEUE_PK PRIMARY KEY(ID)
  );
  
  CREATE TABLE SMSQUEUE (
    ID           BIGINT NOT NULL,
    INFO         VARCHAR(150) NOT NULL,
    ADDRESS      VARCHAR(200) NOT NULL,
    N_ID         BIGINT       NOT NULL,
    NEXT_SEND_DT TIMESTAMP    NOT NULL,
    TRY_N        INTEGER      NOT NULL,
    EXPIRY_DT    TIMESTAMP    NOT NULL,
    CONSTRAINT SMSQUEUE_PK PRIMARY KEY(ID)
  );
  
  CREATE INDEX MSGQUEUE_IDX1
    ON MSGQUEUE (NEXT_SEND_DT);
  CREATE INDEX NOTIFYQUEUE_IDX1
    ON NOTIFYQUEUE (NEXT_SEND_DT);
  CREATE INDEX SENDQUEUE_IDX1
    ON SENDQUEUE (NEXT_SEND_DT);
  CREATE INDEX SMSQUEUE_IDX1
    ON SMSQUEUE (NEXT_SEND_DT);
  