--- create-original.sql 2021-02-01 10:22:09.827221435 -0600
+++ create.sql  2021-02-01 10:24:05.307220117 -0600
@@ -1119,27 +1119,34 @@
 CREATE INDEX `alerts_6` ON `alerts` (`userid`);
 CREATE INDEX `alerts_7` ON `alerts` (`p_eventid`);
 CREATE TABLE `history` (
+       `hid`                    bigint unsigned NOT NULL AUTO_INCREMENT,
        `itemid`                 bigint unsigned                           NOT NULL,
        `clock`                  integer         DEFAULT '0'               NOT NULL,
        `value`                  DOUBLE PRECISION DEFAULT '0.0000'          NOT NULL,
-       `ns`                     integer         DEFAULT '0'               NOT NULL
+       `ns`                     integer         DEFAULT '0'               NOT NULL,
+       PRIMARY KEY (hid)
 ) ENGINE=InnoDB;
 CREATE INDEX `history_1` ON `history` (`itemid`,`clock`);
 CREATE TABLE `history_uint` (
+       `hid`                    bigint unsigned NOT NULL AUTO_INCREMENT,
        `itemid`                 bigint unsigned                           NOT NULL,
        `clock`                  integer         DEFAULT '0'               NOT NULL,
        `value`                  bigint unsigned DEFAULT '0'               NOT NULL,
-       `ns`                     integer         DEFAULT '0'               NOT NULL
+       `ns`                     integer         DEFAULT '0'               NOT NULL,
+       PRIMARY KEY (hid)
 ) ENGINE=InnoDB;
 CREATE INDEX `history_uint_1` ON `history_uint` (`itemid`,`clock`);
 CREATE TABLE `history_str` (
+       `hid`                    bigint unsigned NOT NULL AUTO_INCREMENT,
        `itemid`                 bigint unsigned                           NOT NULL,
        `clock`                  integer         DEFAULT '0'               NOT NULL,
        `value`                  varchar(255)    DEFAULT ''                NOT NULL,
-       `ns`                     integer         DEFAULT '0'               NOT NULL
+       `ns`                     integer         DEFAULT '0'               NOT NULL,
+       PRIMARY KEY (hid)
 ) ENGINE=InnoDB;
 CREATE INDEX `history_str_1` ON `history_str` (`itemid`,`clock`);
 CREATE TABLE `history_log` (
+       `hid`                    bigint unsigned NOT NULL AUTO_INCREMENT,
        `itemid`                 bigint unsigned                           NOT NULL,
        `clock`                  integer         DEFAULT '0'               NOT NULL,
        `timestamp`              integer         DEFAULT '0'               NOT NULL,
@@ -1147,14 +1154,17 @@
        `severity`               integer         DEFAULT '0'               NOT NULL,
        `value`                  text                                      NOT NULL,
        `logeventid`             integer         DEFAULT '0'               NOT NULL,
-       `ns`                     integer         DEFAULT '0'               NOT NULL
+       `ns`                     integer         DEFAULT '0'               NOT NULL,
+       PRIMARY KEY (hid)
 ) ENGINE=InnoDB;
 CREATE INDEX `history_log_1` ON `history_log` (`itemid`,`clock`);
 CREATE TABLE `history_text` (
+       `hid`                    bigint unsigned NOT NULL AUTO_INCREMENT,
        `itemid`                 bigint unsigned                           NOT NULL,
        `clock`                  integer         DEFAULT '0'               NOT NULL,
        `value`                  text                                      NOT NULL,
-       `ns`                     integer         DEFAULT '0'               NOT NULL
+       `ns`                     integer         DEFAULT '0'               NOT NULL,
+       PRIMARY KEY (hid)
 ) ENGINE=InnoDB;
 CREATE INDEX `history_text_1` ON `history_text` (`itemid`,`clock`);
 CREATE TABLE `proxy_history` (
@@ -1990,10 +2000,12 @@
        PRIMARY KEY (lld_override_operationid)
 ) ENGINE=InnoDB;
 CREATE TABLE `trigger_queue` (
+       `tqid`               bigint unsigned                           NOT NULL AUTO_INCREMENT,
        `objectid`               bigint unsigned                           NOT NULL,
        `type`                   integer         DEFAULT '0'               NOT NULL,
        `clock`                  integer         DEFAULT '0'               NOT NULL,
-       `ns`                     integer         DEFAULT '0'               NOT NULL
+       `ns`                     integer         DEFAULT '0'               NOT NULL,
+       PRIMARY KEY (tqid)
 ) ENGINE=InnoDB;
 CREATE TABLE `item_parameter` (
        `item_parameterid`       bigint unsigned                           NOT NULL,
@@ -2017,7 +2029,8 @@
 CREATE INDEX `role_rule_2` ON `role_rule` (`value_moduleid`);
 CREATE TABLE `dbversion` (
        `mandatory`              integer         DEFAULT '0'               NOT NULL,
-       `optional`               integer         DEFAULT '0'               NOT NULL
+       `optional`               integer         DEFAULT '0'               NOT NULL,
+       PRIMARY KEY (mandatory)
 ) ENGINE=InnoDB;
 INSERT INTO dbversion VALUES ('5020000','5020000');
 ALTER TABLE `users` ADD CONSTRAINT `c_users_1` FOREIGN KEY (`roleid`) REFERENCES `role` (`roleid`) ON DELETE CASCADE;
