drop database if exists sk;
create database sk;
use sk;

-- Table structure for table `AlarmFense`
--

CREATE TABLE `AlarmFense` (
  `TableId` bigint UNSIGNED NOT NULL,
  `Name` varchar(128) NOT NULL,
  `UserId` bigint NOT NULL,
  `Shape` int NOT NULL,
  `CoodinatesList` varchar(2048) DEFAULT NULL,
  `Description` varchar(256) DEFAULT NULL,
  `Color` varchar(32) NOT NULL,
  `ShapeType` int NOT NULL,
  `IsShare` int NOT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `AlarmInfo`
--

CREATE TABLE `AlarmInfo` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint NOT NULL,
  `AlarmType` int NOT NULL,
  `AlarmId` varchar(64) NOT NULL,
  `CurTime` varchar(32) DEFAULT NULL,
  `Content` varchar(2048) DEFAULT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `Longitude` varchar(32) NOT NULL,
  `Latitude` varchar(32) NOT NULL,
  `GX` varchar(32) NOT NULL,
  `GY` varchar(32) NOT NULL,
  `GZ` varchar(32) NOT NULL,
  `Roll` varchar(32) NOT NULL,
  `Pitch` varchar(32) NOT NULL,
  `Yaw` varchar(32) NOT NULL,
  `EventId` varchar(64) NOT NULL,
  `VideoId` varchar(64) NOT NULL,
  `GpioStatus` varchar(32) DEFAULT NULL,
  `Direction` int DEFAULT NULL,
  `CarSpeed` bigint DEFAULT NULL,
  `GYR_X` varchar(32) DEFAULT NULL,
  `GYR_Y` varchar(32) DEFAULT NULL,
  `GYR_Z` varchar(32) DEFAULT NULL,
  `Extern1` varchar(32) DEFAULT NULL,
  `Extern2` varchar(32) DEFAULT NULL,
  `Extern3` varchar(32) DEFAULT NULL,
  `Extern4` varchar(32) DEFAULT NULL,
  `Extern5` varchar(32) DEFAULT NULL,
  `Extern` varchar(1024) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Triggers `AlarmInfo`
--
DELIMITER $$
CREATE TRIGGER `SendCopy` AFTER INSERT ON `AlarmInfo` FOR EACH ROW INSERT INTO AlarmInfoUser VALUES (NEW.TableId, NEW.DeviceId,NEW.AlarmType,NEW.AlarmId,NEW.CurTime,NEW.Content,NEW.CreateTime,NEW.Longitude,NEW.Latitude,NEW.GX,NEW.GY,NEW.GZ,NEW.Roll,NEW.Pitch,NEW.Yaw,NEW.EventId,NEW.VideoId,NEW.GpioStatus,NEW.Direction,NEW.CarSpeed,NEW.GYR_X,NEW.GYR_Y,NEW.GYR_Z,NEW.Extern1,NEW.Extern2,NEW.Extern3,NEW.Extern4,NEW.Extern5,NEW.Extern,'0','NO','0','NO','NO')
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `Sendcopybak` AFTER INSERT ON `AlarmInfo` FOR EACH ROW INSERT INTO AlarmInfobak VALUES (NEW.TableId, NEW.DeviceId,NEW.AlarmType,NEW.AlarmId,NEW.CurTime,NEW.Content,NEW.CreateTime,NEW.Longitude,NEW.Latitude,NEW.GX,NEW.GY,NEW.GZ,NEW.Roll,NEW.Pitch,NEW.Yaw,NEW.EventId,NEW.VideoId,NEW.GpioStatus,NEW.Direction,NEW.CarSpeed,NEW.GYR_X,NEW.GYR_Y,NEW.GYR_Z,NEW.Extern1,NEW.Extern2,NEW.Extern3,NEW.Extern4,NEW.Extern5,NEW.Extern,'0','NO','0','NO')
$$
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `AlarmInfobak`
--

CREATE TABLE `AlarmInfobak` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint NOT NULL,
  `AlarmType` int NOT NULL,
  `AlarmId` varchar(64) NOT NULL,
  `CurTime` varchar(32) DEFAULT NULL,
  `Content` varchar(2048) DEFAULT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `Longitude` varchar(32) NOT NULL,
  `Latitude` varchar(32) NOT NULL,
  `GX` varchar(32) NOT NULL,
  `GY` varchar(32) NOT NULL,
  `GZ` varchar(32) NOT NULL,
  `Roll` varchar(32) NOT NULL,
  `Pitch` varchar(32) NOT NULL,
  `Yaw` varchar(32) NOT NULL,
  `EventId` varchar(64) NOT NULL,
  `VideoId` varchar(64) NOT NULL,
  `GpioStatus` varchar(32) DEFAULT NULL,
  `Direction` int DEFAULT NULL,
  `CarSpeed` bigint DEFAULT NULL,
  `GYR_X` varchar(32) DEFAULT NULL,
  `GYR_Y` varchar(32) DEFAULT NULL,
  `GYR_Z` varchar(32) DEFAULT NULL,
  `Extern1` varchar(32) DEFAULT NULL,
  `Extern2` varchar(32) DEFAULT NULL,
  `Extern3` varchar(32) DEFAULT NULL,
  `Extern4` varchar(32) DEFAULT NULL,
  `Extern5` varchar(32) DEFAULT NULL,
  `Extern` varchar(1024) DEFAULT NULL,
  `ClientId` varchar(32) DEFAULT NULL,
  `TrySendEmail` enum('NO','YES') DEFAULT 'NO',
  `UserCheck` int DEFAULT NULL,
  `TrySendEmailPreview` enum('NO','YES') NOT NULL DEFAULT 'NO'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Triggers `AlarmInfobak`
--
DELIMITER $$
CREATE TRIGGER `AddClientId` AFTER INSERT ON `AlarmInfobak` FOR EACH ROW UPDATE AlarmInfoUser
INNER JOIN Devices ON AlarmInfoUser.DeviceId = Devices.DeviceId
SET AlarmInfoUser.ClientId = Devices.ClientId
WHERE AlarmInfoUser.VideoId = NEW.VideoId
$$
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `AlarmInfoUser`
--

CREATE TABLE `AlarmInfoUser` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint NOT NULL,
  `AlarmType` int NOT NULL,
  `AlarmId` varchar(64) NOT NULL,
  `CurTime` varchar(32) DEFAULT NULL,
  `Content` varchar(2048) DEFAULT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `Longitude` varchar(32) NOT NULL,
  `Latitude` varchar(32) NOT NULL,
  `GX` varchar(32) NOT NULL,
  `GY` varchar(32) NOT NULL,
  `GZ` varchar(32) NOT NULL,
  `Roll` varchar(32) NOT NULL,
  `Pitch` varchar(32) NOT NULL,
  `Yaw` varchar(32) NOT NULL,
  `EventId` varchar(64) NOT NULL,
  `VideoId` varchar(64) NOT NULL,
  `GpioStatus` varchar(32) DEFAULT NULL,
  `Direction` int DEFAULT NULL,
  `CarSpeed` bigint DEFAULT NULL,
  `GYR_X` varchar(32) DEFAULT NULL,
  `GYR_Y` varchar(32) DEFAULT NULL,
  `GYR_Z` varchar(32) DEFAULT NULL,
  `Extern1` varchar(32) DEFAULT NULL,
  `Extern2` varchar(32) DEFAULT NULL,
  `Extern3` varchar(32) DEFAULT NULL,
  `Extern4` varchar(32) DEFAULT NULL,
  `Extern5` varchar(32) DEFAULT NULL,
  `Extern` varchar(1024) DEFAULT NULL,
  `ClientId` varchar(32) DEFAULT NULL,
  `TrySendEmail` enum('NO','YES') DEFAULT 'NO',
  `UserCheck` int DEFAULT NULL,
  `TrySendEmailPreview` enum('NO','YES') DEFAULT 'NO',
  `FilesMove` enum('NO','YES') NOT NULL DEFAULT 'NO'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Triggers `AlarmInfoUser`
--
DELIMITER $$
CREATE TRIGGER `PushNotificationsDevice` AFTER INSERT ON `AlarmInfoUser` FOR EACH ROW UPDATE UserDevices
SET UserDevices.AlertNotifications = UserDevices.AlertNotifications + 1
WHERE UserDevices.DeviceId = NEW.DeviceId
$$
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `AutoTestRecord`
--

CREATE TABLE `AutoTestRecord` (
  `TableId` bigint UNSIGNED NOT NULL,
  `McuId` varchar(64) NOT NULL,
  `BeginTestTime` timestamp NULL DEFAULT '2011-11-11 11:11:11',
  `CellularType` varchar(128) NOT NULL,
  `WifiModule` varchar(128) NOT NULL,
  `GpsModule` varchar(128) NOT NULL,
  `DeviceType` varchar(128) NOT NULL,
  `EndTestTime` timestamp NULL DEFAULT '2011-11-11 11:11:11',
  `TestState` int NOT NULL,
  `OtherModule` varchar(1024) DEFAULT NULL,
  `TestModuleList` varchar(512) DEFAULT NULL,
  `TestExtendedState` varchar(10240) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `BasicConfig`
--

CREATE TABLE `BasicConfig` (
  `Tabled` int NOT NULL,
  `ConfigType` varchar(64) NOT NULL,
  `Content` varchar(2048) NOT NULL,
  `Extern` varchar(1024) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;


-- Dumping data for table `BasicConfig`
--

INSERT INTO `BasicConfig` (`Tabled`, `ConfigType`, `Content`, `Extern`) VALUES
(1, 'PortConfig', '{\"StreamsPort\":881,\"FileTransfersPort\":882,\"FileSavesPort\":883,\"VoiceTalksPort\":9100,\"ListenDriversPort\":9101,\"HttpStreamPort\":8082,\"HttpsStreamPort\":8084,\"HttpTransferPort\":8083,\"HttpsTransferPort\":8085}', NULL);

-- --------------------------------------------------------

--
-- Table structure for table `Branding`
--


CREATE TABLE `Branding` (
  `TableId` int NOT NULL,
  `CompanyName` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `Street1` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `Street2` varchar(255) DEFAULT NULL,
  `City` varchar(32) DEFAULT NULL,
  `State` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `Zip` varchar(32) DEFAULT NULL,
  `Country` varchar(32) DEFAULT NULL,
  `Phone` varchar(32) DEFAULT NULL,
  `MainLogo` varchar(255) NOT NULL,
  `MonoLogo` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `Favicon` varchar(255) NOT NULL,
  `WordLogo` varchar(255) NOT NULL,
  `Logo` varchar(255) NOT NULL,
  `Website` varchar(255) NOT NULL,
  `Color` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `TermConditions` varchar(255) DEFAULT 'https://paco1.com/pages/smart-vision-app-terms-and-conditions',
  `PrivacyPolicy` varchar(255) DEFAULT 'https://paco1.com/pages/smart-vision-app-terms-and-conditions',
  `BackgroundColor1` varchar(32) DEFAULT NULL,
  `BackgroundColor2` varchar(32) DEFAULT NULL,
  `Backgroundangle` varchar(32) DEFAULT NULL,
  `ButtonColor1` varchar(32) DEFAULT NULL,
  `ButtonColor2` varchar(32) DEFAULT NULL,
  `Faq` varchar(255) DEFAULT 'https://paco1.com/svt',
  `Documentation` varchar(255) DEFAULT 'https://paco1.com/svt',
  `Support` varchar(255) DEFAULT 'mailto:it@paco1.com',
  `SupportSection` varchar(255) DEFAULT 'DOCUMENTATION',
  `SupportSectionSwitch` enum('Enable','Disable') NOT NULL DEFAULT 'Enable',
  `FaqTitle` varchar(32) DEFAULT 'Faq',
  `SupportTitle` varchar(32) DEFAULT 'Support',
  `DocumentationTitle` varchar(32) DEFAULT 'Documentation',
  `LoginTitle` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT 'Smart Vision Login',
  `DesTitle` varchar(255) DEFAULT 'Effortlessly access your DVRs via the Internet or Local Server to enjoy a wide array of network services, including real-time video streaming, video playback, instant alerts, comprehensive checklists, and detailed reports.',
  `TermConditionsTitle` varchar(32) DEFAULT 'Term & Conditions',
  `PrivacyPolicyTitle` varchar(32) DEFAULT 'Privacy Policy'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Dumping data for table `Branding`
--

INSERT INTO `Branding` (`TableId`, `CompanyName`, `Street1`, `Street2`, `City`, `State`, `Zip`, `Country`, `Phone`, `MainLogo`, `MonoLogo`, `Favicon`, `WordLogo`, `Logo`, `Website`, `Color`, `TermConditions`, `PrivacyPolicy`, `BackgroundColor1`, `BackgroundColor2`, `Backgroundangle`, `ButtonColor1`, `ButtonColor2`, `Faq`, `Documentation`, `Support`, `SupportSection`, `SupportSectionSwitch`, `FaqTitle`, `SupportTitle`, `DocumentationTitle`, `LoginTitle`, `DesTitle`, `TermConditionsTitle`, `PrivacyPolicyTitle`) VALUES
(1, 'Panacea Aftermarket Co.', '555 Hanlan Road, Unit 5', '', 'Toronto', 'ON', 'L4L 4R8', 'Canada', '647-231-9521', '/assets/images/logo/PACO-LOGO.png', '/assets/images/logo/PACO-LOGO-small-white.png', '/assets/images/BEAST-FAVICON.png', '/assets/images/logo/PACO-LOGO-small-color_word.png', '/assets/images/logo/PACO-LOGO-small-color_face.png', 'paco1.com', '#d40002', 'https://paco1.com/pages/smart-vision-app-terms-and-conditions', 'https://paco1.com/pages/smart-vision-app-terms-and-conditions', '#000000', '#ff2600', '130', '#ff2600', '#b51a00', 'https://paco1.com/pages/forklift-smart-vision-cameras', 'https://paco1.com/pages/forklift-smart-vision-cameras', 'https://paco1.com/pages/forklift-smart-vision-cameras', 'DOCUMENTATION', 'Enable', 'Faq', 'Support', 'Documentation', 'Smart Vision Login', 'Effortlessly access your DVRs via the Internet or Local Server to enjoy a wide array of network services, including real-time video streaming, video playback, instant alerts, comprehensive checklists, and detailed reports.', 'Term & Conditions', 'Privacy Policy');

--
-- Indexes for dumped tables
--

-- --------------------------------------------------------

--
-- Table structure for table `CarState`
--

CREATE TABLE `CarState` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint NOT NULL,
  `CurTime` timestamp NULL DEFAULT '2011-11-11 11:11:11',
  `Longitude` decimal(18,6) DEFAULT NULL,
  `Latitude` decimal(18,6) DEFAULT NULL,
  `GSensorX` decimal(18,3) DEFAULT NULL,
  `GSensorY` decimal(18,3) DEFAULT NULL,
  `GSensorZ` decimal(18,3) DEFAULT NULL,
  `CarSpeed` decimal(18,2) DEFAULT NULL,
  `Course` smallint DEFAULT NULL,
  `ExDevSate` smallint DEFAULT NULL,
  `CarTemperature` decimal(18,2) DEFAULT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `Clients`
--

CREATE TABLE `Clients` (
  `ClientId` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `Name` varchar(64) NOT NULL DEFAULT '',
  `CreateTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `UserId` int UNSIGNED NOT NULL,
  `fullname` varchar(32) NOT NULL,
  `Enabled` enum('Enabled','Disabled','Enabled with Expiration Date') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `ContactName` varchar(100) DEFAULT NULL,
  `ContactEmail` varchar(100) DEFAULT NULL,
  `address` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `filename` varchar(100) DEFAULT 'BEAST-logo.png',
  `note` longtext,
  `ExpirationDate` date DEFAULT NULL,
  `StorgeSize` varchar(36) NOT NULL DEFAULT '8'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `CloudAccountInfo`
--

CREATE TABLE `CloudAccountInfo` (
  `TableId` bigint UNSIGNED NOT NULL,
  `CloudType` int NOT NULL,
  `CloudHost` varchar(128) NOT NULL,
  `BaseBucket` varchar(2048) NOT NULL,
  `AccessKey` varchar(256) NOT NULL,
  `SecretKey` varchar(1024) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `DeviceCommonCheckInfo`
--

CREATE TABLE `DeviceCommonCheckInfo` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint NOT NULL,
  `CheckType` varchar(64) NOT NULL,
  `Content` varchar(15360) NOT NULL,
  `CurTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Triggers `DeviceCommonCheckInfo`
--
DELIMITER $$
CREATE TRIGGER `CopytoDeviceCommonCheckInfoUsers` AFTER INSERT ON `DeviceCommonCheckInfo` FOR EACH ROW INSERT INTO DeviceCommonCheckInfoUsers VALUES (NEW.TableId, NEW.DeviceId,NEW.CheckType,NEW.Content,NEW.CurTime,NEW.CreateTime,'NO')
$$
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `DeviceCommonCheckInfoUsers`
--

CREATE TABLE `DeviceCommonCheckInfoUsers` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint NOT NULL,
  `CheckType` varchar(64) NOT NULL,
  `Content` varchar(15360) NOT NULL,
  `CurTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `TrySendEmail` enum('NO','YES') NOT NULL DEFAULT 'NO'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `DeviceConfigInfo`
--

CREATE TABLE `DeviceConfigInfo` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint NOT NULL,
  `ConfigSrc` int NOT NULL,
  `Content` varchar(14360) NOT NULL,
  `IsInform` int NOT NULL,
  `InformResult` varchar(1096) DEFAULT NULL,
  `InformTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `CheckCode` varchar(256) DEFAULT NULL,
  `Description` varchar(256) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `DeviceConfigVersion`
--

CREATE TABLE `DeviceConfigVersion` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint NOT NULL,
  `AlarmFenseVersion` bigint NOT NULL,
  `JudgeAlarmFenseType` int NOT NULL,
  `OtherVersion1` bigint NOT NULL,
  `OtherVersion2` bigint NOT NULL,
  `OtherVersion3` bigint NOT NULL,
  `OtherVersion4` bigint NOT NULL,
  `OtherVersion5` bigint NOT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `DeviceLogInfo`
--

CREATE TABLE `DeviceLogInfo` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint NOT NULL,
  `LogLevel` int NOT NULL,
  `CurTime` varchar(20) NOT NULL,
  `Content` varchar(1280) DEFAULT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `DeviceMacAddress`
--

CREATE TABLE `DeviceMacAddress` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint NOT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `MacAddress` varchar(128) NOT NULL,
  `Description` varchar(256) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `DeviceOnlineOfflineLog`
--

CREATE TABLE `DeviceOnlineOfflineLog` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint NOT NULL,
  `IsOnline` int NOT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `Reason` varchar(512) DEFAULT NULL,
  `Remark` varchar(512) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `DeviceRecordInfo`
--

CREATE TABLE `DeviceRecordInfo` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint NOT NULL,
  `RecordName` varchar(210) NOT NULL,
  `BeginTime` varchar(64) NOT NULL,
  `EndTime` varchar(64) NOT NULL,
  `RecordSize` int NOT NULL,
  `RecordType` int NOT NULL,
  `RecordPath` varchar(512) NOT NULL,
  `UploadState` int NOT NULL,
  `SaveType` int NOT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Triggers `DeviceRecordInfo`
--
DELIMITER $$
CREATE TRIGGER `COPY` AFTER INSERT ON `DeviceRecordInfo` FOR EACH ROW INSERT INTO DeviceRecordInfoUsers VALUES (NEW.TableId, NEW.DeviceId,NEW.RecordName,NEW.BeginTime,NEW.EndTime,NEW.RecordSize,NEW.RecordType,NEW.RecordPath,NEW.UploadState,NEW.SaveType,NEW.CreateTime,'0','NO','0')
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `ClientTRIGGER` AFTER INSERT ON `DeviceRecordInfo` FOR EACH ROW INSERT INTO DeviceRecordInfoUsersba VALUES (NEW.TableId, NEW.DeviceId,NEW.RecordName,NEW.BeginTime,NEW.EndTime,NEW.RecordSize,NEW.RecordType,NEW.RecordPath,NEW.UploadState,NEW.SaveType,NEW.CreateTime,'0','NO','0')
$$
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `DeviceRecordInfoUsers`
--

CREATE TABLE `DeviceRecordInfoUsers` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint DEFAULT NULL,
  `RecordName` varchar(210) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `BeginTime` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `EndTime` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `RecordSize` int DEFAULT NULL,
  `RecordType` int DEFAULT NULL,
  `RecordPath` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `UploadState` int DEFAULT NULL,
  `SaveType` int DEFAULT NULL,
  `CreateTime` timestamp NULL DEFAULT '2011-11-11 11:11:11',
  `ClientId` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `TrySendEmail` enum('YES','NO') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT 'NO',
  `AlarmTableId` bigint UNSIGNED DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `DeviceRecordInfoUsersba`
--

CREATE TABLE `DeviceRecordInfoUsersba` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint DEFAULT NULL,
  `RecordName` varchar(210) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `BeginTime` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `EndTime` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `RecordSize` int DEFAULT NULL,
  `RecordType` int DEFAULT NULL,
  `RecordPath` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `UploadState` int DEFAULT NULL,
  `SaveType` int DEFAULT NULL,
  `CreateTime` timestamp NULL DEFAULT '2011-11-11 11:11:11',
  `ClientId` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `EmailSent` enum('YES','NO') DEFAULT 'NO',
  `AlarmTableId` int NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Triggers `DeviceRecordInfoUsersba`
--
DELIMITER $$
CREATE TRIGGER `AlarmTableId` AFTER INSERT ON `DeviceRecordInfoUsersba` FOR EACH ROW BEGIN
  UPDATE DeviceRecordInfoUsers AS dr
  INNER JOIN AlarmInfo AS ai ON LEFT(dr.RecordName, 14) = LEFT(ai.AlarmId, 14)
  SET dr.AlarmTableId = ai.TableId
  WHERE dr.RecordName = NEW.RecordName;
END
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `ClientID` AFTER INSERT ON `DeviceRecordInfoUsersba` FOR EACH ROW UPDATE DeviceRecordInfoUsers
INNER JOIN Devices ON DeviceRecordInfoUsers.DeviceId = Devices.DeviceId
SET DeviceRecordInfoUsers.ClientId = Devices.ClientId
WHERE DeviceRecordInfoUsers.RecordName = NEW.RecordName
$$
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `DeviceRule`
--

CREATE TABLE `DeviceRule` (
  `TableId` bigint UNSIGNED NOT NULL,
  `RuleId` bigint NOT NULL,
  `DeviceId` bigint NOT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `Devices`
--

CREATE TABLE `Devices` (
  `ScanCode` varchar(64) NOT NULL,
  `McuId` varchar(64) DEFAULT 'unvalid McuId',
  `IsActive` int NOT NULL DEFAULT '0',
  `ActiveTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `DeviceId` bigint NOT NULL,
  `PlateNumber` varchar(64) NOT NULL,
  `ChannelNumber` enum('1','2','3','4') NOT NULL,
  `GroupId` int NOT NULL,
  `TcpServerAddr` varchar(32) DEFAULT '127.0.0.1',
  `TcpStreamInPort` int NOT NULL DEFAULT '9091',
  `TcpStreamOutPort` int NOT NULL DEFAULT '9091',
  `UdpServerAddr` varchar(32) DEFAULT '127.0.0.1',
  `UdpStreamInPort` int NOT NULL DEFAULT '0',
  `UdpStreamOutPort` int NOT NULL DEFAULT '0',
  `CloudFlag` int NOT NULL DEFAULT '0',
  `CreateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `DeviceType` varchar(64) DEFAULT 'unknow type',
  `ClientId` varchar(32) NOT NULL,
  `address` varchar(200) NOT NULL,
  `note` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `filename` varchar(100) NOT NULL DEFAULT 'BEAST-logo.png',
  `TimeZoneDevice` varchar(3) NOT NULL DEFAULT '0',
  `ActivationCode` varchar(100) DEFAULT NULL,
  `PlateNumberView` varchar(64) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `DeviceSaveConfig`
--

CREATE TABLE `DeviceSaveConfig` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint NOT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `UploadTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `Content` varchar(14360) NOT NULL,
  `Description` varchar(256) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `DeviceSession`
--

CREATE TABLE `DeviceSession` (
  `TableId` bigint NOT NULL,
  `SessionId` bigint DEFAULT NULL,
  `DeviceId` bigint DEFAULT NULL,
  `Login` timestamp NULL DEFAULT NULL,
  `Logout` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `DeviceStateInfo`
--

CREATE TABLE `DeviceStateInfo` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint NOT NULL,
  `UserName` varchar(32) NOT NULL,
  `CurTime` timestamp NULL DEFAULT '2011-11-11 11:11:11',
  `DriverId` varchar(64) NOT NULL,
  `StateType` int NOT NULL,
  `GpioStatus` varchar(32) NOT NULL,
  `Direction` int DEFAULT NULL,
  `CarSpeed` bigint DEFAULT NULL,
  `Longitude` varchar(32) NOT NULL,
  `Latitude` varchar(32) NOT NULL,
  `CarTemperature` int DEFAULT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `CpuTemperature` int DEFAULT '0',
  `McuTemperature` int DEFAULT '0',
  `GsensorTemperature` int DEFAULT '0',
  `CellularTemperature` int DEFAULT '0',
  `Extern1` varchar(32) DEFAULT NULL,
  `Extern2` varchar(32) DEFAULT NULL,
  `Extern3` varchar(32) DEFAULT NULL,
  `Extern4` varchar(32) DEFAULT NULL,
  `Extern5` varchar(32) DEFAULT NULL,
  `Extern` varchar(1024) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `DeviceUpdateFile`
--

CREATE TABLE `DeviceUpdateFile` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint NOT NULL,
  `UpdateFileId` bigint UNSIGNED DEFAULT NULL,
  `FileDownloadResult` int NOT NULL,
  `FileDownloadInformTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `UpdateScheduleInformTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `UpdateScheduleResult` int NOT NULL,
  `UpdateSchedule` varchar(512) NOT NULL,
  `FileUpdateResult` int NOT NULL,
  `FileUpdateInformTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `Description` varchar(256) NOT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `DriverFaceIdFileInfo`
--

CREATE TABLE `DriverFaceIdFileInfo` (
  `Tabled` int NOT NULL,
  `FaceInfoMark` varchar(128) NOT NULL COMMENT 'Face information identification',
  `FileName` varchar(256) NOT NULL,
  `AcqTime` datetime NOT NULL COMMENT 'Face information collection time',
  `FilePath` varchar(256) NOT NULL,
  `CreateTime` datetime NOT NULL,
  `Extern` varchar(1024) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='Driver face information file table';

-- --------------------------------------------------------

--
-- Table structure for table `DriverInfo`
--

CREATE TABLE `DriverInfo` (
  `TableId` bigint UNSIGNED NOT NULL,
  `UserId` int UNSIGNED NOT NULL,
  `DriverId` varchar(128) DEFAULT NULL,
  `DriverName` varchar(128) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `EmailSetting`
--

CREATE TABLE `EmailSetting` (
  `Name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `Email` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `SMTPserver` varchar(50) NOT NULL,
  `Username` varchar(50) NOT NULL,
  `Password` varchar(200) NOT NULL,
  `Port` varchar(10) NOT NULL,
  `Id` int NOT NULL,
  `SMTPSecure` enum('SSL','NONE') NOT NULL,
  `Loginbutton` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;


--
-- Dumping data for table `EmailSetting`
--

INSERT INTO `EmailSetting` (`Name`, `Email`, `SMTPserver`, `Username`, `Password`, `Port`, `Id`, `SMTPSecure`, `Loginbutton`) VALUES
('Smart Vision System', 'test@testbn.com', 'mail.testbn.com', 'test@testbn.com', '036=', '465', 1, 'SSL', 'https://sv.paco1.com');

--
-- Indexes for dumped tables
--

-- --------------------------------------------------------

--
-- Table structure for table `EventRecordStatus`
--

CREATE TABLE `EventRecordStatus` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint NOT NULL,
  `VideoId` varchar(64) NOT NULL,
  `FilePath` varchar(1024) NOT NULL,
  `Status` int NOT NULL,
  `Reason` varchar(128) NOT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `FactoryInitDvrInfo`
--

CREATE TABLE `FactoryInitDvrInfo` (
  `TableId` bigint UNSIGNED NOT NULL,
  `SecretKey` varchar(64) NOT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `Groups`
--

CREATE TABLE `Groups` (
  `GroupId` int UNSIGNED NOT NULL,
  `Name` varchar(64) NOT NULL DEFAULT '',
  `CreateTime` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
  `UserId` int UNSIGNED NOT NULL,
  `ClientId` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `fullname` varchar(32) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `HistoryDeviceUpdateFile`
--

CREATE TABLE `HistoryDeviceUpdateFile` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint NOT NULL,
  `DeviceType` int NOT NULL,
  `UpdateFileVersion` varchar(210) NOT NULL,
  `FileDownloadResult` int NOT NULL,
  `FileDownloadInformTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `UpdateScheduleInformTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `UpdateScheduleResult` int NOT NULL,
  `UpdateSchedule` varchar(512) NOT NULL,
  `FileUpdateResult` int NOT NULL,
  `FileUpdateInformTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `Description` varchar(256) NOT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `login_attempts`
--

CREATE TABLE `login_attempts` (
  `id` int NOT NULL,
  `ip_address` varchar(255) NOT NULL,
  `attempts_left` tinyint(1) NOT NULL DEFAULT '5',
  `date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `OfflineInformDevice`
--

CREATE TABLE `OfflineInformDevice` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint NOT NULL,
  `InformType` varchar(64) NOT NULL,
  `Content` varchar(15360) NOT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `RecordFileInfo`
--

CREATE TABLE `RecordFileInfo` (
  `TableId` bigint UNSIGNED NOT NULL,
  `DeviceId` bigint NOT NULL,
  `PlateNumber` varchar(32) NOT NULL,
  `FileName` varchar(128) NOT NULL,
  `UploadTime` varchar(64) NOT NULL,
  `BeginTime` varchar(64) NOT NULL,
  `EndTime` varchar(64) NOT NULL,
  `FileSize` int NOT NULL,
  `FileType` int NOT NULL,
  `FilePath` varchar(512) NOT NULL,
  `Description` varchar(64) DEFAULT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `Rule`
--

CREATE TABLE `Rule` (
  `TableId` bigint UNSIGNED NOT NULL,
  `UserId` bigint NOT NULL,
  `Name` varchar(128) NOT NULL,
  `RuleType` int NOT NULL,
  `FenseId` int NOT NULL,
  `Content` varchar(2048) NOT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `SecurityLog`
--

CREATE TABLE `SecurityLog` (
  `TableId` bigint UNSIGNED NOT NULL,
  `UserId` int NOT NULL,
  `UserName` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `Description` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `ClientId` varchar(512) DEFAULT NULL,
  `OperateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `OperatorAddr` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `Country` varchar(100) DEFAULT NULL,
  `Region` varchar(100) DEFAULT NULL,
  `City` varchar(100) DEFAULT NULL,
  `UserAgent` varchar(300) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `ServerConfigInfo`
--

CREATE TABLE `ServerConfigInfo` (
  `TableId` bigint UNSIGNED NOT NULL,
  `ControlPort` int NOT NULL,
  `StreamPort` int NOT NULL,
  `FileTransferPort` int NOT NULL,
  `FileSavePort` int NOT NULL,
  `VoiceTalkPort` int NOT NULL,
  `ListenDriverPort` int NOT NULL,
  `ControlsPort` int NOT NULL,
  `SelfHttpPort` int NOT NULL,
  `SelfHttpsPort` int NOT NULL,
  `WebServerPort` int NOT NULL,
  `WebServersPort` int NOT NULL,
  `UploadCloudFlag` int NOT NULL,
  `RecordSaveFlag` int NOT NULL,
  `NetWorkCard` varchar(32) DEFAULT NULL,
  `IpAddr` varchar(64) DEFAULT NULL,
  `SystemSalt` varchar(96) DEFAULT NULL,
  `EncryptType` int NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;


--
-- Dumping data for table `ServerConfigInfo`
--

INSERT INTO `ServerConfigInfo` (`TableId`, `ControlPort`, `StreamPort`, `FileTransferPort`, `FileSavePort`, `VoiceTalkPort`, `ListenDriverPort`, `ControlsPort`, `SelfHttpPort`, `SelfHttpsPort`, `WebServerPort`, `WebServersPort`, `UploadCloudFlag`, `RecordSaveFlag`, `NetWorkCard`, `IpAddr`, `SystemSalt`, `EncryptType`) VALUES
(1, 77, 9091, 9092, 9093, 9094, 9095, 880, 6060, 6062, 80, 443, 0, 0, 'etho', '127.0.0.1', '', 0);

--
-- Indexes for dumped tables
--


-- --------------------------------------------------------

--
-- Table structure for table `StreamServerSession`
--

CREATE TABLE `StreamServerSession` (
  `SessionId` bigint UNSIGNED NOT NULL,
  `SessionType` smallint NOT NULL,
  `CmsClientId` bigint NOT NULL,
  `DeviceId` bigint NOT NULL,
  `ChannelId` int NOT NULL DEFAULT '0',
  `ClientIp` varchar(32) DEFAULT NULL,
  `ClientMacAddr` varchar(64) DEFAULT NULL,
  `ClientComment` varchar(128) DEFAULT NULL,
  `CreateTime` timestamp NULL DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Triggers `StreamServerSession`
--
DELIMITER $$
CREATE TRIGGER `Sessionend` AFTER DELETE ON `StreamServerSession` FOR EACH ROW UPDATE DeviceSession SET Logout = CURRENT_TIMESTAMP
WHERE OLD.CreateTime = DeviceSession.Login
$$
DELIMITER ;
DELIMITER $$
CREATE TRIGGER `SessionsStart` AFTER INSERT ON `StreamServerSession` FOR EACH ROW INSERT INTO DeviceSession VALUE (null,NEW.SessionId,NEW.DeviceId,New.CreateTime,New.CreateTime)
$$
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `SuperAdminSettings`
--

CREATE TABLE `SuperAdminSettings` (
  `id` int NOT NULL,
  `trackIp` enum('Enable','Disable') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `TwoFactor` enum('Enable','Disable') NOT NULL,
  `BruteForceProtection` enum('Enable','Disable') NOT NULL,
  `CSRF` enum('Enable','Disable') NOT NULL,
  `ForgotPassword` enum('Enable','Disable') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `LoginEmailNotifications` enum('Enable','Disable') NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;


--
-- Dumping data for table `SuperAdminSettings`
--

INSERT INTO `SuperAdminSettings` (`id`, `trackIp`, `TwoFactor`, `BruteForceProtection`, `CSRF`, `ForgotPassword`, `LoginEmailNotifications`) VALUES
(1, 'Enable', 'Disable', 'Enable', 'Enable', 'Enable', 'Disable');

--
-- Indexes for dumped tables
--

-- --------------------------------------------------------

--
-- Table structure for table `UserConfigInfo`
--

CREATE TABLE `UserConfigInfo` (
  `UserId` int UNSIGNED NOT NULL,
  `DriverIdVersion` int UNSIGNED NOT NULL,
  `DeviceVersion` varchar(2048) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `UserContactInfo`
--

CREATE TABLE `UserContactInfo` (
  `TableId` bigint UNSIGNED NOT NULL,
  `UserId` bigint NOT NULL,
  `EmailInfo` varchar(1024) NOT NULL,
  `PhoneInfo` varchar(1024) NOT NULL,
  `WebChatInfo` varchar(1024) NOT NULL,
  `FacebookInfo` varchar(1024) NOT NULL,
  `OtherInfo1` varchar(1024) NOT NULL,
  `OtherInfo2` varchar(1024) NOT NULL,
  `OtherInfo3` varchar(1024) NOT NULL,
  `Description` varchar(512) NOT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `UpdateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `AlarmInfoList` varchar(2048) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `UserCustomAlarmName`
--

CREATE TABLE `UserCustomAlarmName` (
  `ID` int NOT NULL,
  `UserId` int NOT NULL COMMENT 'UserID',
  `Button1Name` varchar(40) DEFAULT NULL COMMENT 'Remote controller alarm 1',
  `Button2Name` varchar(40) DEFAULT NULL COMMENT 'Remote controller alarm 2',
  `Button3Name` varchar(40) DEFAULT NULL COMMENT 'Remote controller alarm 3',
  `Button4Name` varchar(40) DEFAULT NULL COMMENT 'Remote controller alarm 4',
  `Button5Name` varchar(40) DEFAULT NULL COMMENT 'Remote controller alarm 5',
  `Button6Name` varchar(40) DEFAULT NULL COMMENT 'Remote controller alarm 6',
  `Button7Name` varchar(40) DEFAULT NULL COMMENT 'Remote controller alarm 7',
  `Button8Name` varchar(40) DEFAULT NULL COMMENT 'Remote controller alarm 8',
  `Alarm1Name` varchar(40) DEFAULT NULL COMMENT 'Trigger alarm 1',
  `Alarm2Name` varchar(40) DEFAULT NULL COMMENT 'Trigger alarm 2',
  `Alarm3Name` varchar(40) DEFAULT NULL COMMENT 'Trigger alarm 3',
  `Alarm4Name` varchar(40) DEFAULT NULL COMMENT 'Trigger alarm 4',
  `Alarm5Name` varchar(40) DEFAULT NULL COMMENT 'Trigger alarm 5',
  `Alarm6Name` varchar(40) DEFAULT NULL COMMENT 'Trigger alarm 6',
  `Alarm7Name` varchar(40) DEFAULT NULL COMMENT 'Trigger alarm 7',
  `Alarm8Name` varchar(40) DEFAULT NULL COMMENT 'Trigger alarm 8',
  `Extern` varchar(2048) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='User custom alarm name';

-- --------------------------------------------------------

--
-- Table structure for table `UserDeviceFaceIdFile`
--

CREATE TABLE `UserDeviceFaceIdFile` (
  `Tabled` int NOT NULL,
  `DeviceId` int NOT NULL,
  `FileName` varchar(128) NOT NULL COMMENT 'FaceIdFile Name',
  `FilePath` varchar(1024) NOT NULL COMMENT 'FaceIdFile Path',
  `SendedTime` datetime NOT NULL COMMENT 'Send completion update time',
  `IsSended` tinyint(1) NOT NULL COMMENT 'dvr receiving completion identification',
  `Extern` varchar(2024) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='Facial Id information distribution device table';

-- --------------------------------------------------------

--
-- Table structure for table `UserDevices`
--

CREATE TABLE `UserDevices` (
  `UserId` int NOT NULL,
  `DeviceId` bigint NOT NULL,
  `IsFavorite` smallint UNSIGNED DEFAULT '0',
  `CreateTime` timestamp NOT NULL DEFAULT '2017-09-21 12:12:12',
  `Id` int NOT NULL,
  `ClientId` varchar(32) NOT NULL,
  `AlertNotifications` int DEFAULT '0',
  `AssignedDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `AlertNotification` enum('ON','OFF') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT 'ON',
  `ChecklistNotification` enum('ON','OFF') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT 'ON'
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `UserDriverFaceIdFileInfo`
--

CREATE TABLE `UserDriverFaceIdFileInfo` (
  `Tabled` int NOT NULL,
  `UserName` varchar(64) NOT NULL,
  `FaceInfoMark` varchar(128) NOT NULL COMMENT 'Face information identification',
  `CreateTime` datetime NOT NULL,
  `Extern` varchar(1024) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='User Driver face information file table';

-- --------------------------------------------------------

--
-- Table structure for table `UserMacAddress`
--

CREATE TABLE `UserMacAddress` (
  `TableId` bigint UNSIGNED NOT NULL,
  `CreateTime` timestamp NOT NULL DEFAULT '2011-11-11 11:11:11',
  `MacAddress` varchar(128) NOT NULL,
  `IsUsed` int DEFAULT NULL,
  `UserName` varchar(32) NOT NULL,
  `Description` varchar(256) NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `UserOperateLog`
--

CREATE TABLE `UserOperateLog` (
  `TableId` bigint UNSIGNED NOT NULL,
  `UserId` int NOT NULL,
  `UserName` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL,
  `Description` varchar(512) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `ClientId` varchar(512) DEFAULT NULL,
  `OperateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `OperatorAddr` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `Users`
--

CREATE TABLE `Users` (
  `UserId` int UNSIGNED NOT NULL,
  `UserName` varchar(32) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL DEFAULT '',
  `Password` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `Language` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'english',
  `Enabled` enum('Enabled','Disabled') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `Stream` enum('None','View') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'None',
  `Reports` enum('None','View') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'None',
  `Control` enum('None','View','Edit') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'None',
  `Devices` enum('None','View','Edit') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'None',
  `System` enum('None','View','Edit') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'None',
  `MaxBandwidth` varchar(16) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT '',
  `ParentUserId` tinyint UNSIGNED NOT NULL DEFAULT '1',
  `CreateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `role` enum('User','Admin','Super Admin') CHARACTER SET utf32 COLLATE utf32_general_ci NOT NULL,
  `email` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `registered` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `activation_code` varchar(50) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '',
  `rememberme` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT '',
  `last_seen` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `fullname` text NOT NULL,
  `address` text NOT NULL,
  `note` longtext NOT NULL,
  `filename` varchar(100) NOT NULL DEFAULT 'BEAST-logo.png',
  `last_seen_ip_address` varchar(32) NOT NULL,
  `last_seen_city` varchar(32) NOT NULL,
  `last_seen_region` varchar(32) NOT NULL,
  `last_see_country` varchar(32) NOT NULL,
  `login_email_notification` enum('ON','OFF') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT 'ON',
  `ClientId` varchar(32) NOT NULL,
  `UserAccess` enum('None','View','Edit') NOT NULL,
  `reset` varchar(50) NOT NULL,
  `TimeZone` varchar(3) NOT NULL DEFAULT '0',
  `checklist_email_notification` enum('ON','OFF') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL DEFAULT 'ON',
  `tfa_code` varchar(255) NOT NULL DEFAULT '',
  `alert_email_notification` enum('ON Send Alert','ON Send Alert with Video','ON Send 2 Alerts with and without video','OFF') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT 'ON Send Alert',
  `alert_email_notification2` enum('1','2','3','0') CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT '1',
  `Phone` varchar(255) NOT NULL DEFAULT '0',
  `LoginWhatsAppNotification` enum('ON','OFF') NOT NULL DEFAULT 'OFF',
  `AlertWhatsAppNotification` enum('ON Send Alert','ON Send Alert with Video','ON Send 2 Alerts with and without video','OFF') NOT NULL DEFAULT 'OFF',
  `ChecklistWhatsAppNotification` enum('ON','OFF') NOT NULL DEFAULT 'OFF',
  `Events` enum('None','View','Edit') CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL DEFAULT 'View'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

--
-- Triggers `Users`
--
DELIMITER $$
CREATE TRIGGER `Viewusers` AFTER INSERT ON `Users` FOR EACH ROW INSERT INTO ViewUsers VALUE (NEW.UserId,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,4,null)
$$
DELIMITER ;

-- --------------------------------------------------------

--
-- Table structure for table `ViewUsers`
--

CREATE TABLE `ViewUsers` (
  `UserId` int NOT NULL,
  `DeviceId1` bigint DEFAULT NULL,
  `view1ch` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT 'CH 1',
  `DeviceId2` bigint DEFAULT NULL,
  `view2ch` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT 'CH 1',
  `DeviceId3` bigint DEFAULT NULL,
  `view3ch` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT 'CH 1',
  `DeviceId4` bigint DEFAULT NULL,
  `view4ch` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT 'CH 1',
  `DeviceId5` bigint DEFAULT NULL,
  `view5ch` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT 'CH 1',
  `DeviceId6` bigint DEFAULT NULL,
  `view6ch` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT 'CH 1',
  `DeviceId7` bigint DEFAULT NULL,
  `view7ch` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT 'CH 1',
  `DeviceId8` bigint DEFAULT NULL,
  `view8ch` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT 'CH 1',
  `DeviceId9` bigint DEFAULT NULL,
  `view9ch` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT 'CH 1',
  `DeviceId10` bigint DEFAULT NULL,
  `view10ch` varchar(36) DEFAULT NULL,
  `DeviceId11` bigint DEFAULT NULL,
  `view11ch` varchar(36) DEFAULT NULL,
  `DeviceId12` bigint DEFAULT NULL,
  `view12ch` varchar(36) DEFAULT NULL,
  `liveview` varchar(36) DEFAULT '4',
  `Theme` int DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

-- --------------------------------------------------------

--
-- Table structure for table `WhatsappSetting`
--

CREATE TABLE `WhatsappSetting` (
  `TableId` int NOT NULL,
  `InstanceId` varchar(36) NOT NULL,
  `Token` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

--
-- Indexes for dumped tables
--
--
-- Dumping data for table `WhatsappSetting`
--

INSERT INTO `WhatsappSetting` (`TableId`, `InstanceId`, `Token`) VALUES
(1, '', '');
--
-- Indexes for table `AlarmFense`
--
ALTER TABLE `AlarmFense`
  ADD PRIMARY KEY (`TableId`),
  ADD UNIQUE KEY `UK_Name` (`Name`),
  ADD KEY `IX_AlarmFense_UserId` (`UserId`);

--
-- Indexes for table `AlarmInfo`
--
ALTER TABLE `AlarmInfo`
  ADD PRIMARY KEY (`TableId`),
  ADD UNIQUE KEY `UK_EventId` (`EventId`),
  ADD KEY `IX_Alarm_Info_DeviceId_AlarmType_CurTime` (`DeviceId`,`AlarmType`,`CurTime`),
  ADD KEY `IX_AlarmInfo_TableId` (`AlarmId`),
  ADD KEY `IX_AlarmInfo_EventId` (`EventId`),
  ADD KEY `IX_AlarmInfo_VideoId` (`VideoId`);

--
-- Indexes for table `AlarmInfobak`
--
ALTER TABLE `AlarmInfobak`
  ADD PRIMARY KEY (`TableId`),
  ADD UNIQUE KEY `UK_EventId` (`EventId`),
  ADD KEY `IX_Alarm_Info_DeviceId_AlarmType_CurTime` (`DeviceId`,`AlarmType`,`CurTime`),
  ADD KEY `IX_AlarmInfo_TableId` (`AlarmId`),
  ADD KEY `IX_AlarmInfo_EventId` (`EventId`),
  ADD KEY `IX_AlarmInfo_VideoId` (`VideoId`);

--
-- Indexes for table `AlarmInfoUser`
--
ALTER TABLE `AlarmInfoUser`
  ADD PRIMARY KEY (`TableId`),
  ADD UNIQUE KEY `UK_EventId` (`EventId`),
  ADD KEY `IX_Alarm_Info_DeviceId_AlarmType_CurTime` (`DeviceId`,`AlarmType`,`CurTime`),
  ADD KEY `IX_AlarmInfo_TableId` (`AlarmId`),
  ADD KEY `IX_AlarmInfo_EventId` (`EventId`),
  ADD KEY `IX_AlarmInfo_VideoId` (`VideoId`);

--
-- Indexes for table `AutoTestRecord`
--
ALTER TABLE `AutoTestRecord`
  ADD PRIMARY KEY (`TableId`),
  ADD UNIQUE KEY `UK_McuId` (`McuId`) USING BTREE;

--
-- Indexes for table `BasicConfig`
--
ALTER TABLE `BasicConfig`
  ADD PRIMARY KEY (`Tabled`),
  ADD UNIQUE KEY `ConfigType` (`ConfigType`) USING BTREE;

--
-- Indexes for table `Branding`
--
ALTER TABLE `Branding`
  ADD PRIMARY KEY (`TableId`);

--
-- Indexes for table `CarState`
--
ALTER TABLE `CarState`
  ADD PRIMARY KEY (`TableId`),
  ADD UNIQUE KEY `DeviceId` (`DeviceId`),
  ADD UNIQUE KEY `IX_DeviceId_and_GpsTime` (`CurTime`) USING BTREE;

--
-- Indexes for table `Clients`
--
ALTER TABLE `Clients`
  ADD PRIMARY KEY (`ClientId`);

--
-- Indexes for table `CloudAccountInfo`
--
ALTER TABLE `CloudAccountInfo`
  ADD PRIMARY KEY (`TableId`),
  ADD UNIQUE KEY `IX_CloudAccountInfo_CloudType` (`CloudType`) USING BTREE;

--
-- Indexes for table `DeviceCommonCheckInfo`
--
ALTER TABLE `DeviceCommonCheckInfo`
  ADD PRIMARY KEY (`TableId`),
  ADD KEY `IX_DeviceCommonCheckInfo_DeviceId` (`DeviceId`),
  ADD KEY `IX_DeviceCommonCheckInfo_CurTime` (`CurTime`),
  ADD KEY `IX_DeviceCommonCheckInfo_CheckType` (`CheckType`);

--
-- Indexes for table `DeviceCommonCheckInfoUsers`
--
ALTER TABLE `DeviceCommonCheckInfoUsers`
  ADD PRIMARY KEY (`TableId`),
  ADD KEY `IX_DeviceCommonCheckInfo_DeviceId` (`DeviceId`),
  ADD KEY `IX_DeviceCommonCheckInfo_CurTime` (`CurTime`),
  ADD KEY `IX_DeviceCommonCheckInfo_CheckType` (`CheckType`);

--
-- Indexes for table `DeviceLogInfo`
--
ALTER TABLE `DeviceLogInfo`
  ADD PRIMARY KEY (`TableId`),
  ADD KEY `IX_Device_Log_Info_DeviceId_LogLevel_CurTime` (`DeviceId`,`LogLevel`,`CurTime`);

--
-- Indexes for table `DeviceOnlineOfflineLog`
--
ALTER TABLE `DeviceOnlineOfflineLog`
  ADD PRIMARY KEY (`TableId`),
  ADD KEY `IX_Device_Online_Offline_Log` (`DeviceId`,`CreateTime`);

--
-- Indexes for table `DeviceRecordInfo`
--
ALTER TABLE `DeviceRecordInfo`
  ADD PRIMARY KEY (`TableId`),
  ADD KEY `IX_Device_Record_Info_FileName` (`DeviceId`,`RecordName`),
  ADD KEY `IX_Device_Record_Info_Time` (`DeviceId`,`BeginTime`,`EndTime`),
  ADD KEY `IX_Device_Record_Info_FileType` (`DeviceId`,`RecordType`);

--
-- Indexes for table `DeviceRecordInfoUsers`
--
ALTER TABLE `DeviceRecordInfoUsers`
  ADD PRIMARY KEY (`TableId`),
  ADD KEY `IX_Device_Record_Info_FileName` (`DeviceId`,`RecordName`),
  ADD KEY `IX_Device_Record_Info_Time` (`DeviceId`,`BeginTime`,`EndTime`),
  ADD KEY `IX_Device_Record_Info_FileType` (`DeviceId`,`RecordType`);

--
-- Indexes for table `DeviceRecordInfoUsersba`
--
ALTER TABLE `DeviceRecordInfoUsersba`
  ADD PRIMARY KEY (`TableId`),
  ADD KEY `IX_Device_Record_Info_FileName` (`DeviceId`,`RecordName`),
  ADD KEY `IX_Device_Record_Info_Time` (`DeviceId`,`BeginTime`,`EndTime`),
  ADD KEY `IX_Device_Record_Info_FileType` (`DeviceId`,`RecordType`);

--
-- Indexes for table `Devices`
--
ALTER TABLE `Devices`
  ADD PRIMARY KEY (`DeviceId`),
  ADD UNIQUE KEY `UK_PlateNumber` (`PlateNumber`),
  ADD UNIQUE KEY `UK_ScanCode` (`ScanCode`),
  ADD KEY `IX_GroupId` (`GroupId`),
  ADD KEY `IX_McuId` (`McuId`);

--
-- Indexes for table `DeviceSession`
--
ALTER TABLE `DeviceSession`
  ADD PRIMARY KEY (`TableId`);

--
-- Indexes for table `DriverFaceIdFileInfo`
--
ALTER TABLE `DriverFaceIdFileInfo`
  ADD PRIMARY KEY (`Tabled`),
  ADD UNIQUE KEY `FaceInfoMark` (`FaceInfoMark`) USING BTREE;

--
-- Indexes for table `EmailSetting`
--
ALTER TABLE `EmailSetting`
  ADD PRIMARY KEY (`Id`);

--
-- Indexes for table `Groups`
--
ALTER TABLE `Groups`
  ADD PRIMARY KEY (`GroupId`),
  ADD UNIQUE KEY `IX_Group_name` (`Name`) USING BTREE;

--
-- Indexes for table `login_attempts`
--
ALTER TABLE `login_attempts`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `ip_address` (`ip_address`);

--
-- Indexes for table `SecurityLog`
--
ALTER TABLE `SecurityLog`
  ADD PRIMARY KEY (`TableId`);

--
-- Indexes for table `ServerConfigInfo`
--
ALTER TABLE `ServerConfigInfo`
  ADD PRIMARY KEY (`TableId`);

--
-- Indexes for table `StreamServerSession`
--
ALTER TABLE `StreamServerSession`
  ADD UNIQUE KEY `UK_CmsClient_Req_Device` (`SessionType`,`CmsClientId`,`DeviceId`,`ChannelId`),
  ADD KEY `IX_SessionId` (`SessionId`);

--
-- Indexes for table `SuperAdminSettings`
--
ALTER TABLE `SuperAdminSettings`
  ADD PRIMARY KEY (`id`),
  ADD UNIQUE KEY `id` (`id`);

--
-- Indexes for table `UserContactInfo`
--
ALTER TABLE `UserContactInfo`
  ADD PRIMARY KEY (`TableId`),
  ADD UNIQUE KEY `IX_UserContactInfo_UserId1` (`UserId`);

--
-- Indexes for table `UserCustomAlarmName`
--
ALTER TABLE `UserCustomAlarmName`
  ADD PRIMARY KEY (`ID`),
  ADD UNIQUE KEY `Alarm_UserId` (`UserId`) USING BTREE;

--
-- Indexes for table `UserDeviceFaceIdFile`
--
ALTER TABLE `UserDeviceFaceIdFile`
  ADD PRIMARY KEY (`Tabled`),
  ADD UNIQUE KEY `DeviceId` (`DeviceId`) USING BTREE;

--
-- Indexes for table `UserDevices`
--
ALTER TABLE `UserDevices`
  ADD PRIMARY KEY (`Id`);

--
-- Indexes for table `UserDriverFaceIdFileInfo`
--
ALTER TABLE `UserDriverFaceIdFileInfo`
  ADD PRIMARY KEY (`Tabled`),
  ADD UNIQUE KEY `User_FaceInfoMark` (`UserName`,`FaceInfoMark`) USING BTREE;

--
-- Indexes for table `UserOperateLog`
--
ALTER TABLE `UserOperateLog`
  ADD PRIMARY KEY (`TableId`);

--
-- Indexes for table `Users`
--
ALTER TABLE `Users`
  ADD PRIMARY KEY (`UserId`),
  ADD UNIQUE KEY `UC_UserName` (`UserName`) USING BTREE;

--
-- Indexes for table `ViewUsers`
--
ALTER TABLE `ViewUsers`
  ADD PRIMARY KEY (`UserId`);

--
-- Indexes for table `WhatsappSetting`
--
ALTER TABLE `WhatsappSetting`
  ADD PRIMARY KEY (`TableId`);

--
-- AUTO_INCREMENT for dumped tables
--

--
-- AUTO_INCREMENT for table `AlarmFense`
--
ALTER TABLE `AlarmFense`
  MODIFY `TableId` bigint UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `AlarmInfo`
--
ALTER TABLE `AlarmInfo`
  MODIFY `TableId` bigint UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `AutoTestRecord`
--
ALTER TABLE `AutoTestRecord`
  MODIFY `TableId` bigint UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `BasicConfig`
--
ALTER TABLE `BasicConfig`
  MODIFY `Tabled` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `Branding`
--
ALTER TABLE `Branding`
  MODIFY `TableId` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `CarState`
--
ALTER TABLE `CarState`
  MODIFY `TableId` bigint UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `CloudAccountInfo`
--
ALTER TABLE `CloudAccountInfo`
  MODIFY `TableId` bigint UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `DeviceCommonCheckInfo`
--
ALTER TABLE `DeviceCommonCheckInfo`
  MODIFY `TableId` bigint UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `DeviceCommonCheckInfoUsers`
--
ALTER TABLE `DeviceCommonCheckInfoUsers`
  MODIFY `TableId` bigint UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `DeviceLogInfo`
--
ALTER TABLE `DeviceLogInfo`
  MODIFY `TableId` bigint UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `DeviceOnlineOfflineLog`
--
ALTER TABLE `DeviceOnlineOfflineLog`
  MODIFY `TableId` bigint UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `DeviceRecordInfo`
--
ALTER TABLE `DeviceRecordInfo`
  MODIFY `TableId` bigint UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `DeviceSession`
--
ALTER TABLE `DeviceSession`
  MODIFY `TableId` bigint NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `DriverFaceIdFileInfo`
--
ALTER TABLE `DriverFaceIdFileInfo`
  MODIFY `Tabled` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `EmailSetting`
--
ALTER TABLE `EmailSetting`
  MODIFY `Id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;

--
-- AUTO_INCREMENT for table `Groups`
--
ALTER TABLE `Groups`
  MODIFY `GroupId` int UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `login_attempts`
--
ALTER TABLE `login_attempts`
  MODIFY `id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `SecurityLog`
--
ALTER TABLE `SecurityLog`
  MODIFY `TableId` bigint UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `ServerConfigInfo`
--
ALTER TABLE `ServerConfigInfo`
  MODIFY `TableId` bigint UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `UserContactInfo`
--
ALTER TABLE `UserContactInfo`
  MODIFY `TableId` bigint UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;

--
-- AUTO_INCREMENT for table `UserCustomAlarmName`
--
ALTER TABLE `UserCustomAlarmName`
  MODIFY `ID` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `UserDeviceFaceIdFile`
--
ALTER TABLE `UserDeviceFaceIdFile`
  MODIFY `Tabled` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `UserDevices`
--
ALTER TABLE `UserDevices`
  MODIFY `Id` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `UserDriverFaceIdFileInfo`
--
ALTER TABLE `UserDriverFaceIdFileInfo`
  MODIFY `Tabled` int NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `UserOperateLog`
--
ALTER TABLE `UserOperateLog`
  MODIFY `TableId` bigint UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `Users`
--
ALTER TABLE `Users`
  MODIFY `UserId` int UNSIGNED NOT NULL AUTO_INCREMENT;

--
-- AUTO_INCREMENT for table `WhatsappSetting`
--
ALTER TABLE `WhatsappSetting`
  MODIFY `TableId` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
COMMIT;
