-- noinspection SqlNoDataSourceInspectionForFile

-- Schema: device_manager
-- Brief: DeviceManager component controller
-- Created by: renepadilha
-- Table schema_version: must be defined for database update through the DeviceManagerPersistence component

CREATE TABLE schema_version AS
SELECT "$Author: renepadilha $" AS Author,
       "$Date: 2023-04-04 17:00:00 -0300$" AS LastModifiedAt,
       "$Revision: 3a16dbe826144cee7f304eb564b686525609f9a6$" AS Revision;

-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

CREATE TABLE DisabledDevices (
  DeviceName VARCHAR NOT NULL
);

CREATE UNIQUE INDEX 'idx_DeviceStatus_DeviceName' ON 'DisabledDevices' ('DeviceName');

CREATE TABLE DeviceStatusHistory (
  DeviceName VARCHAR NOT NULL,
  Enabled BOOLEAN NOT NULL,
  Operator VARCHAR NOT NULL,
  Timestamp DATETIME NOT NULL
);

CREATE INDEX 'idx_DeviceStatusHistory_DeviceName_Operator_Timestamp' ON 'DeviceStatusHistory' ('DeviceName', 'Operator', 'Timestamp');
-- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
