﻿CREATE TABLE "iot_Area" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_Area" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Name" TEXT NULL,
    "Number" TEXT NULL,
    "DisplayOrder" INTEGER NOT NULL,
    "Left" INTEGER NOT NULL,
    "Right" INTEGER NOT NULL,
    "ParentId" TEXT NULL,
    "Type" INTEGER NOT NULL,
    "CustomType" TEXT NULL,
    CONSTRAINT "FK_iot_Area_iot_Area_ParentId" FOREIGN KEY ("ParentId") REFERENCES "iot_Area" ("Id") ON DELETE RESTRICT
);

CREATE TABLE "iot_IoTGateway" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_IoTGateway" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Name" TEXT NULL,
    "Number" TEXT NOT NULL,
    "IsOnline" INTEGER NOT NULL,
    "Image" TEXT NULL,
    "Version" TEXT NULL,
    "DisplayOrder" INTEGER NOT NULL,
    "Hidden" INTEGER NOT NULL,
    "BuildingId" TEXT NULL
);

CREATE TABLE "iot_IoTProduct" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_IoTProduct" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Name" TEXT NULL,
    "Number" TEXT NOT NULL,
    "Image" TEXT NULL,
    "Path" TEXT NULL,
    "ApiJson" TEXT NULL,
    "CategoryId" TEXT NULL
);

CREATE TABLE "iot_PermissionCategory" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_PermissionCategory" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Name" TEXT NULL,
    "Number" TEXT NULL,
    "DisplayOrder" INTEGER NOT NULL,
    "Left" INTEGER NOT NULL,
    "Right" INTEGER NOT NULL,
    "ParentId" TEXT NULL,
    CONSTRAINT "FK_iot_PermissionCategory_iot_PermissionCategory_ParentId" FOREIGN KEY ("ParentId") REFERENCES "iot_PermissionCategory" ("Id") ON DELETE SET NULL
);

CREATE TABLE "iot_Role" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_Role" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Name" TEXT NOT NULL,
    "IsReadOnly" INTEGER NOT NULL
);

CREATE TABLE "iot_Setting" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_Setting" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Name" TEXT NOT NULL,
    "Value" TEXT NULL,
    "Type" INTEGER NOT NULL
);

CREATE TABLE "iot_User" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_User" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "UserName" TEXT NOT NULL,
    "NickName" TEXT NULL,
    "Avatar" TEXT NULL,
    "SecurityStamp" TEXT NULL,
    "PasswordHash" TEXT NULL,
    "Email" TEXT NULL
);

CREATE TABLE "iot_Organ" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_Organ" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Name" TEXT NULL,
    "Number" TEXT NULL,
    "DisplayOrder" INTEGER NOT NULL,
    "Left" INTEGER NOT NULL,
    "Right" INTEGER NOT NULL,
    "ParentId" TEXT NULL,
    "Type" INTEGER NOT NULL,
    "CustomType" TEXT NULL,
    "Image" TEXT NULL,
    "Description" TEXT NULL,
    "AreaId" TEXT NULL,
    "IsReadOnly" INTEGER NOT NULL,
    CONSTRAINT "FK_iot_Organ_iot_Area_AreaId" FOREIGN KEY ("AreaId") REFERENCES "iot_Area" ("Id") ON DELETE RESTRICT,
    CONSTRAINT "FK_iot_Organ_iot_Organ_ParentId" FOREIGN KEY ("ParentId") REFERENCES "iot_Organ" ("Id") ON DELETE RESTRICT
);

CREATE TABLE "iot_IoTApi" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_IoTApi" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Name" TEXT NULL,
    "Path" TEXT NULL,
    "Command" TEXT NULL,
    "Method" TEXT NULL,
    "ProductId" TEXT NOT NULL,
    CONSTRAINT "FK_iot_IoTApi_iot_IoTProduct_ProductId" FOREIGN KEY ("ProductId") REFERENCES "iot_IoTProduct" ("Id") ON DELETE CASCADE
);

