Index: db/default.sql
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+>PRAGMA foreign_keys = OFF;\nBEGIN TRANSACTION;\nCREATE TABLE routing (\n  `ID`                      INTEGER PRIMARY KEY AUTOINCREMENT,\n  `publishing_instance_id`  TEXT,\n  `publishing_element_id`   TEXT,\n  `destination_instance_id` TEXT,\n  `destination_element_id`  TEXT,\n  `is_network_connection`   TINYINT(1)\n);\nCREATE TABLE config (\n  `ID`    INTEGER PRIMARY KEY AUTOINCREMENT,\n  `key`   TEXT,\n  `value` TEXT\n);\nCREATE TABLE satellite (\n  `ID`         INTEGER PRIMARY KEY AUTOINCREMENT,\n  `name`       TEXT,\n  `domain`     TEXT,\n  `public_ip`  TEXT,\n  `created_at` DATETIME NOT NULL,\n  `updated_at` DATETIME NOT NULL\n);\nINSERT INTO satellite VALUES (2, 'ComSat4', 'comsat4.iotracks.com', '104.130.135.213', '2016-09-21 15:21:31.898 +00:00',\n                              '2016-09-21 15:21:31.898 +00:00');\nCREATE TABLE data_tracks (\n  `ID`           INTEGER PRIMARY KEY AUTOINCREMENT,\n  `name`         TEXT,\n  `instance_id`  TEXT,\n  `updated_by`   BIGINT,\n  `description`  TEXT,\n  `is_selected`  INTEGER,\n  `is_activated` INTEGER,\n  `created_at`   DATETIME NOT NULL,\n  `updated_at`   DATETIME NOT NULL,\n  `user_id`      INTEGER REFERENCES `users` (`ID`)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE element_instance_port (\n  `ID`            INTEGER PRIMARY KEY AUTOINCREMENT,\n  `port_internal` BIGINT,\n  `port_external` BIGINT,\n  `updated_by`    BIGINT,\n  `created_at`    DATETIME NOT NULL,\n  `updated_at`    DATETIME NOT NULL,\n  `elementId`     TEXT\n);\nCREATE TABLE iofog_console (\n  ID           INTEGER PRIMARY KEY AUTOINCREMENT,\n  org_id       BIGINT,\n  version      BIGINT,\n  api_base_url TEXT,\n  element_id   TEXT,\n  access_token TEXT,\n  iofog_uuid   TEXT REFERENCES iofogs (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE stream_viewer (\n  ID           INTEGER PRIMARY KEY AUTOINCREMENT,\n  orgId        BIGINT,\n  version      BIGINT,\n  api_base_url TEXT,\n  element_id   TEXT,\n  access_token TEXT,\n  iofog_uuid   TEXT REFERENCES iofogs (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE instance_track (\n  ID                  INTEGER PRIMARY KEY AUTOINCREMENT,\n  name                TEXT,\n  description         TEXT,\n  last_updated        DATETIME,\n  is_selected         TINYINT(1),\n  is_activated        TINYINT(1),\n  updated_by          BIGINT,\n  created_at          DATETIME NOT NULL,\n  updated_at          DATETIME NOT NULL,\n  element_instance_id INTEGER REFERENCES element_instance (ID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE element_advertised_port (\n  ID          INTEGER PRIMARY KEY AUTOINCREMENT,\n  port_number BIGINT,\n  name        TEXT,\n  description TEXT,\n  element_id  INTEGER REFERENCES element (ID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE iofog_users (\n  ID      INTEGER PRIMARY KEY AUTOINCREMENT,\n  user_id INTEGER REFERENCES users (ID)\n    ON DELETE CASCADE\n    ON UPDATE CASCADE,\n  fog_id  TEXT REFERENCES iofogs (UUID)\n    ON DELETE CASCADE\n    ON UPDATE CASCADE,\n  UNIQUE (user_id, fog_id)\n);\nINSERT INTO iofog_users VALUES (193, 43, 'fVmnRpHgdNnDw7XJLJw7GV4NVRhjk4V3');\nCREATE TABLE element_fog_types (\n  ID            INTEGER PRIMARY KEY AUTOINCREMENT,\n  element_id    INTEGER REFERENCES element (ID)\n    ON DELETE CASCADE\n    ON UPDATE CASCADE,\n  iofog_type_id INTEGER REFERENCES iofog_type (ID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nINSERT INTO element_fog_types VALUES (1, 1, 1);\nINSERT INTO element_fog_types VALUES (2, 2, 1);\nINSERT INTO element_fog_types VALUES (3, 3, 1);\nINSERT INTO element_fog_types VALUES (4, 4, 1);\nINSERT INTO element_fog_types VALUES (5, 5, 1);\nINSERT INTO element_fog_types VALUES (6, 6, 1);\nINSERT INTO element_fog_types VALUES (7, 7, 1);\nINSERT INTO element_fog_types VALUES (8, 8, 1);\nINSERT INTO element_fog_types VALUES (9, 9, 1);\nINSERT INTO element_fog_types VALUES (10, 10, 1);\nINSERT INTO element_fog_types VALUES (11, 11, 1);\nINSERT INTO element_fog_types VALUES (12, 49, 1);\nINSERT INTO element_fog_types VALUES (13, 58, 1);\nCREATE TABLE network_pairing (\n  ID                INTEGER PRIMARY KEY AUTOINCREMENT,\n  IsPublicPort      TINYINT(1),\n  instanceId1       TEXT REFERENCES iofogs (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE,\n  instanceId2       TEXT REFERENCES iofogs (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE,\n  elementId1        TEXT REFERENCES element_instance (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE,\n  elementId2        TEXT REFERENCES element_instance (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE,\n  networkElementId1 TEXT REFERENCES element_instance (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE,\n  networkElementId2 TEXT REFERENCES element_instance (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE,\n  elemen1PortId     INTEGER REFERENCES element_instance_port (ID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE,\n  satellitePortId   INTEGER REFERENCES satellite_port (ID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE element_instance_connections (\n  ID                           INTEGER PRIMARY KEY AUTOINCREMENT,\n  source_element_instance      TEXT,\n  destination_element_instance TEXT\n);\nCREATE TABLE element (\n  ID              INTEGER PRIMARY KEY AUTOINCREMENT,\n  name            TEXT,\n  description     TEXT,\n  category        TEXT,\n  container_image TEXT,\n  publisher       TEXT,\n  diskRequired    BIGINT,\n  ram_required    BIGINT,\n  picture         BIGINT,\n  config          TEXT,\n  is_public       TINYINT(1),\n  org_id          BIGINT,\n  registry_id     INTEGER REFERENCES registry (ID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nINSERT INTO element VALUES\n  (1, 'Stream Viewer', 'The built-in stream viewer for ioIntegrator Linux edition', 'Utilities',\n      'iotracks/catalog:stream-viewer-1.0', 'SYSTEM', 0, 0, 'none.png', NULL, 1, 0, 1);\nINSERT INTO element VALUES\n  (2, 'Debug Console', 'The built-in debug console for ioIntegrator Linux edition', 'Utilities',\n      'iotracks/catalog:debug', 'SYSTEM', 0, 0, 'none.png', NULL, 1, 0, 1);\nINSERT INTO element VALUES\n  (3, 'Networking Tool', 'The built-in networking tool for ioIntegrator Linux edition', 'Utilities',\n      'iotracks/catalog:core-networking-1-12', 'SYSTEM', 0, 0, 'none.png', NULL, 1, 0, 1);\nINSERT INTO element VALUES\n  (4, 'Hello Web Demo', 'A simple web server for you to test your ioFog', 'Demos', 'iotracks/catalog:hello-web-1',\n      'iotracks', 0, 0, 'images/build/4.png', NULL, 1, 0, 1);\nINSERT INTO element VALUES\n  (5, 'RESTBlue', 'Bluetooth RESTful API', 'Utilities', 'iotracks/catalog:bluetooth-rest-api-v0.5', 'SYSTEM', 0, 0,\n      'none.png', NULL, 1, 0, 1);\nINSERT INTO element VALUES\n  (6, 'HAL', 'HAL container', 'Utilities', 'iotracks/catalog:hal-0.1', 'SYSTEM', 0, 0, 'none.png', NULL, 1, 0, 1);\nINSERT INTO element VALUES\n  (7, 'HAL ARM', 'ARM HAL container', 'Utilities', 'iotracks/catalog:hal-0.1-arm', 'SYSTEM', 0, 0, 'none.png', NULL,\n      1, 0, 1);\nINSERT INTO element VALUES\n  (8, 'Open Weather Map Data', 'A stream of data from the Open Weather Map API in JSON format', 'Sensors',\n      'iotracks/catalog:open-weather-map-v1.06', 'iotracks', 0, 0, 'images/build/8.png', NULL, 1, 0, 1);\nINSERT INTO element VALUES (49, 'JSON REST API', 'A configurable REST API that gives JSON output', 'Utilities',\n                                'iotracks/catalog:json-rest-api-v1.04', 'iotracks', 0, 0, 'images/build/49.png', NULL,\n                                1, 0, 1);\nINSERT INTO element VALUES (58, 'Temperature Converter', 'A simple temperature format converter', 'Utilities',\n                                'iotracks/catalog:temperature-conversion-v1.03', 'iotracks', 0, 0,\n                                'images/build/58.png', NULL, 1, 0, 1);\n\nINSERT INTO element VALUES (9, 'Mongo', 'MongoDB database', 'Utilities',\n                                '80444561333/alpine-mongo', 'SYSTEM', 0, 0,\n                                'none.png', NULL, 1, 0, 1);\n\nINSERT INTO element VALUES (10, 'Influx', 'InfluxDB database', 'Utilities',\n                                '80444561333/alpine-influx', 'SYSTEM', 0, 0,\n                                'none.png', NULL, 1, 0, 1);\n\nINSERT INTO element VALUES (11, 'Grafana', 'Grafana container', 'Utilities',\n                                '80444561333/grafana', 'SYSTEM', 0, 0,\n                                'none.png', NULL, 1, 0, 1);\n\nCREATE TABLE element_input_type (\n  ID          INTEGER PRIMARY KEY AUTOINCREMENT,\n  element_key BIGINT REFERENCES element (ID)\n    ON DELETE CASCADE\n    ON UPDATE CASCADE,\n  info_type   TEXT,\n  info_format TEXT\n);\nCREATE TABLE element_output_type (\n  ID          INTEGER PRIMARY KEY AUTOINCREMENT,\n  element_key BIGINT REFERENCES element (ID)\n    ON DELETE CASCADE\n    ON UPDATE CASCADE,\n  info_type   TEXT,\n  info_format TEXT\n);\nCREATE TABLE satellite_port (\n  ID                                INTEGER PRIMARY KEY AUTOINCREMENT,\n  port1                             BIGINT,\n  port2                             BIGINT,\n  max_connections_port1             BIGINT,\n  max_connection_port2              BIGINT,\n  passcode_port1                    TEXT,\n  passcode_port2                    TEXT,\n  heartbeat_absence_threshold_port1 BIGINT,\n  heartbeat_absence_threshold_port2 BIGINT,\n  updated_by                        BIGINT,\n  created_at                        DATETIME NOT NULL,\n  updated_at                        DATETIME NOT NULL,\n  satellite_id                      INTEGER REFERENCES satellite (ID)\n    ON DELETE CASCADE\n    ON UPDATE CASCADE,\n  mapping_id                        TEXT\n);\nCREATE TABLE iofog_provision_keys (\n  ID                  INTEGER PRIMARY KEY AUTOINCREMENT,\n  provisioning_string VARCHAR(100),\n  expiration_time     BIGINT,\n  iofog_uuid          TEXT REFERENCES iofogs (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nINSERT INTO iofog_provision_keys VALUES (79, 'jX3QfQvQ', 1517402261932, 'fVmnRpHgdNnDw7XJLJw7GV4NVRhjk4V3');\nCREATE TABLE iofogs (\n  UUID                    TEXT PRIMARY KEY,\n  Name                    TEXT    DEFAULT ('Unnamed ioFog 1'),\n  Location                TEXT,\n  Latitude                TEXT,\n  Longitude               TEXT,\n  OrgID                   BIGINT,\n  Description             TEXT,\n  created_at              DATETIME,\n  updated_at              DATETIME,\n  LastActive              BIGINT,\n  Token                   TEXT,\n  DaemonStatus            TEXT    DEFAULT 'UNKNOWN',\n  DaemonOperatingDuration BIGINT  DEFAULT 0,\n  DaemonLastStart         BIGINT,\n  MemoryUsage             FLOAT   DEFAULT 0,\n  DiskUsage               FLOAT   DEFAULT 0,\n  CPUUsage                FLOAT   DEFAULT 0,\n  MemoryViolation         TEXT,\n  DiskViolation           TEXT,\n  CPUViolation            TEXT,\n  ElementStatus           TEXT,\n  RepositoryCount         BIGINT,\n  RepositoryStatus        TEXT,\n  SystemTime              BIGINT,\n  LastStatusTime          BIGINT,\n  IPAddress               TEXT    DEFAULT '0.0.0.0',\n  ProcessedMessages       BIGINT  DEFAULT 0,\n  ElementMessageCounts    TEXT,\n  MessageSpeed            BIGINT,\n  LastCommandTime         BIGINT,\n  NetworkInterface        TEXT    DEFAULT 'eth0',\n  DockerURL               TEXT    DEFAULT 'unix:///var/run/docker.sock',\n  DiskLimit               FLOAT   DEFAULT 50,\n  DiskDirectory           TEXT    DEFAULT ('/var/lib/iofog/'),\n  MemoryLimit             FLOAT   DEFAULT 4096,\n  CPULimit                FLOAT   DEFAULT 80,\n  LogLimit                FLOAT   DEFAULT 10,\n  LogDirectory            TEXT    DEFAULT ('/var/log/iofog/'),\n  Debug                   INTEGER,\n  Viewer                  INTEGER,\n  Bluetooth               INTEGER,\n  hal                     INTEGER DEFAULT (0),\n  mongo                   INTEGER DEFAULT (0),\n  influx                  INTEGER DEFAULT (0),\n  grafana                 INTEGER DEFAULT (0),\n  IsolatedDockerContainer INTEGER DEFAULT (1),\n  LogFileCount            BIGINT  DEFAULT 10,\n  Version                 TEXT,\n  isReadyToUpgrade        INTEGER DEFAULT(1),\n  isReadyToRollback       INTEGER DEFAULT(0),\n  StatusFrequency         INTEGER DEFAULT (10),\n  ChangeFrequency         INTEGER DEFAULT (20),\n  ScanFrequency           INTEGER DEFAULT (60),\n  Proxy                   TEXT    DEFAULT (''),\n  typeKey                 INTEGER REFERENCES iofog_type (ID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE iofog_type (\n  ID                     INTEGER PRIMARY KEY AUTOINCREMENT,\n  Name                   TEXT,\n  Image                  TEXT,\n  Description            TEXT,\n  StreamViewerElementKey BIGINT,\n  consoleElementKey      BIGINT,\n  NetworkElementKey      BIGINT,\n  HalElementKey          BIGINT,\n  MongoElementKey        BIGINT,\n  InfluxElementKey       BIGINT,\n  GrafanaElementKey      BIGINT,\n  BluetoothElementKey    BIGINT\n);\nINSERT INTO iofog_type VALUES (1, 'Standard Linux (x86)', 'iointegrator1.png',\n                               'A standard Linux server of at least moderate processing power and capacity. Compatible with common Linux types such as Ubuntu, Red Hat, and CentOS.',\n                               1, 2, 3, 6, 9, 10, 11, 5);\nINSERT INTO iofog_type VALUES (2, 'ARM Linux', 'iointegrator2.png',\n                               'A version of ioFog meant to run on Linux systems with ARM processors. Microservices for this ioFog type will be tailored to ARM systems.',\n                               1, 2, 3, 7, 9, 10, 11, 5);\nCREATE TABLE element_instance (\n  ID                  INTEGER PRIMARY KEY AUTOINCREMENT,\n  UUID                TEXT UNIQUE,\n  track_id            BIGINT,\n  element_key         BIGINT,\n  config              BIGINT,\n  name                TEXT,\n  updated_by          BIGINT,\n  config_last_updated BIGINT,\n  is_stream_viewer    TINYINT(1),\n  is_debug_console    TINYINT(1),\n  is_manager          TINYINT(1),\n  is_network          TINYINT(1),\n  registry_id         BIGINT,\n  rebuild             TINYINT(1),\n  root_host_access    TINYINT(1),\n  log_size            TINYINT(1),\n  created_at          DATETIME NOT NULL,\n  updated_at          DATETIME NOT NULL,\n  volume_mappings     TEXT,\n  element_id          INTEGER REFERENCES element (ID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE,\n  iofog_uuid          TEXT REFERENCES iofogs (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE iofog_access_tokens (\n  ID              INTEGER PRIMARY KEY AUTOINCREMENT,\n  user_id         INTEGER,\n  expiration_time BIGINT,\n  token           TEXT,\n  iofog_uuid      TEXT REFERENCES iofogs (UUID)\n    ON DELETE CASCADE\n    ON UPDATE CASCADE\n);\nCREATE TABLE users (\n  ID                INTEGER PRIMARY KEY AUTOINCREMENT,\n  first_name        VARCHAR(100),\n  last_name         VARCHAR(100),\n  email             VARCHAR(100),\n  password          VARCHAR(100),\n  temp_password     TEXT,\n  email_activated   INTEGER,\n  user_access_token TEXT\n);\nINSERT INTO users VALUES (43, 'Admin', 'Admin', 'admin@admin.admin', 'admin', NULL, 1000,\n                          '6eb5117a227868387324017f64dc7e2b2ab299b10b5fc5927ba516fd4a6794b6');\nINSERT INTO users VALUES (44, 'Ivan', 'Panasuk', 'ivan@ivan.ivan', 'admin', NULL, 1000,\n                          '6eb5117a227868387324017f64dc7e2b2ab299b10b5fc5927ba516fd4a6794b7');\nINSERT INTO users VALUES (45, 'Artur', 'Artur', 'artur@artur.artur', 'admin', NULL, 1000,\n                          '6eb5117a227868387324017f64dc7e2b2ab299b10b5fc5927ba516fd4a6794b8');\nINSERT INTO users VALUES (46, 'Eugene', 'Eugene', 'eugene@eugene.eugene', 'admin', NULL, 1000,\n                          '6eb5117a227868387324017f64dc7e2b2ab299b10b5fc5927ba516fd4a6794b9');\nINSERT INTO users VALUES (47, 'Irina', 'Irina', 'irina@irina.irina', 'admin', NULL, 1000,\n                          '6eb5117a227868387324017f64dc7e2b2ab299b10b5fc5927ba516fd4a6794b1');\nINSERT INTO users VALUES (48, 'Katya', 'Katya', 'katya@katya.katya', 'admin', NULL, 1000,\n                          '6eb5117a227868387324017f64dc7e2b2ab299b10b5fc5927ba516fd4a6794b2');\nINSERT INTO users VALUES (49, 'Sasha', 'Sasha', 'sasha@sasha.sasha', 'admin', NULL, 1000,\n                          '6eb5117a227868387324017f64dc7e2b2ab299b10b5fc5927ba516fd4a6794b3');\nINSERT INTO users VALUES (50, 'Dima', 'Dima', 'dima@dima.dima', 'admin', NULL, 1000,\n                          '6eb5117a227868387324017f64dc7e2b2ab299b10b5fc5927ba516fd4a6794b4');\nINSERT INTO users VALUES (51, 'Egor', 'Egor', 'egor@povelitel.gor', 'admin', NULL, 1000,\n                          '6eb5117a227868387324017f64dc7e2b2ab299b10b5fc5927ba516fd4a6794b5');\n\nCREATE TABLE email_activation_code (\n  ID              INTEGER PRIMARY KEY AUTOINCREMENT,\n  user_id         INTEGER REFERENCES users (ID)\n    ON DELETE CASCADE\n    ON UPDATE CASCADE,\n  activation_code TEXT,\n  expiration_time BIGINT\n);\nINSERT INTO email_activation_code VALUES (35, 43, 'XPMDjGP6fbQdB4py', 1517495034248);\nCREATE TABLE registry (\n  ID            INTEGER PRIMARY KEY AUTOINCREMENT,\n  url           TEXT,\n  is_public     INTEGER,\n  secure        INTEGER,\n  certificate   TEXT,\n  requires_cert INTEGER,\n  user_name     TEXT,\n  password      TEXT,\n  user_email    BIGINT,\n  iofog_uuid    TEXT REFERENCES iofogs (UUID),\n  user_id       INTEGER REFERENCES users (ID)\n);\nINSERT INTO registry\nVALUES (1, 'registry.hub.docker.com', 1, 1, '', 0, 'iointegrator', '0nTh3Edge2015', 'admin@iotracks.com', NULL, NULL);\nCREATE TABLE iofog_change_tracking (\n\t`ID`\tINTEGER PRIMARY KEY AUTOINCREMENT,\n\t`container_config`\tBIGINT,\n\t`reboot`\tBOOLEAN,\n\t`version` BIGINT,\n\t`container_list`\tBIGINT,\n\t`config`\tBIGINT,\n\t`routing`\tBIGINT,\n\t`registries`\tBIGINT,\n\t`proxy` BIGINT,\n\t`iofog_uuid`\tTEXT,\n\tFOREIGN KEY(`iofog_uuid`) REFERENCES iofogs ( UUID ) ON DELETE SET NULL ON UPDATE CASCADE\n);\nCREATE TABLE proxy (\n  `ID`          INTEGER PRIMARY KEY AUTOINCREMENT,\n  `username`    TEXT,\n  `password`    TEXT,\n  `host`        TEXT,\n  `remote_port` INTEGER,\n  `local_port`  INTEGER             DEFAULT 22,\n  `rsa_key`     TEXT,\n  `close`       BOOLEAN             DEFAULT FALSE,\n  `iofog_uuid`  TEXT,\n  FOREIGN KEY (`iofog_uuid`) REFERENCES iofogs (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE hw_info (\n  `ID`         INTEGER PRIMARY KEY AUTOINCREMENT,\n  `info`       TEXT,\n  `iofog_uuid` TEXT,\n  `created_at` DATETIME NOT NULL,\n  `updated_at` DATETIME NOT NULL,\n  FOREIGN KEY (`iofog_uuid`) REFERENCES iofogs (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE usb_info (\n  `ID`         INTEGER PRIMARY KEY AUTOINCREMENT,\n  `info`       TEXT,\n  `iofog_uuid` TEXT,\n  `created_at` DATETIME NOT NULL,\n  `updated_at` DATETIME NOT NULL,\n  FOREIGN KEY (`iofog_uuid`) REFERENCES iofogs (UUID)\n    ON DELETE SET NULL\n    ON UPDATE CASCADE\n);\nCREATE TABLE iofog_version_commands (\n  ID INTEGER PRIMARY KEY AUTOINCREMENT,\n  version_command VARCHAR (100),\n  `iofog_uuid`\tTEXT,\n  FOREIGN KEY(`iofog_uuid`) REFERENCES iofogs (UUID) ON DELETE SET NULL ON UPDATE CASCADE\n);\n\nINSERT INTO iofog_change_tracking VALUES(1, 1517401049283, 0, 1517401049283,1517472938429,1517472938429,1517401049283,1517401049283, 1517401049283, 'fVmnRpHgdNnDw7XJLJw7GV4NVRhjk4V3');\nDELETE FROM sqlite_sequence;\nINSERT INTO sqlite_sequence VALUES ('config', 52);\nINSERT INTO sqlite_sequence VALUES ('satellite', 9);\nINSERT INTO sqlite_sequence VALUES ('data_tracks', 90);\nINSERT INTO sqlite_sequence VALUES ('routing', 196);\nINSERT INTO sqlite_sequence VALUES ('element_instance_port', 650);\nINSERT INTO sqlite_sequence VALUES ('iofog_console', 256);\nINSERT INTO sqlite_sequence VALUES ('stream_viewer', 257);\nINSERT INTO sqlite_sequence VALUES ('instance_track', 0);\nINSERT INTO sqlite_sequence VALUES ('element_advertised_port', 0);\nINSERT INTO sqlite_sequence VALUES ('iofog_users', 193);\nINSERT INTO sqlite_sequence VALUES ('element_fog_types', 181);\nINSERT INTO sqlite_sequence VALUES ('network_pairing', 644);\nINSERT INTO sqlite_sequence VALUES ('element_instance_connections', 68);\nINSERT INTO sqlite_sequence VALUES ('element', 226);\nINSERT INTO sqlite_sequence VALUES ('element_input_type', 100);\nINSERT INTO sqlite_sequence VALUES ('element_output_type', 92);\nINSERT INTO sqlite_sequence VALUES ('satellite_port', 639);\nINSERT INTO sqlite_sequence VALUES ('iofog_provision_keys', 79);\nINSERT INTO sqlite_sequence VALUES ('iofog_type', 2);\nINSERT INTO sqlite_sequence VALUES ('element_instance', 1048);\nINSERT INTO sqlite_sequence VALUES ('iofog_access_tokens', 21);\nINSERT INTO sqlite_sequence VALUES ('users', 43);\nINSERT INTO sqlite_sequence VALUES ('users', 44);\nINSERT INTO sqlite_sequence VALUES ('users', 45);\nINSERT INTO sqlite_sequence VALUES ('users', 46);\nINSERT INTO sqlite_sequence VALUES ('users', 47);\nINSERT INTO sqlite_sequence VALUES ('users', 48);\nINSERT INTO sqlite_sequence VALUES ('users', 49);\nINSERT INTO sqlite_sequence VALUES ('users', 50);\nINSERT INTO sqlite_sequence VALUES ('users', 51);\nINSERT INTO sqlite_sequence VALUES ('email_activation_code', 35);\nINSERT INTO sqlite_sequence VALUES ('registry', 1);\nINSERT INTO sqlite_sequence VALUES ('iofog_change_tracking', 1);\n\nINSERT INTO config (key, value) VALUES ('port', '4443');\nINSERT INTO config (key, value) VALUES ('ssl_key', 'privkey.pem');\nINSERT INTO config (key, value) VALUES ('intermediate_cert', 'my-private-root-ca.cert.pem');\nINSERT INTO config (key, value) VALUES ('ssl_cert', 'fullchain.pem');\n\nCOMMIT;\n
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- db/default.sql	(revision 45bf0c7d527fc55c00c7b2c460c22444d0131ee2)
+++ db/default.sql	(date 1521823982000)
@@ -365,6 +365,18 @@
     ON DELETE SET NULL
     ON UPDATE CASCADE
 );
+CREATE TABLE element_instance_status (
+  ID                    INTEGER PRIMARY KEY AUTOINCREMENT,
+  status                TEXT,
+  cpu_usage             FLOAT,
+  memory_usage          BIGINT,
+  date                  DATETIME,
+  created_at            DATETIME NOT NULL,
+  updated_at            DATETIME NOT NULL,
+  element_instance_uuid INTEGER REFERENCES element_instance (UUID)
+    ON DELETE SET NULL
+    ON UPDATE CASCADE
+);
 CREATE TABLE iofog_access_tokens (
   ID              INTEGER PRIMARY KEY AUTOINCREMENT,
   user_id         INTEGER,
Index: src/server/controllers/api/instanceStatusController.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+>/**\n * @file instanceStatusController.js\n * @author Zishan Iqbal\n * @description This file includes the implementation of the instance-status end-point\n */\nimport async from 'async';\n\nimport BaseApiController from './baseApiController';\nimport FogService from '../../services/fogService';\nimport AppUtils from '../../utils/appUtils';\nimport logger from '../../utils/winstonLogs';\n\n\n/********************************************* EndPoints ******************************************************/\n\n/*************** Instance Status EndPoint (Post: /api/v2/instance/status/id/:ID/token/:Token) *****************/\n  const instanceStatusEndPoint = function(req, res){\n\n  logger.info(\"Endpoint hit: \"+ req.originalUrl);\n\n  let params = {},\n      fogInstanceProps= {\n        fogId: 'bodyParams.instanceId',\n        setProperty: 'fogInstance'\n      };\n \n  params.bodyParams = req.body;\n  params.bodyParams.instanceId = req.params.ID;\n  logger.info(\"Parameters:\" + JSON.stringify(params.bodyParams));\n\n  async.waterfall([\n    async.apply(BaseApiController.checkUserExistance, req, res),\n    async.apply(FogService.getFogInstance, fogInstanceProps, params),\n    updateFogInstance\n  ], function(err, result) {\n    AppUtils.sendResponse(res, err,'','', result);\n  })\n};\n\n/*********************************** Extra Functions ***************************************************/\nconst updateFogInstance = function(params, callback){\n\n  let proxyStatus = getProxyStatus(params);\n\n  let fogInstanceProps = {\n        instanceId: 'bodyParams.instanceId',\n        updatedFog: {\n          daemonstatus: params.bodyParams.daemonstatus,\n          daemonoperatingduration : params.bodyParams.daemonoperatingduration,\n          daemonlaststart : params.bodyParams.daemonlaststart,\n          memoryusage : params.bodyParams.memoryusage,\n          diskusage : params.bodyParams.diskusage,\n          cpuusage : params.bodyParams.cpuusage,\n          memoryviolation : params.bodyParams.memoryviolation,\n          diskviolation : params.bodyParams.diskviolation, \n          cpuviolation : params.bodyParams.cpuviolation,\n          elementstatus : params.bodyParams.elementstatus, \n          repositorycount : params.bodyParams.repositorycount,\n          repositorystatus : params.bodyParams.repositorystatus,\n          systemtime : params.bodyParams.systemtime,\n          laststatustime : params.bodyParams.laststatustime,\n          ipaddress : params.bodyParams.ipaddress,\n          processedmessages : params.bodyParams.processedmessages,\n          elementmessagecounts : params.bodyParams.elementmessagecounts, \n          messagespeed : params.bodyParams.messagespeed,\n          lastcommandtime : params.bodyParams.lastcommandtime,\n          proxy : proxyStatus,\n          version: params.bodyParams.version || '1.0',\n          isReadyToUpgrade: params.bodyParams.isreadytoupgrade,\n          isReadyToRollback: params.bodyParams.isreadytorollback\n        }\n      };\n    FogService.updateFogInstance(fogInstanceProps, params, callback);\n};\n\nconst getProxyStatus = function(params) {\n    let result;\n    let newProxyStr = params.bodyParams.proxystatus;\n    let oldProxyStr = params.fogInstance.proxy;\n\n    if (oldProxyStr) {\n        let oldProxyObj = JSON.parse(oldProxyStr);\n        result = oldProxyObj.status === 'PENDING_OPEN' || oldProxyObj.status === 'PENDING_CLOSE'\n            ? oldProxyStr : newProxyStr;\n    } else {\n        result = newProxyStr;\n    }\n\n    return result;\n};\n\nexport default {\n  instanceStatusEndPoint: instanceStatusEndPoint\n};
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/server/controllers/api/instanceStatusController.js	(revision 45bf0c7d527fc55c00c7b2c460c22444d0131ee2)
+++ src/server/controllers/api/instanceStatusController.js	(date 1521823982000)
@@ -9,6 +9,7 @@
 import FogService from '../../services/fogService';
 import AppUtils from '../../utils/appUtils';
 import logger from '../../utils/winstonLogs';
+import ElemetInstanceStatusService from "../../services/elementInstanceStatusService";
 
 
 /********************************************* EndPoints ******************************************************/
@@ -22,8 +23,13 @@
       fogInstanceProps= {
         fogId: 'bodyParams.instanceId',
         setProperty: 'fogInstance'
+      },
+      statusProps = {
+          statusArr: 'bodyParams.elementstatus',
+          instanceId: 'bodyParams.instanceId',
+          setProperty: 'status'
       };
- 
+
   params.bodyParams = req.body;
   params.bodyParams.instanceId = req.params.ID;
   logger.info("Parameters:" + JSON.stringify(params.bodyParams));
@@ -31,7 +37,8 @@
   async.waterfall([
     async.apply(BaseApiController.checkUserExistance, req, res),
     async.apply(FogService.getFogInstance, fogInstanceProps, params),
-    updateFogInstance
+      async.apply(ElemetInstanceStatusService.createStatus, statusProps, params),
+      updateFogInstance,
   ], function(err, result) {
     AppUtils.sendResponse(res, err,'','', result);
   })
@@ -52,16 +59,16 @@
           diskusage : params.bodyParams.diskusage,
           cpuusage : params.bodyParams.cpuusage,
           memoryviolation : params.bodyParams.memoryviolation,
-          diskviolation : params.bodyParams.diskviolation, 
+            diskviolation: params.bodyParams.diskviolation,
           cpuviolation : params.bodyParams.cpuviolation,
-          elementstatus : params.bodyParams.elementstatus, 
+            elementstatus: params.bodyParams.elementstatus,
           repositorycount : params.bodyParams.repositorycount,
           repositorystatus : params.bodyParams.repositorystatus,
           systemtime : params.bodyParams.systemtime,
           laststatustime : params.bodyParams.laststatustime,
           ipaddress : params.bodyParams.ipaddress,
           processedmessages : params.bodyParams.processedmessages,
-          elementmessagecounts : params.bodyParams.elementmessagecounts, 
+            elementmessagecounts: params.bodyParams.elementmessagecounts,
           messagespeed : params.bodyParams.messagespeed,
           lastcommandtime : params.bodyParams.lastcommandtime,
           proxy : proxyStatus,
Index: src/server/managers/dataTracksManager.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.BaseRevisionTextPatchEP
<+>/**\n * @file dataTracksManager.js\n * @author Zishan Iqbal\n * @description This file includes the CURD operations for the dataTracks Model.\n */\n\nimport BaseManager from './../managers/baseManager';\nimport DataTracks from './../models/dataTracks';\nimport sequelize from './../utils/sequelize';\n\n\nclass DataTracksManager extends BaseManager {\n\n  getEntity() {\n    return DataTracks;\n  }\n\n  findByInstanceId(instanceId) {\n    return DataTracks.findAll({\n      where: {\n        instanceId: instanceId\n      },\n      attributes: ['id', 'name', 'description']\n    });\n  }\n\n  findById(trackId) {\n    return DataTracks.findOne({\n      where: {\n        'id': trackId\n      }\n    });\n  }\n\n  getTracksByUserId(userId) {\n    return DataTracks.findAll({\n      where: {\n        updatedBy: userId\n      }\n    });\n  }\n\n  deleteByTrackId(trackId) {\n    return DataTracks.destroy({\n      where: {\n        id: trackId\n      }\n    });\n  }\n\n  updateById(id, data) {\n    return DataTracks.update(data, {\n      where: {\n        id: id\n      }\n    });\n  }\n\n  updateByUserId(userId, data){\n   return DataTracks.update(data, {\n      where: {\n        updatedBy: userId\n      }\n    });\n  }\n\n  findContainerListByInstanceId(instanceId) {\n    let instanceTrackingQuery = \"SELECT i.*, t.is_activated FROM element_instance i LEFT JOIN \\\n    data_tracks t ON i.track_id = t.ID \\\n    WHERE i.iofog_uuid in (:instanceId) AND (i.track_id = 0 OR t.is_activated = 1)\";\n\n    return sequelize.query(instanceTrackingQuery, {\n      replacements: {\n        instanceId: instanceId\n      },\n      type: sequelize.QueryTypes.SELECT\n    });\n  }\n}\n\nconst instance = new DataTracksManager();\nexport default instance;
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/server/managers/dataTracksManager.js	(revision 45bf0c7d527fc55c00c7b2c460c22444d0131ee2)
+++ src/server/managers/dataTracksManager.js	(date 1521823982000)
@@ -65,8 +65,9 @@
   }
 
   findContainerListByInstanceId(instanceId) {
-    let instanceTrackingQuery = "SELECT i.*, t.is_activated FROM element_instance i LEFT JOIN \
+      let instanceTrackingQuery = "SELECT i.*, t.is_activated, s.* FROM element_instance i LEFT JOIN \
     data_tracks t ON i.track_id = t.ID \
+    LEFT JOIN element_instance_status s ON i.uuid = s.element_instance_uuid \
     WHERE i.iofog_uuid in (:instanceId) AND (i.track_id = 0 OR t.is_activated = 1)";
 
     return sequelize.query(instanceTrackingQuery, {
Index: src/server/managers/elementInstanceStatusManager.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/server/managers/elementInstanceStatusManager.js	(date 1521729416000)
+++ src/server/managers/elementInstanceStatusManager.js	(date 1521729416000)
@@ -0,0 +1,48 @@
+import BaseManager from "./baseManager";
+import ElementInstanceStatus from "../models/elementInstanceStatus";
+
+/**
+ * @author elukashick
+ */
+
+class ElementInstanceStatusManager extends BaseManager {
+    getEntity() {
+        return ElementInstanceStatus;
+    }
+
+    findByInstanceId(uuid) {
+        return ElementInstanceStatus.find({
+            where: {
+                element_instance_uuid: uuid
+            }
+        });
+    }
+
+    update(obj) {
+        return ElementInstanceStatus.update(obj, {
+            where: {
+                element_instance_uuid: obj.uuid
+            }
+        });
+    }
+
+    create(obj) {
+        return ElementInstanceStatus.create({
+            status: obj.status,
+            cpuUsage: obj.cpuUsage,
+            memoryUsage: obj.memoryUsage,
+            date: obj.date,
+            element_instance_uuid: obj.uuid
+        });
+    }
+
+    upsertStatus(obj) {
+        return this.findByInstanceId(obj.uuid)
+            .then((dbObj) => {
+                return null == dbObj ? this.create(obj) : this.update(obj)
+            });
+    }
+}
+
+const instance = new ElementInstanceStatusManager();
+export default instance;
\ No newline at end of file
Index: src/server/models/elementInstanceStatus.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/server/models/elementInstanceStatus.js	(date 1521721961000)
+++ src/server/models/elementInstanceStatus.js	(date 1521721961000)
@@ -0,0 +1,43 @@
+/**
+ * @author elukashick
+ */
+
+import Sequelize from 'sequelize';
+import sequelize from './../utils/sequelize';
+import ElementInstance from './elementInstance'
+
+const ElementInstanceStatus = sequelize.define('element_instance_status', {
+    id: {
+        type: Sequelize.INTEGER,
+        primaryKey: true,
+        autoIncrement: true,
+        field: 'ID'
+    },
+    status: {
+        type: Sequelize.TEXT,
+        field: 'status'
+    },
+    cpuUsage: {
+        type: Sequelize.FLOAT,
+        defaultValue: 0.000,
+        field: 'cpu_usage'
+    },
+    memoryUsage: {
+        type: Sequelize.BIGINT,
+        defaultValue: 0,
+        field: 'memory_usage'
+    }
+}, {
+    // add the timestamp attributes (updatedAt, createdAt)
+    timestamps: true,
+    // disable the modification of table names
+    freezeTableName: true,
+    // don't use camelcase for automatically added attributes but underscore style
+    // so updatedAt will be updated_at
+    underscored: true
+});
+
+ElementInstanceStatus.belongsTo(ElementInstance, {
+    foreignKey: 'element_instance_uuid'
+});
+export default ElementInstanceStatus;
\ No newline at end of file
Index: src/server/services/elementInstanceStatusService.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/server/services/elementInstanceStatusService.js	(date 1521722754000)
+++ src/server/services/elementInstanceStatusService.js	(date 1521722754000)
@@ -0,0 +1,33 @@
+import AppUtils from "../utils/appUtils";
+import ElementInstanceStatusManager from "../managers/elementInstanceStatusManager";
+
+/**
+ * @author elukashick
+ */
+
+const createStatus = function (props, params, callback) {
+    let statusArr = JSON.parse(AppUtils.getProperty(params, props.statusArr)),
+        instanceId = AppUtils.getProperty(params, props.instanceId);
+    for (var i = 0, len = statusArr.length; i < len; i++) {
+        let status = statusArr[i].status,
+            cpuUsage = statusArr[i].cpuUsage,
+            memoryUsage = statusArr[i].memoryUsage;
+
+        let obj = {
+            status: statusArr[i].status,
+            cpuUsage: statusArr[i].cpuusage,
+            memoryUsage: statusArr[i].memoryusage,
+            date: statusArr[i].starttime,
+            uuid: statusArr[i].id
+        };
+
+        ElementInstanceStatusManager
+            .upsertStatus(obj)
+            .then(AppUtils.onCreate.bind(null, params, props.setProperty, 'Unable to create Element Instance Status', callback));
+    }
+}
+
+
+export default {
+    createStatus: createStatus
+};
\ No newline at end of file