CREATE TABLE "iot_IoTDevice" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_IoTDevice" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Name" TEXT NULL,
    "Number" TEXT NOT NULL,
    "Gateway" TEXT NULL,
    "DisplayName" TEXT NOT NULL,
    "Tag" TEXT NULL,
    "IsOnline" INTEGER NOT NULL,
    "Icon" TEXT NULL,
    "Ip" TEXT NULL,
    "UserName" TEXT NULL,
    "Password" TEXT NULL,
    "ConnectId" TEXT NULL,
    "DisplayOrder" INTEGER NOT NULL,
    "Disabled" INTEGER NOT NULL,
    "ProductId" TEXT NOT NULL,
    "IoTGatewayId" TEXT NOT NULL,
    CONSTRAINT "FK_iot_IoTDevice_iot_IoTGateway_IoTGatewayId" FOREIGN KEY ("IoTGatewayId") REFERENCES "iot_IoTGateway" ("Id") ON DELETE CASCADE,
    CONSTRAINT "FK_iot_IoTDevice_iot_IoTProduct_ProductId" FOREIGN KEY ("ProductId") REFERENCES "iot_IoTProduct" ("Id") ON DELETE CASCADE
);

CREATE TABLE "iot_Permission" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_Permission" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Name" TEXT NULL,
    "Number" TEXT NULL,
    "CategoryId" TEXT NULL,
    CONSTRAINT "FK_iot_Permission_iot_PermissionCategory_CategoryId" FOREIGN KEY ("CategoryId") REFERENCES "iot_PermissionCategory" ("Id") ON DELETE SET NULL
);

CREATE TABLE "iot_UserRole" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_UserRole" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "UserId" TEXT NOT NULL,
    "RoleId" TEXT NOT NULL,
    CONSTRAINT "FK_iot_UserRole_iot_Role_RoleId" FOREIGN KEY ("RoleId") REFERENCES "iot_Role" ("Id") ON DELETE CASCADE,
    CONSTRAINT "FK_iot_UserRole_iot_User_UserId" FOREIGN KEY ("UserId") REFERENCES "iot_User" ("Id") ON DELETE CASCADE
);

CREATE TABLE "iot_Department" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_Department" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Name" TEXT NULL,
    "Number" TEXT NULL,
    "DisplayOrder" INTEGER NOT NULL,
    "Left" INTEGER NOT NULL,
    "Right" INTEGER NOT NULL,
    "ParentId" TEXT NULL,
    "Type" INTEGER NOT NULL,
    "CustomType" TEXT NULL,
    "OrganId" TEXT NOT NULL,
    CONSTRAINT "FK_iot_Department_iot_Organ_OrganId" FOREIGN KEY ("OrganId") REFERENCES "iot_Organ" ("Id") ON DELETE CASCADE,
    CONSTRAINT "FK_iot_Department_iot_Department_ParentId" FOREIGN KEY ("ParentId") REFERENCES "iot_Department" ("Id") ON DELETE RESTRICT
);

CREATE TABLE "iot_IoTScene" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_IoTScene" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Name" TEXT NOT NULL,
    "Image" TEXT NOT NULL,
    "Hidden" INTEGER NOT NULL,
    "DisplayOrder" INTEGER NOT NULL,
    "BuildingId" TEXT NOT NULL,
    "OrganId" TEXT NULL,
    CONSTRAINT "FK_iot_IoTScene_iot_Organ_OrganId" FOREIGN KEY ("OrganId") REFERENCES "iot_Organ" ("Id") ON DELETE RESTRICT
);

CREATE TABLE "iot_OrganRole" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_OrganRole" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Name" TEXT NULL,
    "Number" TEXT NULL,
    "IsReadOnly" INTEGER NOT NULL,
    "OrganId" TEXT NOT NULL,
    CONSTRAINT "FK_iot_OrganRole_iot_Organ_OrganId" FOREIGN KEY ("OrganId") REFERENCES "iot_Organ" ("Id") ON DELETE CASCADE
);

CREATE TABLE "iot_OrganUser" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_OrganUser" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Type" INTEGER NOT NULL,
    "CustomType" TEXT NULL,
    "OrganId" TEXT NOT NULL,
    "UserId" TEXT NOT NULL,
    "IsDefault" INTEGER NOT NULL,
    "IsReadOnly" INTEGER NOT NULL,
    CONSTRAINT "FK_iot_OrganUser_iot_Organ_OrganId" FOREIGN KEY ("OrganId") REFERENCES "iot_Organ" ("Id") ON DELETE CASCADE
);

CREATE TABLE "iot_Title" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_Title" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Name" TEXT NULL,
    "MinLevel" INTEGER NOT NULL,
    "MaxLevel" INTEGER NOT NULL,
    "OrganId" TEXT NOT NULL,
    CONSTRAINT "FK_iot_Title_iot_Organ_OrganId" FOREIGN KEY ("OrganId") REFERENCES "iot_Organ" ("Id") ON DELETE CASCADE
);

CREATE TABLE "iot_IoTParameter" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_IoTParameter" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Type" TEXT NULL,
    "Name" TEXT NULL,
    "Description" TEXT NULL,
    "Required" INTEGER NOT NULL,
    "Maxinum" TEXT NULL,
    "Minimum" TEXT NULL,
    "ApiId" TEXT NOT NULL,
    CONSTRAINT "FK_iot_IoTParameter_iot_IoTApi_ApiId" FOREIGN KEY ("ApiId") REFERENCES "iot_IoTApi" ("Id") ON DELETE CASCADE
);

CREATE TABLE "iot_IoTCommand" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_IoTCommand" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Name" TEXT NULL,
    "DisplayOrder" INTEGER NOT NULL,
    "Disabled" INTEGER NOT NULL,
    "Delay" INTEGER NOT NULL,
    "QueryString" TEXT NULL,
    "ApiId" TEXT NOT NULL,
    "DeviceId" TEXT NOT NULL,
    CONSTRAINT "FK_iot_IoTCommand_iot_IoTApi_ApiId" FOREIGN KEY ("ApiId") REFERENCES "iot_IoTApi" ("Id") ON DELETE CASCADE,
    CONSTRAINT "FK_iot_IoTCommand_iot_IoTDevice_DeviceId" FOREIGN KEY ("DeviceId") REFERENCES "iot_IoTDevice" ("Id") ON DELETE CASCADE
);

CREATE TABLE "iot_IoTData" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_IoTData" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Key" TEXT NOT NULL,
    "Value" TEXT NULL,
    "Name" TEXT NULL,
    "Type" INTEGER NOT NULL,
    "Unit" TEXT NULL,
    "Description" TEXT NULL,
    "Timestamp" INTEGER NOT NULL,
    "Hidden" INTEGER NOT NULL,
    "DeviceId" TEXT NOT NULL,
    CONSTRAINT "FK_iot_IoTData_iot_IoTDevice_DeviceId" FOREIGN KEY ("DeviceId") REFERENCES "iot_IoTDevice" ("Id") ON DELETE CASCADE
);

CREATE TABLE "iot_RolePermission" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_RolePermission" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "RoleId" TEXT NOT NULL,
    "PermissionId" TEXT NOT NULL,
    "IsReadOnly" INTEGER NOT NULL,
    CONSTRAINT "FK_iot_RolePermission_iot_Permission_PermissionId" FOREIGN KEY ("PermissionId") REFERENCES "iot_Permission" ("Id") ON DELETE CASCADE,
    CONSTRAINT "FK_iot_RolePermission_iot_Role_RoleId" FOREIGN KEY ("RoleId") REFERENCES "iot_Role" ("Id") ON DELETE CASCADE
);

CREATE TABLE "iot_IoTTimer" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_IoTTimer" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Name" TEXT NULL,
    "Cron" TEXT NULL,
    "Disabled" INTEGER NOT NULL,
    "IoTSceneId" TEXT NOT NULL,
    CONSTRAINT "FK_iot_IoTTimer_iot_IoTScene_IoTSceneId" FOREIGN KEY ("IoTSceneId") REFERENCES "iot_IoTScene" ("Id") ON DELETE CASCADE
);

CREATE TABLE "iot_OrganRolePermission" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_OrganRolePermission" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "RoleId" TEXT NOT NULL,
    "PermissionId" TEXT NOT NULL,
    "IsReadOnly" INTEGER NOT NULL,
    CONSTRAINT "FK_iot_OrganRolePermission_iot_OrganRole_RoleId" FOREIGN KEY ("RoleId") REFERENCES "iot_OrganRole" ("Id") ON DELETE CASCADE
);

CREATE TABLE "iot_OrganUserRole" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_OrganUserRole" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "IsReadOnly" INTEGER NOT NULL,
    "OrganUserId" TEXT NOT NULL,
    "OrganRoleId" TEXT NOT NULL,
    CONSTRAINT "FK_iot_OrganUserRole_iot_OrganRole_OrganRoleId" FOREIGN KEY ("OrganRoleId") REFERENCES "iot_OrganRole" ("Id") ON DELETE CASCADE,
    CONSTRAINT "FK_iot_OrganUserRole_iot_OrganUser_OrganUserId" FOREIGN KEY ("OrganUserId") REFERENCES "iot_OrganUser" ("Id") ON DELETE CASCADE
);

CREATE TABLE "iot_Job" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_Job" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Name" TEXT NULL,
    "Level" INTEGER NOT NULL,
    "TitleId" TEXT NOT NULL,
    "DepartmentId" TEXT NOT NULL,
    CONSTRAINT "FK_iot_Job_iot_Department_DepartmentId" FOREIGN KEY ("DepartmentId") REFERENCES "iot_Department" ("Id") ON DELETE CASCADE,
    CONSTRAINT "FK_iot_Job_iot_Title_TitleId" FOREIGN KEY ("TitleId") REFERENCES "iot_Title" ("Id") ON DELETE CASCADE
);

CREATE TABLE "iot_IoTSceneIoTCommand" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_IoTSceneIoTCommand" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "IoTSceneId" TEXT NOT NULL,
    "IoTCommandId" TEXT NOT NULL,
    CONSTRAINT "FK_iot_IoTSceneIoTCommand_iot_IoTCommand_IoTCommandId" FOREIGN KEY ("IoTCommandId") REFERENCES "iot_IoTCommand" ("Id") ON DELETE CASCADE,
    CONSTRAINT "FK_iot_IoTSceneIoTCommand_iot_IoTScene_IoTSceneId" FOREIGN KEY ("IoTSceneId") REFERENCES "iot_IoTScene" ("Id") ON DELETE CASCADE
);

CREATE TABLE "iot_IoTTigger" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_IoTTigger" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Name" TEXT NULL,
    "Condition" TEXT NULL,
    "Disabled" INTEGER NOT NULL,
    "DataId" TEXT NOT NULL,
    "IoTSceneId" TEXT NOT NULL,
    CONSTRAINT "FK_iot_IoTTigger_iot_IoTData_DataId" FOREIGN KEY ("DataId") REFERENCES "iot_IoTData" ("Id") ON DELETE CASCADE,
    CONSTRAINT "FK_iot_IoTTigger_iot_IoTScene_IoTSceneId" FOREIGN KEY ("IoTSceneId") REFERENCES "iot_IoTScene" ("Id") ON DELETE CASCADE
);

CREATE TABLE "iot_DepartmentUser" (
    "Id" TEXT NOT NULL CONSTRAINT "PK_iot_DepartmentUser" PRIMARY KEY,
    "IsDeleted" TEXT NULL,
    "Position" TEXT NULL,
    "Type" INTEGER NOT NULL,
    "CustomType" TEXT NULL,
    "UserId" TEXT NOT NULL,
    "DeparementId" TEXT NOT NULL,
    "JobId" TEXT NULL,
    "DepartmentId" TEXT NULL,
    "OrganUserId" TEXT NULL,
    CONSTRAINT "FK_iot_DepartmentUser_iot_Department_DepartmentId" FOREIGN KEY ("DepartmentId") REFERENCES "iot_Department" ("Id") ON DELETE RESTRICT,
    CONSTRAINT "FK_iot_DepartmentUser_iot_Job_JobId" FOREIGN KEY ("JobId") REFERENCES "iot_Job" ("Id") ON DELETE RESTRICT,
    CONSTRAINT "FK_iot_DepartmentUser_iot_OrganUser_OrganUserId" FOREIGN KEY ("OrganUserId") REFERENCES "iot_OrganUser" ("Id") ON DELETE RESTRICT
);

CREATE INDEX "IX_iot_Area_ParentId" ON "iot_Area" ("ParentId");

CREATE INDEX "IX_iot_Department_OrganId" ON "iot_Department" ("OrganId");

CREATE INDEX "IX_iot_Department_ParentId" ON "iot_Department" ("ParentId");

CREATE INDEX "IX_iot_DepartmentUser_DepartmentId" ON "iot_DepartmentUser" ("DepartmentId");

CREATE INDEX "IX_iot_DepartmentUser_JobId" ON "iot_DepartmentUser" ("JobId");

CREATE INDEX "IX_iot_DepartmentUser_OrganUserId" ON "iot_DepartmentUser" ("OrganUserId");

CREATE UNIQUE INDEX "IX_iot_IoTApi_ProductId_Name" ON "iot_IoTApi" ("ProductId", "Name");

CREATE INDEX "IX_iot_IoTCommand_ApiId" ON "iot_IoTCommand" ("ApiId");

CREATE INDEX "IX_iot_IoTCommand_DeviceId" ON "iot_IoTCommand" ("DeviceId");

CREATE INDEX "IX_iot_IoTData_DeviceId" ON "iot_IoTData" ("DeviceId");

CREATE INDEX "IX_iot_IoTDevice_IoTGatewayId" ON "iot_IoTDevice" ("IoTGatewayId");

CREATE UNIQUE INDEX "IX_iot_IoTDevice_Number" ON "iot_IoTDevice" ("Number");

CREATE INDEX "IX_iot_IoTDevice_ProductId" ON "iot_IoTDevice" ("ProductId");

CREATE UNIQUE INDEX "IX_iot_IoTGateway_Number" ON "iot_IoTGateway" ("Number");

CREATE INDEX "IX_iot_IoTParameter_ApiId" ON "iot_IoTParameter" ("ApiId");

CREATE UNIQUE INDEX "IX_iot_IoTProduct_Number" ON "iot_IoTProduct" ("Number");

CREATE INDEX "IX_iot_IoTScene_OrganId" ON "iot_IoTScene" ("OrganId");

CREATE INDEX "IX_iot_IoTSceneIoTCommand_IoTCommandId" ON "iot_IoTSceneIoTCommand" ("IoTCommandId");

CREATE INDEX "IX_iot_IoTSceneIoTCommand_IoTSceneId" ON "iot_IoTSceneIoTCommand" ("IoTSceneId");

CREATE INDEX "IX_iot_IoTTigger_DataId" ON "iot_IoTTigger" ("DataId");

CREATE INDEX "IX_iot_IoTTigger_IoTSceneId" ON "iot_IoTTigger" ("IoTSceneId");

CREATE INDEX "IX_iot_IoTTimer_IoTSceneId" ON "iot_IoTTimer" ("IoTSceneId");

CREATE INDEX "IX_iot_Job_DepartmentId" ON "iot_Job" ("DepartmentId");

CREATE INDEX "IX_iot_Job_TitleId" ON "iot_Job" ("TitleId");

CREATE INDEX "IX_iot_Organ_AreaId" ON "iot_Organ" ("AreaId");

CREATE INDEX "IX_iot_Organ_ParentId" ON "iot_Organ" ("ParentId");

CREATE INDEX "IX_iot_OrganRole_OrganId" ON "iot_OrganRole" ("OrganId");

CREATE INDEX "IX_iot_OrganRolePermission_RoleId" ON "iot_OrganRolePermission" ("RoleId");

CREATE INDEX "IX_iot_OrganUser_OrganId" ON "iot_OrganUser" ("OrganId");

CREATE INDEX "IX_iot_OrganUserRole_OrganRoleId" ON "iot_OrganUserRole" ("OrganRoleId");

CREATE INDEX "IX_iot_OrganUserRole_OrganUserId" ON "iot_OrganUserRole" ("OrganUserId");

CREATE INDEX "IX_iot_Permission_CategoryId" ON "iot_Permission" ("CategoryId");

CREATE UNIQUE INDEX "IX_iot_Permission_Number" ON "iot_Permission" ("Number");

CREATE UNIQUE INDEX "IX_iot_PermissionCategory_Number" ON "iot_PermissionCategory" ("Number");

CREATE INDEX "IX_iot_PermissionCategory_ParentId" ON "iot_PermissionCategory" ("ParentId");

CREATE UNIQUE INDEX "IX_iot_Role_Name" ON "iot_Role" ("Name");

CREATE INDEX "IX_iot_RolePermission_PermissionId" ON "iot_RolePermission" ("PermissionId");

CREATE UNIQUE INDEX "IX_iot_RolePermission_RoleId_PermissionId" ON "iot_RolePermission" ("RoleId", "PermissionId");

CREATE UNIQUE INDEX "IX_iot_Setting_Name" ON "iot_Setting" ("Name");

CREATE INDEX "IX_iot_Title_OrganId" ON "iot_Title" ("OrganId");

CREATE UNIQUE INDEX "IX_iot_User_Email" ON "iot_User" ("Email");

CREATE UNIQUE INDEX "IX_iot_User_UserName" ON "iot_User" ("UserName");

CREATE INDEX "IX_iot_UserRole_RoleId" ON "iot_UserRole" ("RoleId");

CREATE UNIQUE INDEX "IX_iot_UserRole_UserId_RoleId" ON "iot_UserRole" ("UserId", "RoleId");

