diff --git a/IoTSharp.Data.MySQL/Migrations/20220212025925_AddTenantInfoAndToken.cs b/IoTSharp.Data.MySQL/Migrations/20220212025925_AddTenantInfoAndToken.cs deleted file mode 100644 index 6f5987d3fd3d8e1d1253a5154d6bcdddaca9af97..0000000000000000000000000000000000000000 --- a/IoTSharp.Data.MySQL/Migrations/20220212025925_AddTenantInfoAndToken.cs +++ /dev/null @@ -1,106 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace IoTSharp.Data.MySql.Migrations -{ - public partial class AddTenantInfoAndToken : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_BaseEvents_Customer_CustomerId", - table: "BaseEvents"); - - migrationBuilder.DropForeignKey( - name: "FK_BaseEvents_Tenant_TenantId", - table: "BaseEvents"); - - migrationBuilder.AlterColumn( - name: "TenantId", - table: "BaseEvents", - type: "char(36)", - nullable: true, - collation: "ascii_general_ci", - oldClrType: typeof(Guid), - oldType: "char(36)") - .OldAnnotation("Relational:Collation", "ascii_general_ci"); - - migrationBuilder.AlterColumn( - name: "CustomerId", - table: "BaseEvents", - type: "char(36)", - nullable: true, - collation: "ascii_general_ci", - oldClrType: typeof(Guid), - oldType: "char(36)") - .OldAnnotation("Relational:Collation", "ascii_general_ci"); - - migrationBuilder.AddForeignKey( - name: "FK_BaseEvents_Customer_CustomerId", - table: "BaseEvents", - column: "CustomerId", - principalTable: "Customer", - principalColumn: "Id"); - - migrationBuilder.AddForeignKey( - name: "FK_BaseEvents_Tenant_TenantId", - table: "BaseEvents", - column: "TenantId", - principalTable: "Tenant", - principalColumn: "Id"); - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropForeignKey( - name: "FK_BaseEvents_Customer_CustomerId", - table: "BaseEvents"); - - migrationBuilder.DropForeignKey( - name: "FK_BaseEvents_Tenant_TenantId", - table: "BaseEvents"); - - migrationBuilder.AlterColumn( - name: "TenantId", - table: "BaseEvents", - type: "char(36)", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - collation: "ascii_general_ci", - oldClrType: typeof(Guid), - oldType: "char(36)", - oldNullable: true) - .OldAnnotation("Relational:Collation", "ascii_general_ci"); - - migrationBuilder.AlterColumn( - name: "CustomerId", - table: "BaseEvents", - type: "char(36)", - nullable: false, - defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), - collation: "ascii_general_ci", - oldClrType: typeof(Guid), - oldType: "char(36)", - oldNullable: true) - .OldAnnotation("Relational:Collation", "ascii_general_ci"); - - migrationBuilder.AddForeignKey( - name: "FK_BaseEvents_Customer_CustomerId", - table: "BaseEvents", - column: "CustomerId", - principalTable: "Customer", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - - migrationBuilder.AddForeignKey( - name: "FK_BaseEvents_Tenant_TenantId", - table: "BaseEvents", - column: "TenantId", - principalTable: "Tenant", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - } - } -} diff --git a/IoTSharp.Data.MySQL/Migrations/20220212025925_AddTenantInfoAndToken.Designer.cs b/IoTSharp.Data.MySQL/Migrations/20220212100754_FixTenantInfo.Designer.cs similarity index 90% rename from IoTSharp.Data.MySQL/Migrations/20220212025925_AddTenantInfoAndToken.Designer.cs rename to IoTSharp.Data.MySQL/Migrations/20220212100754_FixTenantInfo.Designer.cs index 975e7a818740794cc1e7dbea5cafc82f7398f43e..f8ab5b499a0c49352523ab1a9cb426c15e882887 100644 --- a/IoTSharp.Data.MySQL/Migrations/20220212025925_AddTenantInfoAndToken.Designer.cs +++ b/IoTSharp.Data.MySQL/Migrations/20220212100754_FixTenantInfo.Designer.cs @@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace IoTSharp.Data.MySql.Migrations { [DbContext(typeof(ApplicationDbContext))] - [Migration("20220212025925_AddTenantInfoAndToken")] - partial class AddTenantInfoAndToken + [Migration("20220212100754_FixTenantInfo")] + partial class FixTenantInfo { protected override void BuildTargetModel(ModelBuilder modelBuilder) { @@ -522,7 +522,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Creator") .HasColumnType("char(36)"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("char(36)"); b.Property("DiagramDesc") @@ -534,13 +534,13 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("DiagramName") .HasColumnType("longtext"); - b.Property("DiagramStatus") + b.Property("DiagramStatus") .HasColumnType("int"); - b.Property("IsDefault") + b.Property("IsDefault") .HasColumnType("tinyint(1)"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("char(36)"); b.HasKey("DiagramId"); @@ -564,7 +564,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Creator") .HasColumnType("char(36)"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("char(36)"); b.Property("DeviceDiagramDiagramId") @@ -579,14 +579,14 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("GraphFill") .HasColumnType("longtext"); - b.Property("GraphHeight") - .HasColumnType("decimal(65,30)"); + b.Property("GraphHeight") + .HasColumnType("int"); - b.Property("GraphPostionX") - .HasColumnType("decimal(65,30)"); + b.Property("GraphPostionX") + .HasColumnType("int"); - b.Property("GraphPostionY") - .HasColumnType("decimal(65,30)"); + b.Property("GraphPostionY") + .HasColumnType("int"); b.Property("GraphShape") .HasColumnType("longtext"); @@ -594,8 +594,8 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("GraphStroke") .HasColumnType("longtext"); - b.Property("GraphStrokeWidth") - .HasColumnType("decimal(65,30)"); + b.Property("GraphStrokeWidth") + .HasColumnType("int"); b.Property("GraphTextAnchor") .HasColumnType("longtext"); @@ -606,22 +606,22 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("GraphTextFontFamily") .HasColumnType("longtext"); - b.Property("GraphTextFontSize") - .HasColumnType("decimal(65,30)"); + b.Property("GraphTextFontSize") + .HasColumnType("int"); - b.Property("GraphTextRefX") - .HasColumnType("decimal(65,30)"); + b.Property("GraphTextRefX") + .HasColumnType("int"); - b.Property("GraphTextRefY") - .HasColumnType("decimal(65,30)"); + b.Property("GraphTextRefY") + .HasColumnType("int"); b.Property("GraphTextVerticalAnchor") .HasColumnType("longtext"); - b.Property("GraphWidth") - .HasColumnType("decimal(65,30)"); + b.Property("GraphWidth") + .HasColumnType("int"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("char(36)"); b.HasKey("GraphId"); @@ -653,13 +653,13 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Creator") .HasColumnType("char(36)"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("char(36)"); - b.Property("DeviceId") + b.Property("DeviceId") .HasColumnType("bigint"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("char(36)"); b.Property("ToolBoxIcon") @@ -668,22 +668,22 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("ToolBoxName") .HasColumnType("longtext"); - b.Property("ToolBoxOffsetLeftPer") - .HasColumnType("decimal(65,30)"); + b.Property("ToolBoxOffsetLeftPer") + .HasColumnType("int"); - b.Property("ToolBoxOffsetTopPer") - .HasColumnType("decimal(65,30)"); + b.Property("ToolBoxOffsetTopPer") + .HasColumnType("int"); - b.Property("ToolBoxOffsetX") - .HasColumnType("decimal(65,30)"); + b.Property("ToolBoxOffsetX") + .HasColumnType("int"); - b.Property("ToolBoxOffsetY") - .HasColumnType("decimal(65,30)"); + b.Property("ToolBoxOffsetY") + .HasColumnType("int"); b.Property("ToolBoxRequestUri") .HasColumnType("longtext"); - b.Property("ToolBoxStatus") + b.Property("ToolBoxStatus") .HasColumnType("int"); b.Property("ToolBoxType") @@ -803,7 +803,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("CreateDate") .HasColumnType("datetime(6)"); - b.Property("Creator") + b.Property("Creator") .HasColumnType("bigint"); b.Property("DeviceId") @@ -818,16 +818,16 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("PortName") .HasColumnType("longtext"); - b.Property("PortPhyType") + b.Property("PortPhyType") .HasColumnType("int"); b.Property("PortPic") .HasColumnType("longtext"); - b.Property("PortStatus") + b.Property("PortStatus") .HasColumnType("int"); - b.Property("PortType") + b.Property("PortType") .HasColumnType("int"); b.HasKey("PortId"); @@ -847,10 +847,10 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Creator") .HasColumnType("char(36)"); - b.Property("MappingIndex") - .HasColumnType("decimal(65,30)"); + b.Property("MappingIndex") + .HasColumnType("int"); - b.Property("MappingStatus") + b.Property("MappingStatus") .HasColumnType("int"); b.Property("SourceDeviceId") @@ -915,7 +915,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Creator") .HasColumnType("char(36)"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("char(36)"); b.Property("FieldCode") @@ -930,7 +930,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("FieldI18nKey") .HasColumnType("longtext"); - b.Property("FieldMaxLength") + b.Property("FieldMaxLength") .HasColumnType("int"); b.Property("FieldName") @@ -942,10 +942,10 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("FieldPocoTypeName") .HasColumnType("longtext"); - b.Property("FieldStatus") + b.Property("FieldStatus") .HasColumnType("int"); - b.Property("FieldUIElement") + b.Property("FieldUIElement") .HasColumnType("bigint"); b.Property("FieldUIElementSchema") @@ -963,22 +963,22 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("FieldValueLocalDataSource") .HasColumnType("longtext"); - b.Property("FieldValueType") + b.Property("FieldValueType") .HasColumnType("int"); b.Property("FieldValueTypeName") .HasColumnType("longtext"); - b.Property("FormId") + b.Property("FormId") .HasColumnType("bigint"); - b.Property("IsEnabled") + b.Property("IsEnabled") .HasColumnType("tinyint(1)"); - b.Property("IsRequired") + b.Property("IsRequired") .HasColumnType("tinyint(1)"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("char(36)"); b.HasKey("FieldId"); @@ -996,13 +996,13 @@ namespace IoTSharp.Data.MySql.Migrations .ValueGeneratedOnAdd() .HasColumnType("bigint"); - b.Property("BizId") + b.Property("BizId") .HasColumnType("bigint"); b.Property("Creator") .HasColumnType("char(36)"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("char(36)"); b.Property("FieldCode") @@ -1011,7 +1011,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("FieldCreateDate") .HasColumnType("datetime(6)"); - b.Property("FieldId") + b.Property("FieldId") .HasColumnType("bigint"); b.Property("FieldName") @@ -1023,13 +1023,13 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("FieldValue") .HasColumnType("longtext"); - b.Property("FieldValueType") + b.Property("FieldValueType") .HasColumnType("bigint"); - b.Property("FromId") + b.Property("FromId") .HasColumnType("bigint"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("char(36)"); b.HasKey("FieldValueId"); @@ -1047,16 +1047,16 @@ namespace IoTSharp.Data.MySql.Migrations .ValueGeneratedOnAdd() .HasColumnType("bigint"); - b.Property("BizId") + b.Property("BizId") .HasColumnType("bigint"); b.Property("Creator") .HasColumnType("char(36)"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("char(36)"); - b.Property("FormCreator") + b.Property("FormCreator") .HasColumnType("bigint"); b.Property("FormDesc") @@ -1071,7 +1071,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("FormSchame") .HasColumnType("longtext"); - b.Property("FormStatus") + b.Property("FormStatus") .HasColumnType("int"); b.Property("FromCreateDate") @@ -1083,7 +1083,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("ModelClass") .HasColumnType("longtext"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("char(36)"); b.Property("Url") @@ -1116,7 +1116,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Createor") .HasColumnType("char(36)"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("char(36)"); b.Property("ExecutorId") @@ -1170,7 +1170,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("TargetId") .HasColumnType("longtext"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("char(36)"); b.Property("TestStatus") @@ -1207,7 +1207,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("AddDate") .HasColumnType("datetime(6)"); - b.Property("BaseEventId") + b.Property("BaseEventEventId") .HasColumnType("char(36)"); b.Property("BizId") @@ -1216,13 +1216,13 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Data") .HasColumnType("longtext"); - b.Property("FlowId") + b.Property("FlowId") .HasColumnType("char(36)"); - b.Property("FlowRuleId") + b.Property("FlowRuleRuleId") .HasColumnType("char(36)"); - b.Property("NodeStatus") + b.Property("NodeStatus") .HasColumnType("int"); b.Property("OperationDesc") @@ -1239,11 +1239,11 @@ namespace IoTSharp.Data.MySql.Migrations b.HasKey("OperationId"); - b.HasIndex("BaseEventId"); + b.HasIndex("BaseEventEventId"); b.HasIndex("FlowId"); - b.HasIndex("FlowRuleId"); + b.HasIndex("FlowRuleRuleId"); b.ToTable("FlowOperations"); }); @@ -1263,7 +1263,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Creator") .HasColumnType("longtext"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("char(36)"); b.Property("DefinitionsXml") @@ -1300,7 +1300,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("SubVersion") .HasColumnType("double"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("char(36)"); b.Property("Version") @@ -1387,7 +1387,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Creator") .HasColumnType("char(36)"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("char(36)"); b.Property("DefaultConfig") @@ -1411,7 +1411,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Tag") .HasColumnType("longtext"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("char(36)"); b.Property("TestStatus") @@ -1447,7 +1447,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Creator") .HasColumnType("char(36)"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("char(36)"); b.Property("EventDesc") @@ -1468,7 +1468,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("EventTag") .HasColumnType("longtext"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("char(36)"); b.Property("Type") @@ -1916,15 +1916,11 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -1935,9 +1931,7 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.DeviceDiagram", "DeviceDiagram") .WithMany() @@ -1945,9 +1939,7 @@ namespace IoTSharp.Data.MySql.Migrations b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -1960,15 +1952,11 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2016,15 +2004,11 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2035,15 +2019,11 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2054,15 +2034,11 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2073,9 +2049,7 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.RuleTaskExecutor", "Executor") .WithMany() @@ -2087,9 +2061,7 @@ namespace IoTSharp.Data.MySql.Migrations b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2104,21 +2076,15 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.BaseEvent", "BaseEvent") .WithMany() - .HasForeignKey("BaseEventId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("BaseEventEventId"); b.HasOne("IoTSharp.Data.Flow", "Flow") .WithMany() - .HasForeignKey("FlowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("FlowId"); b.HasOne("IoTSharp.Data.FlowRule", "FlowRule") .WithMany() - .HasForeignKey("FlowRuleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("FlowRuleRuleId"); b.Navigation("BaseEvent"); @@ -2131,15 +2097,11 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2180,15 +2142,11 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2199,15 +2157,11 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); diff --git a/IoTSharp.Data.MySQL/Migrations/20220212100754_FixTenantInfo.cs b/IoTSharp.Data.MySQL/Migrations/20220212100754_FixTenantInfo.cs new file mode 100644 index 0000000000000000000000000000000000000000..9b8527ca0fdbe14ab721d0fdbefa8dc06a0a34a8 --- /dev/null +++ b/IoTSharp.Data.MySQL/Migrations/20220212100754_FixTenantInfo.cs @@ -0,0 +1,1894 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace IoTSharp.Data.MySql.Migrations +{ + public partial class FixTenantInfo : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_DeviceIdentities_Device_DeviceId", + table: "DeviceIdentities"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_BaseEvents_BaseEventId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_FlowRules_FlowRuleId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_Flows_FlowId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_SubscriptionTasks_Customer_CustomerId", + table: "SubscriptionTasks"); + + migrationBuilder.DropIndex( + name: "IX_SubscriptionTasks_CustomerId", + table: "SubscriptionTasks"); + + migrationBuilder.DropIndex( + name: "IX_FlowOperations_BaseEventId", + table: "FlowOperations"); + + migrationBuilder.DropIndex( + name: "IX_FlowOperations_FlowRuleId", + table: "FlowOperations"); + + migrationBuilder.DropIndex( + name: "IX_DeviceIdentities_DeviceId", + table: "DeviceIdentities"); + + migrationBuilder.DropColumn( + name: "CustomerId", + table: "SubscriptionTasks"); + + migrationBuilder.DropColumn( + name: "BaseEventId", + table: "FlowOperations"); + + migrationBuilder.DropColumn( + name: "FlowRuleId", + table: "FlowOperations"); + + migrationBuilder.AlterColumn( + name: "Type", + table: "TelemetryData", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("Relational:ColumnOrder", 5); + + migrationBuilder.AlterColumn( + name: "DataSide", + table: "TelemetryData", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("Relational:ColumnOrder", 4); + + migrationBuilder.AlterColumn( + name: "DateTime", + table: "TelemetryData", + type: "timestamp", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp") + .Annotation("Relational:ColumnOrder", 3); + + migrationBuilder.AlterColumn( + name: "KeyName", + table: "TelemetryData", + type: "varchar(255)", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)") + .Annotation("MySql:CharSet", "utf8mb4") + .Annotation("Relational:ColumnOrder", 2) + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "DeviceId", + table: "TelemetryData", + type: "char(36)", + nullable: false, + collation: "ascii_general_ci", + oldClrType: typeof(Guid), + oldType: "char(36)") + .Annotation("Relational:ColumnOrder", 1) + .OldAnnotation("Relational:Collation", "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "CustomerId", + table: "SubscriptionEvents", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TenantId", + table: "SubscriptionEvents", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "CustomerId", + table: "RuleTaskExecutors", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TenantId", + table: "RuleTaskExecutors", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "CustomerId", + table: "Flows", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TenantId", + table: "Flows", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "CustomerId", + table: "FlowRules", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TenantId", + table: "FlowRules", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "Version", + table: "FlowRules", + type: "double", + nullable: false, + defaultValue: 0.0); + + migrationBuilder.AlterColumn( + name: "NodeStatus", + table: "FlowOperations", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FlowId", + table: "FlowOperations", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci", + oldClrType: typeof(Guid), + oldType: "char(36)") + .OldAnnotation("Relational:Collation", "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "BaseEventEventId", + table: "FlowOperations", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "FlowRuleRuleId", + table: "FlowOperations", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AlterColumn( + name: "FormStatus", + table: "DynamicFormInfos", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FormCreator", + table: "DynamicFormInfos", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "BizId", + table: "DynamicFormInfos", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AddColumn( + name: "CustomerId", + table: "DynamicFormInfos", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TenantId", + table: "DynamicFormInfos", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AlterColumn( + name: "FromId", + table: "DynamicFormFieldValueInfos", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FieldValueType", + table: "DynamicFormFieldValueInfos", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FieldId", + table: "DynamicFormFieldValueInfos", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "BizId", + table: "DynamicFormFieldValueInfos", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AddColumn( + name: "CustomerId", + table: "DynamicFormFieldValueInfos", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TenantId", + table: "DynamicFormFieldValueInfos", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AlterColumn( + name: "IsRequired", + table: "DynamicFormFieldInfos", + type: "tinyint(1)", + nullable: false, + defaultValue: false, + oldClrType: typeof(bool), + oldType: "tinyint(1)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "IsEnabled", + table: "DynamicFormFieldInfos", + type: "tinyint(1)", + nullable: false, + defaultValue: false, + oldClrType: typeof(bool), + oldType: "tinyint(1)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FormId", + table: "DynamicFormFieldInfos", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FieldValueType", + table: "DynamicFormFieldInfos", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FieldUIElement", + table: "DynamicFormFieldInfos", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FieldStatus", + table: "DynamicFormFieldInfos", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FieldMaxLength", + table: "DynamicFormFieldInfos", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AddColumn( + name: "CustomerId", + table: "DynamicFormFieldInfos", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TenantId", + table: "DynamicFormFieldInfos", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AlterColumn( + name: "PortType", + table: "DevicePorts", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "PortStatus", + table: "DevicePorts", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "PortPhyType", + table: "DevicePorts", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Creator", + table: "DevicePorts", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MappingStatus", + table: "DevicePortMappings", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MappingIndex", + table: "DevicePortMappings", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "decimal(65,30)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeviceId", + table: "DeviceIdentities", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci", + oldClrType: typeof(Guid), + oldType: "char(36)", + oldNullable: true) + .OldAnnotation("Relational:Collation", "ascii_general_ci"); + + migrationBuilder.AlterColumn( + name: "ToolBoxStatus", + table: "DeviceGraphToolBoxes", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetY", + table: "DeviceGraphToolBoxes", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "decimal(65,30)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetX", + table: "DeviceGraphToolBoxes", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "decimal(65,30)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetTopPer", + table: "DeviceGraphToolBoxes", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "decimal(65,30)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetLeftPer", + table: "DeviceGraphToolBoxes", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "decimal(65,30)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeviceId", + table: "DeviceGraphToolBoxes", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AddColumn( + name: "CustomerId", + table: "DeviceGraphToolBoxes", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TenantId", + table: "DeviceGraphToolBoxes", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AlterColumn( + name: "GraphWidth", + table: "DeviceGraphs", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "decimal(65,30)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphTextRefY", + table: "DeviceGraphs", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "decimal(65,30)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphTextRefX", + table: "DeviceGraphs", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "decimal(65,30)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphTextFontSize", + table: "DeviceGraphs", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "decimal(65,30)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphStrokeWidth", + table: "DeviceGraphs", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "decimal(65,30)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphPostionY", + table: "DeviceGraphs", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "decimal(65,30)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphPostionX", + table: "DeviceGraphs", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "decimal(65,30)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphHeight", + table: "DeviceGraphs", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "decimal(65,30)", + oldNullable: true); + + migrationBuilder.AddColumn( + name: "CustomerId", + table: "DeviceGraphs", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TenantId", + table: "DeviceGraphs", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AlterColumn( + name: "IsDefault", + table: "DeviceDiagrams", + type: "tinyint(1)", + nullable: false, + defaultValue: false, + oldClrType: typeof(bool), + oldType: "tinyint(1)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DiagramStatus", + table: "DeviceDiagrams", + type: "int", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "int", + oldNullable: true); + + migrationBuilder.AddColumn( + name: "CustomerId", + table: "DeviceDiagrams", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TenantId", + table: "DeviceDiagrams", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AlterColumn( + name: "Type", + table: "DataStorage", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("Relational:ColumnOrder", 5); + + migrationBuilder.AlterColumn( + name: "DateTime", + table: "DataStorage", + type: "timestamp", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp") + .Annotation("Relational:ColumnOrder", 3); + + migrationBuilder.AlterColumn( + name: "DataSide", + table: "DataStorage", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("Relational:ColumnOrder", 4); + + migrationBuilder.AlterColumn( + name: "KeyName", + table: "DataStorage", + type: "varchar(255)", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)") + .Annotation("MySql:CharSet", "utf8mb4") + .Annotation("Relational:ColumnOrder", 2) + .OldAnnotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.AlterColumn( + name: "DeviceId", + table: "DataStorage", + type: "char(36)", + nullable: false, + collation: "ascii_general_ci", + oldClrType: typeof(Guid), + oldType: "char(36)") + .Annotation("Relational:ColumnOrder", 1) + .OldAnnotation("Relational:Collation", "ascii_general_ci"); + + migrationBuilder.AlterColumn( + name: "Catalog", + table: "DataStorage", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .Annotation("Relational:ColumnOrder", 0); + + migrationBuilder.AddColumn( + name: "CustomerId", + table: "BaseEvents", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "TenantId", + table: "BaseEvents", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci"); + + migrationBuilder.CreateTable( + name: "RefreshTokens", + columns: table => new + { + Id = table.Column(type: "char(36)", nullable: false, collation: "ascii_general_ci"), + UserId = table.Column(type: "varchar(255)", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + Token = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + JwtId = table.Column(type: "longtext", nullable: true) + .Annotation("MySql:CharSet", "utf8mb4"), + IsUsed = table.Column(type: "tinyint(1)", nullable: false), + IsRevorked = table.Column(type: "tinyint(1)", nullable: false), + AddedDate = table.Column(type: "datetime(6)", nullable: false), + ExpiryDate = table.Column(type: "datetime(6)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RefreshTokens", x => x.Id); + table.ForeignKey( + name: "FK_RefreshTokens_AspNetUsers_UserId", + column: x => x.UserId, + principalTable: "AspNetUsers", + principalColumn: "Id"); + }) + .Annotation("MySql:CharSet", "utf8mb4"); + + migrationBuilder.CreateIndex( + name: "IX_SubscriptionEvents_CustomerId", + table: "SubscriptionEvents", + column: "CustomerId"); + + migrationBuilder.CreateIndex( + name: "IX_SubscriptionEvents_TenantId", + table: "SubscriptionEvents", + column: "TenantId"); + + migrationBuilder.CreateIndex( + name: "IX_RuleTaskExecutors_CustomerId", + table: "RuleTaskExecutors", + column: "CustomerId"); + + migrationBuilder.CreateIndex( + name: "IX_RuleTaskExecutors_TenantId", + table: "RuleTaskExecutors", + column: "TenantId"); + + migrationBuilder.CreateIndex( + name: "IX_Flows_CustomerId", + table: "Flows", + column: "CustomerId"); + + migrationBuilder.CreateIndex( + name: "IX_Flows_TenantId", + table: "Flows", + column: "TenantId"); + + migrationBuilder.CreateIndex( + name: "IX_FlowRules_CustomerId", + table: "FlowRules", + column: "CustomerId"); + + migrationBuilder.CreateIndex( + name: "IX_FlowRules_TenantId", + table: "FlowRules", + column: "TenantId"); + + migrationBuilder.CreateIndex( + name: "IX_FlowOperations_BaseEventEventId", + table: "FlowOperations", + column: "BaseEventEventId"); + + migrationBuilder.CreateIndex( + name: "IX_FlowOperations_FlowRuleRuleId", + table: "FlowOperations", + column: "FlowRuleRuleId"); + + migrationBuilder.CreateIndex( + name: "IX_DynamicFormInfos_CustomerId", + table: "DynamicFormInfos", + column: "CustomerId"); + + migrationBuilder.CreateIndex( + name: "IX_DynamicFormInfos_TenantId", + table: "DynamicFormInfos", + column: "TenantId"); + + migrationBuilder.CreateIndex( + name: "IX_DynamicFormFieldValueInfos_CustomerId", + table: "DynamicFormFieldValueInfos", + column: "CustomerId"); + + migrationBuilder.CreateIndex( + name: "IX_DynamicFormFieldValueInfos_TenantId", + table: "DynamicFormFieldValueInfos", + column: "TenantId"); + + migrationBuilder.CreateIndex( + name: "IX_DynamicFormFieldInfos_CustomerId", + table: "DynamicFormFieldInfos", + column: "CustomerId"); + + migrationBuilder.CreateIndex( + name: "IX_DynamicFormFieldInfos_TenantId", + table: "DynamicFormFieldInfos", + column: "TenantId"); + + migrationBuilder.CreateIndex( + name: "IX_DeviceIdentities_DeviceId", + table: "DeviceIdentities", + column: "DeviceId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_DeviceGraphToolBoxes_CustomerId", + table: "DeviceGraphToolBoxes", + column: "CustomerId"); + + migrationBuilder.CreateIndex( + name: "IX_DeviceGraphToolBoxes_TenantId", + table: "DeviceGraphToolBoxes", + column: "TenantId"); + + migrationBuilder.CreateIndex( + name: "IX_DeviceGraphs_CustomerId", + table: "DeviceGraphs", + column: "CustomerId"); + + migrationBuilder.CreateIndex( + name: "IX_DeviceGraphs_TenantId", + table: "DeviceGraphs", + column: "TenantId"); + + migrationBuilder.CreateIndex( + name: "IX_DeviceDiagrams_CustomerId", + table: "DeviceDiagrams", + column: "CustomerId"); + + migrationBuilder.CreateIndex( + name: "IX_DeviceDiagrams_TenantId", + table: "DeviceDiagrams", + column: "TenantId"); + + migrationBuilder.CreateIndex( + name: "IX_BaseEvents_CustomerId", + table: "BaseEvents", + column: "CustomerId"); + + migrationBuilder.CreateIndex( + name: "IX_BaseEvents_TenantId", + table: "BaseEvents", + column: "TenantId"); + + migrationBuilder.CreateIndex( + name: "IX_RefreshTokens_UserId", + table: "RefreshTokens", + column: "UserId"); + + migrationBuilder.AddForeignKey( + name: "FK_BaseEvents_Customer_CustomerId", + table: "BaseEvents", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_BaseEvents_Tenant_TenantId", + table: "BaseEvents", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceDiagrams_Customer_CustomerId", + table: "DeviceDiagrams", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceDiagrams_Tenant_TenantId", + table: "DeviceDiagrams", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceGraphs_Customer_CustomerId", + table: "DeviceGraphs", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceGraphs_Tenant_TenantId", + table: "DeviceGraphs", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceGraphToolBoxes_Customer_CustomerId", + table: "DeviceGraphToolBoxes", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceGraphToolBoxes_Tenant_TenantId", + table: "DeviceGraphToolBoxes", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceIdentities_Device_DeviceId", + table: "DeviceIdentities", + column: "DeviceId", + principalTable: "Device", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormFieldInfos_Customer_CustomerId", + table: "DynamicFormFieldInfos", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormFieldInfos_Tenant_TenantId", + table: "DynamicFormFieldInfos", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormFieldValueInfos_Customer_CustomerId", + table: "DynamicFormFieldValueInfos", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormFieldValueInfos_Tenant_TenantId", + table: "DynamicFormFieldValueInfos", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormInfos_Customer_CustomerId", + table: "DynamicFormInfos", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormInfos_Tenant_TenantId", + table: "DynamicFormInfos", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_BaseEvents_BaseEventEventId", + table: "FlowOperations", + column: "BaseEventEventId", + principalTable: "BaseEvents", + principalColumn: "EventId"); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_FlowRules_FlowRuleRuleId", + table: "FlowOperations", + column: "FlowRuleRuleId", + principalTable: "FlowRules", + principalColumn: "RuleId"); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_Flows_FlowId", + table: "FlowOperations", + column: "FlowId", + principalTable: "Flows", + principalColumn: "FlowId"); + + migrationBuilder.AddForeignKey( + name: "FK_FlowRules_Customer_CustomerId", + table: "FlowRules", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_FlowRules_Tenant_TenantId", + table: "FlowRules", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Flows_Customer_CustomerId", + table: "Flows", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Flows_Tenant_TenantId", + table: "Flows", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_RuleTaskExecutors_Customer_CustomerId", + table: "RuleTaskExecutors", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_RuleTaskExecutors_Tenant_TenantId", + table: "RuleTaskExecutors", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_SubscriptionEvents_Customer_CustomerId", + table: "SubscriptionEvents", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_SubscriptionEvents_Tenant_TenantId", + table: "SubscriptionEvents", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_BaseEvents_Customer_CustomerId", + table: "BaseEvents"); + + migrationBuilder.DropForeignKey( + name: "FK_BaseEvents_Tenant_TenantId", + table: "BaseEvents"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceDiagrams_Customer_CustomerId", + table: "DeviceDiagrams"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceDiagrams_Tenant_TenantId", + table: "DeviceDiagrams"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceGraphs_Customer_CustomerId", + table: "DeviceGraphs"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceGraphs_Tenant_TenantId", + table: "DeviceGraphs"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceGraphToolBoxes_Customer_CustomerId", + table: "DeviceGraphToolBoxes"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceGraphToolBoxes_Tenant_TenantId", + table: "DeviceGraphToolBoxes"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceIdentities_Device_DeviceId", + table: "DeviceIdentities"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormFieldInfos_Customer_CustomerId", + table: "DynamicFormFieldInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormFieldInfos_Tenant_TenantId", + table: "DynamicFormFieldInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormFieldValueInfos_Customer_CustomerId", + table: "DynamicFormFieldValueInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormFieldValueInfos_Tenant_TenantId", + table: "DynamicFormFieldValueInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormInfos_Customer_CustomerId", + table: "DynamicFormInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormInfos_Tenant_TenantId", + table: "DynamicFormInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_BaseEvents_BaseEventEventId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_FlowRules_FlowRuleRuleId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_Flows_FlowId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowRules_Customer_CustomerId", + table: "FlowRules"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowRules_Tenant_TenantId", + table: "FlowRules"); + + migrationBuilder.DropForeignKey( + name: "FK_Flows_Customer_CustomerId", + table: "Flows"); + + migrationBuilder.DropForeignKey( + name: "FK_Flows_Tenant_TenantId", + table: "Flows"); + + migrationBuilder.DropForeignKey( + name: "FK_RuleTaskExecutors_Customer_CustomerId", + table: "RuleTaskExecutors"); + + migrationBuilder.DropForeignKey( + name: "FK_RuleTaskExecutors_Tenant_TenantId", + table: "RuleTaskExecutors"); + + migrationBuilder.DropForeignKey( + name: "FK_SubscriptionEvents_Customer_CustomerId", + table: "SubscriptionEvents"); + + migrationBuilder.DropForeignKey( + name: "FK_SubscriptionEvents_Tenant_TenantId", + table: "SubscriptionEvents"); + + migrationBuilder.DropTable( + name: "RefreshTokens"); + + migrationBuilder.DropIndex( + name: "IX_SubscriptionEvents_CustomerId", + table: "SubscriptionEvents"); + + migrationBuilder.DropIndex( + name: "IX_SubscriptionEvents_TenantId", + table: "SubscriptionEvents"); + + migrationBuilder.DropIndex( + name: "IX_RuleTaskExecutors_CustomerId", + table: "RuleTaskExecutors"); + + migrationBuilder.DropIndex( + name: "IX_RuleTaskExecutors_TenantId", + table: "RuleTaskExecutors"); + + migrationBuilder.DropIndex( + name: "IX_Flows_CustomerId", + table: "Flows"); + + migrationBuilder.DropIndex( + name: "IX_Flows_TenantId", + table: "Flows"); + + migrationBuilder.DropIndex( + name: "IX_FlowRules_CustomerId", + table: "FlowRules"); + + migrationBuilder.DropIndex( + name: "IX_FlowRules_TenantId", + table: "FlowRules"); + + migrationBuilder.DropIndex( + name: "IX_FlowOperations_BaseEventEventId", + table: "FlowOperations"); + + migrationBuilder.DropIndex( + name: "IX_FlowOperations_FlowRuleRuleId", + table: "FlowOperations"); + + migrationBuilder.DropIndex( + name: "IX_DynamicFormInfos_CustomerId", + table: "DynamicFormInfos"); + + migrationBuilder.DropIndex( + name: "IX_DynamicFormInfos_TenantId", + table: "DynamicFormInfos"); + + migrationBuilder.DropIndex( + name: "IX_DynamicFormFieldValueInfos_CustomerId", + table: "DynamicFormFieldValueInfos"); + + migrationBuilder.DropIndex( + name: "IX_DynamicFormFieldValueInfos_TenantId", + table: "DynamicFormFieldValueInfos"); + + migrationBuilder.DropIndex( + name: "IX_DynamicFormFieldInfos_CustomerId", + table: "DynamicFormFieldInfos"); + + migrationBuilder.DropIndex( + name: "IX_DynamicFormFieldInfos_TenantId", + table: "DynamicFormFieldInfos"); + + migrationBuilder.DropIndex( + name: "IX_DeviceIdentities_DeviceId", + table: "DeviceIdentities"); + + migrationBuilder.DropIndex( + name: "IX_DeviceGraphToolBoxes_CustomerId", + table: "DeviceGraphToolBoxes"); + + migrationBuilder.DropIndex( + name: "IX_DeviceGraphToolBoxes_TenantId", + table: "DeviceGraphToolBoxes"); + + migrationBuilder.DropIndex( + name: "IX_DeviceGraphs_CustomerId", + table: "DeviceGraphs"); + + migrationBuilder.DropIndex( + name: "IX_DeviceGraphs_TenantId", + table: "DeviceGraphs"); + + migrationBuilder.DropIndex( + name: "IX_DeviceDiagrams_CustomerId", + table: "DeviceDiagrams"); + + migrationBuilder.DropIndex( + name: "IX_DeviceDiagrams_TenantId", + table: "DeviceDiagrams"); + + migrationBuilder.DropIndex( + name: "IX_BaseEvents_CustomerId", + table: "BaseEvents"); + + migrationBuilder.DropIndex( + name: "IX_BaseEvents_TenantId", + table: "BaseEvents"); + + migrationBuilder.DropColumn( + name: "CustomerId", + table: "SubscriptionEvents"); + + migrationBuilder.DropColumn( + name: "TenantId", + table: "SubscriptionEvents"); + + migrationBuilder.DropColumn( + name: "CustomerId", + table: "RuleTaskExecutors"); + + migrationBuilder.DropColumn( + name: "TenantId", + table: "RuleTaskExecutors"); + + migrationBuilder.DropColumn( + name: "CustomerId", + table: "Flows"); + + migrationBuilder.DropColumn( + name: "TenantId", + table: "Flows"); + + migrationBuilder.DropColumn( + name: "CustomerId", + table: "FlowRules"); + + migrationBuilder.DropColumn( + name: "TenantId", + table: "FlowRules"); + + migrationBuilder.DropColumn( + name: "Version", + table: "FlowRules"); + + migrationBuilder.DropColumn( + name: "BaseEventEventId", + table: "FlowOperations"); + + migrationBuilder.DropColumn( + name: "FlowRuleRuleId", + table: "FlowOperations"); + + migrationBuilder.DropColumn( + name: "CustomerId", + table: "DynamicFormInfos"); + + migrationBuilder.DropColumn( + name: "TenantId", + table: "DynamicFormInfos"); + + migrationBuilder.DropColumn( + name: "CustomerId", + table: "DynamicFormFieldValueInfos"); + + migrationBuilder.DropColumn( + name: "TenantId", + table: "DynamicFormFieldValueInfos"); + + migrationBuilder.DropColumn( + name: "CustomerId", + table: "DynamicFormFieldInfos"); + + migrationBuilder.DropColumn( + name: "TenantId", + table: "DynamicFormFieldInfos"); + + migrationBuilder.DropColumn( + name: "CustomerId", + table: "DeviceGraphToolBoxes"); + + migrationBuilder.DropColumn( + name: "TenantId", + table: "DeviceGraphToolBoxes"); + + migrationBuilder.DropColumn( + name: "CustomerId", + table: "DeviceGraphs"); + + migrationBuilder.DropColumn( + name: "TenantId", + table: "DeviceGraphs"); + + migrationBuilder.DropColumn( + name: "CustomerId", + table: "DeviceDiagrams"); + + migrationBuilder.DropColumn( + name: "TenantId", + table: "DeviceDiagrams"); + + migrationBuilder.DropColumn( + name: "CustomerId", + table: "BaseEvents"); + + migrationBuilder.DropColumn( + name: "TenantId", + table: "BaseEvents"); + + migrationBuilder.AlterColumn( + name: "Type", + table: "TelemetryData", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("Relational:ColumnOrder", 5); + + migrationBuilder.AlterColumn( + name: "DataSide", + table: "TelemetryData", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("Relational:ColumnOrder", 4); + + migrationBuilder.AlterColumn( + name: "DateTime", + table: "TelemetryData", + type: "timestamp", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp") + .OldAnnotation("Relational:ColumnOrder", 3); + + migrationBuilder.AlterColumn( + name: "KeyName", + table: "TelemetryData", + type: "varchar(255)", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("Relational:ColumnOrder", 2); + + migrationBuilder.AlterColumn( + name: "DeviceId", + table: "TelemetryData", + type: "char(36)", + nullable: false, + collation: "ascii_general_ci", + oldClrType: typeof(Guid), + oldType: "char(36)") + .OldAnnotation("Relational:Collation", "ascii_general_ci") + .OldAnnotation("Relational:ColumnOrder", 1); + + migrationBuilder.AddColumn( + name: "CustomerId", + table: "SubscriptionTasks", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AlterColumn( + name: "NodeStatus", + table: "FlowOperations", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "FlowId", + table: "FlowOperations", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci", + oldClrType: typeof(Guid), + oldType: "char(36)", + oldNullable: true) + .OldAnnotation("Relational:Collation", "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "BaseEventId", + table: "FlowOperations", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AddColumn( + name: "FlowRuleId", + table: "FlowOperations", + type: "char(36)", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + collation: "ascii_general_ci"); + + migrationBuilder.AlterColumn( + name: "FormStatus", + table: "DynamicFormInfos", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "FormCreator", + table: "DynamicFormInfos", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "BizId", + table: "DynamicFormInfos", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "FromId", + table: "DynamicFormFieldValueInfos", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "FieldValueType", + table: "DynamicFormFieldValueInfos", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "FieldId", + table: "DynamicFormFieldValueInfos", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "BizId", + table: "DynamicFormFieldValueInfos", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "IsRequired", + table: "DynamicFormFieldInfos", + type: "tinyint(1)", + nullable: true, + oldClrType: typeof(bool), + oldType: "tinyint(1)"); + + migrationBuilder.AlterColumn( + name: "IsEnabled", + table: "DynamicFormFieldInfos", + type: "tinyint(1)", + nullable: true, + oldClrType: typeof(bool), + oldType: "tinyint(1)"); + + migrationBuilder.AlterColumn( + name: "FormId", + table: "DynamicFormFieldInfos", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "FieldValueType", + table: "DynamicFormFieldInfos", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "FieldUIElement", + table: "DynamicFormFieldInfos", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "FieldStatus", + table: "DynamicFormFieldInfos", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "FieldMaxLength", + table: "DynamicFormFieldInfos", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "PortType", + table: "DevicePorts", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "PortStatus", + table: "DevicePorts", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "PortPhyType", + table: "DevicePorts", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "Creator", + table: "DevicePorts", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "MappingStatus", + table: "DevicePortMappings", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "MappingIndex", + table: "DevicePortMappings", + type: "decimal(65,30)", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "DeviceId", + table: "DeviceIdentities", + type: "char(36)", + nullable: true, + collation: "ascii_general_ci", + oldClrType: typeof(Guid), + oldType: "char(36)") + .OldAnnotation("Relational:Collation", "ascii_general_ci"); + + migrationBuilder.AlterColumn( + name: "ToolBoxStatus", + table: "DeviceGraphToolBoxes", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetY", + table: "DeviceGraphToolBoxes", + type: "decimal(65,30)", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetX", + table: "DeviceGraphToolBoxes", + type: "decimal(65,30)", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetTopPer", + table: "DeviceGraphToolBoxes", + type: "decimal(65,30)", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetLeftPer", + table: "DeviceGraphToolBoxes", + type: "decimal(65,30)", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "DeviceId", + table: "DeviceGraphToolBoxes", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "GraphWidth", + table: "DeviceGraphs", + type: "decimal(65,30)", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "GraphTextRefY", + table: "DeviceGraphs", + type: "decimal(65,30)", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "GraphTextRefX", + table: "DeviceGraphs", + type: "decimal(65,30)", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "GraphTextFontSize", + table: "DeviceGraphs", + type: "decimal(65,30)", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "GraphStrokeWidth", + table: "DeviceGraphs", + type: "decimal(65,30)", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "GraphPostionY", + table: "DeviceGraphs", + type: "decimal(65,30)", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "GraphPostionX", + table: "DeviceGraphs", + type: "decimal(65,30)", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "GraphHeight", + table: "DeviceGraphs", + type: "decimal(65,30)", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "IsDefault", + table: "DeviceDiagrams", + type: "tinyint(1)", + nullable: true, + oldClrType: typeof(bool), + oldType: "tinyint(1)"); + + migrationBuilder.AlterColumn( + name: "DiagramStatus", + table: "DeviceDiagrams", + type: "int", + nullable: true, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "Type", + table: "DataStorage", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("Relational:ColumnOrder", 5); + + migrationBuilder.AlterColumn( + name: "DateTime", + table: "DataStorage", + type: "timestamp", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "timestamp") + .OldAnnotation("Relational:ColumnOrder", 3); + + migrationBuilder.AlterColumn( + name: "DataSide", + table: "DataStorage", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("Relational:ColumnOrder", 4); + + migrationBuilder.AlterColumn( + name: "KeyName", + table: "DataStorage", + type: "varchar(255)", + nullable: false, + oldClrType: typeof(string), + oldType: "varchar(255)") + .Annotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("MySql:CharSet", "utf8mb4") + .OldAnnotation("Relational:ColumnOrder", 2); + + migrationBuilder.AlterColumn( + name: "DeviceId", + table: "DataStorage", + type: "char(36)", + nullable: false, + collation: "ascii_general_ci", + oldClrType: typeof(Guid), + oldType: "char(36)") + .OldAnnotation("Relational:Collation", "ascii_general_ci") + .OldAnnotation("Relational:ColumnOrder", 1); + + migrationBuilder.AlterColumn( + name: "Catalog", + table: "DataStorage", + type: "int", + nullable: false, + oldClrType: typeof(int), + oldType: "int") + .OldAnnotation("Relational:ColumnOrder", 0); + + migrationBuilder.CreateIndex( + name: "IX_SubscriptionTasks_CustomerId", + table: "SubscriptionTasks", + column: "CustomerId"); + + migrationBuilder.CreateIndex( + name: "IX_FlowOperations_BaseEventId", + table: "FlowOperations", + column: "BaseEventId"); + + migrationBuilder.CreateIndex( + name: "IX_FlowOperations_FlowRuleId", + table: "FlowOperations", + column: "FlowRuleId"); + + migrationBuilder.CreateIndex( + name: "IX_DeviceIdentities_DeviceId", + table: "DeviceIdentities", + column: "DeviceId"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceIdentities_Device_DeviceId", + table: "DeviceIdentities", + column: "DeviceId", + principalTable: "Device", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_BaseEvents_BaseEventId", + table: "FlowOperations", + column: "BaseEventId", + principalTable: "BaseEvents", + principalColumn: "EventId", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_FlowRules_FlowRuleId", + table: "FlowOperations", + column: "FlowRuleId", + principalTable: "FlowRules", + principalColumn: "RuleId", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_Flows_FlowId", + table: "FlowOperations", + column: "FlowId", + principalTable: "Flows", + principalColumn: "FlowId", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_SubscriptionTasks_Customer_CustomerId", + table: "SubscriptionTasks", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/IoTSharp.Data.MySQL/Migrations/ApplicationDbContextModelSnapshot.cs b/IoTSharp.Data.MySQL/Migrations/ApplicationDbContextModelSnapshot.cs index 612a38915c7f66521b9b7166172294c70637bbe8..a9f682c6ebf23d944b82d613000817ead7f3c608 100644 --- a/IoTSharp.Data.MySQL/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/IoTSharp.Data.MySQL/Migrations/ApplicationDbContextModelSnapshot.cs @@ -520,7 +520,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Creator") .HasColumnType("char(36)"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("char(36)"); b.Property("DiagramDesc") @@ -532,13 +532,13 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("DiagramName") .HasColumnType("longtext"); - b.Property("DiagramStatus") + b.Property("DiagramStatus") .HasColumnType("int"); - b.Property("IsDefault") + b.Property("IsDefault") .HasColumnType("tinyint(1)"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("char(36)"); b.HasKey("DiagramId"); @@ -562,7 +562,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Creator") .HasColumnType("char(36)"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("char(36)"); b.Property("DeviceDiagramDiagramId") @@ -577,14 +577,14 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("GraphFill") .HasColumnType("longtext"); - b.Property("GraphHeight") - .HasColumnType("decimal(65,30)"); + b.Property("GraphHeight") + .HasColumnType("int"); - b.Property("GraphPostionX") - .HasColumnType("decimal(65,30)"); + b.Property("GraphPostionX") + .HasColumnType("int"); - b.Property("GraphPostionY") - .HasColumnType("decimal(65,30)"); + b.Property("GraphPostionY") + .HasColumnType("int"); b.Property("GraphShape") .HasColumnType("longtext"); @@ -592,8 +592,8 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("GraphStroke") .HasColumnType("longtext"); - b.Property("GraphStrokeWidth") - .HasColumnType("decimal(65,30)"); + b.Property("GraphStrokeWidth") + .HasColumnType("int"); b.Property("GraphTextAnchor") .HasColumnType("longtext"); @@ -604,22 +604,22 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("GraphTextFontFamily") .HasColumnType("longtext"); - b.Property("GraphTextFontSize") - .HasColumnType("decimal(65,30)"); + b.Property("GraphTextFontSize") + .HasColumnType("int"); - b.Property("GraphTextRefX") - .HasColumnType("decimal(65,30)"); + b.Property("GraphTextRefX") + .HasColumnType("int"); - b.Property("GraphTextRefY") - .HasColumnType("decimal(65,30)"); + b.Property("GraphTextRefY") + .HasColumnType("int"); b.Property("GraphTextVerticalAnchor") .HasColumnType("longtext"); - b.Property("GraphWidth") - .HasColumnType("decimal(65,30)"); + b.Property("GraphWidth") + .HasColumnType("int"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("char(36)"); b.HasKey("GraphId"); @@ -651,13 +651,13 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Creator") .HasColumnType("char(36)"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("char(36)"); - b.Property("DeviceId") + b.Property("DeviceId") .HasColumnType("bigint"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("char(36)"); b.Property("ToolBoxIcon") @@ -666,22 +666,22 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("ToolBoxName") .HasColumnType("longtext"); - b.Property("ToolBoxOffsetLeftPer") - .HasColumnType("decimal(65,30)"); + b.Property("ToolBoxOffsetLeftPer") + .HasColumnType("int"); - b.Property("ToolBoxOffsetTopPer") - .HasColumnType("decimal(65,30)"); + b.Property("ToolBoxOffsetTopPer") + .HasColumnType("int"); - b.Property("ToolBoxOffsetX") - .HasColumnType("decimal(65,30)"); + b.Property("ToolBoxOffsetX") + .HasColumnType("int"); - b.Property("ToolBoxOffsetY") - .HasColumnType("decimal(65,30)"); + b.Property("ToolBoxOffsetY") + .HasColumnType("int"); b.Property("ToolBoxRequestUri") .HasColumnType("longtext"); - b.Property("ToolBoxStatus") + b.Property("ToolBoxStatus") .HasColumnType("int"); b.Property("ToolBoxType") @@ -801,7 +801,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("CreateDate") .HasColumnType("datetime(6)"); - b.Property("Creator") + b.Property("Creator") .HasColumnType("bigint"); b.Property("DeviceId") @@ -816,16 +816,16 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("PortName") .HasColumnType("longtext"); - b.Property("PortPhyType") + b.Property("PortPhyType") .HasColumnType("int"); b.Property("PortPic") .HasColumnType("longtext"); - b.Property("PortStatus") + b.Property("PortStatus") .HasColumnType("int"); - b.Property("PortType") + b.Property("PortType") .HasColumnType("int"); b.HasKey("PortId"); @@ -845,10 +845,10 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Creator") .HasColumnType("char(36)"); - b.Property("MappingIndex") - .HasColumnType("decimal(65,30)"); + b.Property("MappingIndex") + .HasColumnType("int"); - b.Property("MappingStatus") + b.Property("MappingStatus") .HasColumnType("int"); b.Property("SourceDeviceId") @@ -913,7 +913,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Creator") .HasColumnType("char(36)"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("char(36)"); b.Property("FieldCode") @@ -928,7 +928,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("FieldI18nKey") .HasColumnType("longtext"); - b.Property("FieldMaxLength") + b.Property("FieldMaxLength") .HasColumnType("int"); b.Property("FieldName") @@ -940,10 +940,10 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("FieldPocoTypeName") .HasColumnType("longtext"); - b.Property("FieldStatus") + b.Property("FieldStatus") .HasColumnType("int"); - b.Property("FieldUIElement") + b.Property("FieldUIElement") .HasColumnType("bigint"); b.Property("FieldUIElementSchema") @@ -961,22 +961,22 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("FieldValueLocalDataSource") .HasColumnType("longtext"); - b.Property("FieldValueType") + b.Property("FieldValueType") .HasColumnType("int"); b.Property("FieldValueTypeName") .HasColumnType("longtext"); - b.Property("FormId") + b.Property("FormId") .HasColumnType("bigint"); - b.Property("IsEnabled") + b.Property("IsEnabled") .HasColumnType("tinyint(1)"); - b.Property("IsRequired") + b.Property("IsRequired") .HasColumnType("tinyint(1)"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("char(36)"); b.HasKey("FieldId"); @@ -994,13 +994,13 @@ namespace IoTSharp.Data.MySql.Migrations .ValueGeneratedOnAdd() .HasColumnType("bigint"); - b.Property("BizId") + b.Property("BizId") .HasColumnType("bigint"); b.Property("Creator") .HasColumnType("char(36)"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("char(36)"); b.Property("FieldCode") @@ -1009,7 +1009,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("FieldCreateDate") .HasColumnType("datetime(6)"); - b.Property("FieldId") + b.Property("FieldId") .HasColumnType("bigint"); b.Property("FieldName") @@ -1021,13 +1021,13 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("FieldValue") .HasColumnType("longtext"); - b.Property("FieldValueType") + b.Property("FieldValueType") .HasColumnType("bigint"); - b.Property("FromId") + b.Property("FromId") .HasColumnType("bigint"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("char(36)"); b.HasKey("FieldValueId"); @@ -1045,16 +1045,16 @@ namespace IoTSharp.Data.MySql.Migrations .ValueGeneratedOnAdd() .HasColumnType("bigint"); - b.Property("BizId") + b.Property("BizId") .HasColumnType("bigint"); b.Property("Creator") .HasColumnType("char(36)"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("char(36)"); - b.Property("FormCreator") + b.Property("FormCreator") .HasColumnType("bigint"); b.Property("FormDesc") @@ -1069,7 +1069,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("FormSchame") .HasColumnType("longtext"); - b.Property("FormStatus") + b.Property("FormStatus") .HasColumnType("int"); b.Property("FromCreateDate") @@ -1081,7 +1081,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("ModelClass") .HasColumnType("longtext"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("char(36)"); b.Property("Url") @@ -1114,7 +1114,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Createor") .HasColumnType("char(36)"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("char(36)"); b.Property("ExecutorId") @@ -1168,7 +1168,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("TargetId") .HasColumnType("longtext"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("char(36)"); b.Property("TestStatus") @@ -1205,7 +1205,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("AddDate") .HasColumnType("datetime(6)"); - b.Property("BaseEventId") + b.Property("BaseEventEventId") .HasColumnType("char(36)"); b.Property("BizId") @@ -1214,13 +1214,13 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Data") .HasColumnType("longtext"); - b.Property("FlowId") + b.Property("FlowId") .HasColumnType("char(36)"); - b.Property("FlowRuleId") + b.Property("FlowRuleRuleId") .HasColumnType("char(36)"); - b.Property("NodeStatus") + b.Property("NodeStatus") .HasColumnType("int"); b.Property("OperationDesc") @@ -1237,11 +1237,11 @@ namespace IoTSharp.Data.MySql.Migrations b.HasKey("OperationId"); - b.HasIndex("BaseEventId"); + b.HasIndex("BaseEventEventId"); b.HasIndex("FlowId"); - b.HasIndex("FlowRuleId"); + b.HasIndex("FlowRuleRuleId"); b.ToTable("FlowOperations"); }); @@ -1261,7 +1261,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Creator") .HasColumnType("longtext"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("char(36)"); b.Property("DefinitionsXml") @@ -1298,7 +1298,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("SubVersion") .HasColumnType("double"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("char(36)"); b.Property("Version") @@ -1385,7 +1385,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Creator") .HasColumnType("char(36)"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("char(36)"); b.Property("DefaultConfig") @@ -1409,7 +1409,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Tag") .HasColumnType("longtext"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("char(36)"); b.Property("TestStatus") @@ -1445,7 +1445,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("Creator") .HasColumnType("char(36)"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("char(36)"); b.Property("EventDesc") @@ -1466,7 +1466,7 @@ namespace IoTSharp.Data.MySql.Migrations b.Property("EventTag") .HasColumnType("longtext"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("char(36)"); b.Property("Type") @@ -1914,15 +1914,11 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -1933,9 +1929,7 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.DeviceDiagram", "DeviceDiagram") .WithMany() @@ -1943,9 +1937,7 @@ namespace IoTSharp.Data.MySql.Migrations b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -1958,15 +1950,11 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2014,15 +2002,11 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2033,15 +2017,11 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2052,15 +2032,11 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2071,9 +2047,7 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.RuleTaskExecutor", "Executor") .WithMany() @@ -2085,9 +2059,7 @@ namespace IoTSharp.Data.MySql.Migrations b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2102,21 +2074,15 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.BaseEvent", "BaseEvent") .WithMany() - .HasForeignKey("BaseEventId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("BaseEventEventId"); b.HasOne("IoTSharp.Data.Flow", "Flow") .WithMany() - .HasForeignKey("FlowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("FlowId"); b.HasOne("IoTSharp.Data.FlowRule", "FlowRule") .WithMany() - .HasForeignKey("FlowRuleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("FlowRuleRuleId"); b.Navigation("BaseEvent"); @@ -2129,15 +2095,11 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2178,15 +2140,11 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2197,15 +2155,11 @@ namespace IoTSharp.Data.MySql.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); diff --git a/IoTSharp.Data.PostgreSQL/Migrations/20220212100327_FixTenantInfo.Designer.cs b/IoTSharp.Data.PostgreSQL/Migrations/20220212100327_FixTenantInfo.Designer.cs new file mode 100644 index 0000000000000000000000000000000000000000..a74143d6c11199b0f67b864df3ff269b5cefd999 --- /dev/null +++ b/IoTSharp.Data.PostgreSQL/Migrations/20220212100327_FixTenantInfo.Designer.cs @@ -0,0 +1,2290 @@ +// +using System; +using IoTSharp.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace IoTSharp.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20220212100327_FixTenantInfo")] + partial class FixTenantInfo + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("IoTSharp.Data.AuditLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ActionData") + .HasColumnType("jsonb"); + + b.Property("ActionName") + .HasColumnType("text"); + + b.Property("ActionResult") + .HasColumnType("jsonb"); + + b.Property("ActiveDateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("ObjectID") + .HasColumnType("uuid"); + + b.Property("ObjectName") + .HasColumnType("text"); + + b.Property("ObjectType") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("UserId") + .HasColumnType("text"); + + b.Property("UserName") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("AuditLog"); + }); + + modelBuilder.Entity("IoTSharp.Data.AuthorizedKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AuthToken") + .HasColumnType("text"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("AuthorizedKeys"); + }); + + modelBuilder.Entity("IoTSharp.Data.BaseDictionary", b => + { + b.Property("DictionaryId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("DictionaryId")); + + b.Property("Dictionary18NKeyName") + .HasColumnType("text"); + + b.Property("DictionaryColor") + .HasColumnType("text"); + + b.Property("DictionaryDesc") + .HasColumnType("text"); + + b.Property("DictionaryGroupId") + .HasColumnType("bigint"); + + b.Property("DictionaryIcon") + .HasColumnType("text"); + + b.Property("DictionaryName") + .HasColumnType("text"); + + b.Property("DictionaryPattern") + .HasColumnType("text"); + + b.Property("DictionaryStatus") + .HasColumnType("integer"); + + b.Property("DictionaryTag") + .HasColumnType("text"); + + b.Property("DictionaryValue") + .HasColumnType("text"); + + b.Property("DictionaryValueType") + .HasColumnType("integer"); + + b.Property("DictionaryValueTypeName") + .HasColumnType("text"); + + b.HasKey("DictionaryId"); + + b.ToTable("BaseDictionaries"); + }); + + modelBuilder.Entity("IoTSharp.Data.BaseDictionaryGroup", b => + { + b.Property("DictionaryGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("DictionaryGroupId")); + + b.Property("DictionaryGroup18NKeyName") + .HasColumnType("text"); + + b.Property("DictionaryGroupDesc") + .HasColumnType("text"); + + b.Property("DictionaryGroupKey") + .HasColumnType("text"); + + b.Property("DictionaryGroupName") + .HasColumnType("text"); + + b.Property("DictionaryGroupStatus") + .HasColumnType("integer"); + + b.Property("DictionaryGroupValueType") + .HasColumnType("integer"); + + b.Property("DictionaryGroupValueTypeName") + .HasColumnType("text"); + + b.HasKey("DictionaryGroupId"); + + b.ToTable("BaseDictionaryGroups"); + }); + + modelBuilder.Entity("IoTSharp.Data.BaseEvent", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("BizData") + .HasColumnType("text"); + + b.Property("Bizid") + .HasColumnType("text"); + + b.Property("CreaterDateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("EventDesc") + .HasColumnType("text"); + + b.Property("EventName") + .HasColumnType("text"); + + b.Property("EventStaus") + .HasColumnType("integer"); + + b.Property("FlowRuleRuleId") + .HasColumnType("uuid"); + + b.Property("MataData") + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("EventId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("FlowRuleRuleId"); + + b.HasIndex("TenantId"); + + b.ToTable("BaseEvents"); + }); + + modelBuilder.Entity("IoTSharp.Data.BaseI18N", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AddDate") + .HasColumnType("timestamp with time zone"); + + b.Property("KeyName") + .HasColumnType("text"); + + b.Property("ResouceDesc") + .HasColumnType("text"); + + b.Property("ResouceGroupId") + .HasColumnType("integer"); + + b.Property("ResourceId") + .HasColumnType("bigint"); + + b.Property("ResourceKey") + .HasColumnType("text"); + + b.Property("ResourceTag") + .HasColumnType("text"); + + b.Property("ResourceType") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("uuid"); + + b.Property("ValueBG") + .HasColumnType("text"); + + b.Property("ValueCS") + .HasColumnType("text"); + + b.Property("ValueDA") + .HasColumnType("text"); + + b.Property("ValueDEDE") + .HasColumnType("text"); + + b.Property("ValueELGR") + .HasColumnType("text"); + + b.Property("ValueENGR") + .HasColumnType("text"); + + b.Property("ValueENUS") + .HasColumnType("text"); + + b.Property("ValueESES") + .HasColumnType("text"); + + b.Property("ValueFI") + .HasColumnType("text"); + + b.Property("ValueFRFR") + .HasColumnType("text"); + + b.Property("ValueHE") + .HasColumnType("text"); + + b.Property("ValueHRHR") + .HasColumnType("text"); + + b.Property("ValueHU") + .HasColumnType("text"); + + b.Property("ValueITIT") + .HasColumnType("text"); + + b.Property("ValueJAJP") + .HasColumnType("text"); + + b.Property("ValueKOKR") + .HasColumnType("text"); + + b.Property("ValueNL") + .HasColumnType("text"); + + b.Property("ValuePLPL") + .HasColumnType("text"); + + b.Property("ValuePT") + .HasColumnType("text"); + + b.Property("ValueSLSL") + .HasColumnType("text"); + + b.Property("ValueSR") + .HasColumnType("text"); + + b.Property("ValueSV") + .HasColumnType("text"); + + b.Property("ValueTRTR") + .HasColumnType("text"); + + b.Property("ValueUK") + .HasColumnType("text"); + + b.Property("ValueVI") + .HasColumnType("text"); + + b.Property("ValueZHCN") + .HasColumnType("text"); + + b.Property("ValueZHTW") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("BaseI18Ns"); + }); + + modelBuilder.Entity("IoTSharp.Data.Customer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Address") + .HasColumnType("text"); + + b.Property("City") + .HasColumnType("text"); + + b.Property("Country") + .HasColumnType("text"); + + b.Property("Email") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Phone") + .HasColumnType("text"); + + b.Property("Province") + .HasColumnType("text"); + + b.Property("Street") + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("ZipCode") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("Customer"); + }); + + modelBuilder.Entity("IoTSharp.Data.DataStorage", b => + { + b.Property("Catalog") + .HasColumnType("integer") + .HasColumnOrder(0); + + b.Property("DeviceId") + .HasColumnType("uuid") + .HasColumnOrder(1); + + b.Property("KeyName") + .HasColumnType("text") + .HasColumnOrder(2); + + b.Property("DataSide") + .HasColumnType("integer") + .HasColumnOrder(4); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone") + .HasColumnOrder(3); + + b.Property("Type") + .HasColumnType("integer") + .HasColumnOrder(5); + + b.Property("Value_Binary") + .HasColumnType("bytea"); + + b.Property("Value_Boolean") + .HasColumnType("boolean"); + + b.Property("Value_DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Value_Double") + .HasColumnType("double precision"); + + b.Property("Value_Json") + .HasColumnType("jsonb"); + + b.Property("Value_Long") + .HasColumnType("bigint"); + + b.Property("Value_String") + .HasColumnType("text"); + + b.Property("Value_XML") + .HasColumnType("xml"); + + b.HasKey("Catalog", "DeviceId", "KeyName"); + + b.HasIndex("Catalog"); + + b.HasIndex("Catalog", "DeviceId"); + + b.ToTable("DataStorage"); + + b.HasDiscriminator("Catalog").HasValue(0); + }); + + modelBuilder.Entity("IoTSharp.Data.Device", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AuthorizedKeyId") + .HasColumnType("uuid"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("DeviceModelId") + .HasColumnType("uuid"); + + b.Property("DeviceType") + .HasColumnType("integer"); + + b.Property("LastActive") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Online") + .HasColumnType("boolean"); + + b.Property("OwnerId") + .HasColumnType("uuid"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("Timeout") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("AuthorizedKeyId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("DeviceModelId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("TenantId"); + + b.ToTable("Device"); + + b.HasDiscriminator("DeviceType").HasValue(0); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceDiagram", b => + { + b.Property("DiagramId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreateDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("DiagramDesc") + .HasColumnType("text"); + + b.Property("DiagramImage") + .HasColumnType("text"); + + b.Property("DiagramName") + .HasColumnType("text"); + + b.Property("DiagramStatus") + .HasColumnType("integer"); + + b.Property("IsDefault") + .HasColumnType("boolean"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.HasKey("DiagramId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("DeviceDiagrams"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceGraph", b => + { + b.Property("GraphId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreateDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("DeviceDiagramDiagramId") + .HasColumnType("uuid"); + + b.Property("DeviceId") + .HasColumnType("uuid"); + + b.Property("GraphElementId") + .HasColumnType("text"); + + b.Property("GraphFill") + .HasColumnType("text"); + + b.Property("GraphHeight") + .HasColumnType("integer"); + + b.Property("GraphPostionX") + .HasColumnType("integer"); + + b.Property("GraphPostionY") + .HasColumnType("integer"); + + b.Property("GraphShape") + .HasColumnType("text"); + + b.Property("GraphStroke") + .HasColumnType("text"); + + b.Property("GraphStrokeWidth") + .HasColumnType("integer"); + + b.Property("GraphTextAnchor") + .HasColumnType("text"); + + b.Property("GraphTextFill") + .HasColumnType("text"); + + b.Property("GraphTextFontFamily") + .HasColumnType("text"); + + b.Property("GraphTextFontSize") + .HasColumnType("integer"); + + b.Property("GraphTextRefX") + .HasColumnType("integer"); + + b.Property("GraphTextRefY") + .HasColumnType("integer"); + + b.Property("GraphTextVerticalAnchor") + .HasColumnType("text"); + + b.Property("GraphWidth") + .HasColumnType("integer"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.HasKey("GraphId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("DeviceDiagramDiagramId"); + + b.HasIndex("TenantId"); + + b.ToTable("DeviceGraphs"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceGraphToolBox", b => + { + b.Property("ToolBoxId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CommondParam") + .HasColumnType("text"); + + b.Property("CommondType") + .HasColumnType("text"); + + b.Property("CreateDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("DeviceId") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("ToolBoxIcon") + .HasColumnType("text"); + + b.Property("ToolBoxName") + .HasColumnType("text"); + + b.Property("ToolBoxOffsetLeftPer") + .HasColumnType("integer"); + + b.Property("ToolBoxOffsetTopPer") + .HasColumnType("integer"); + + b.Property("ToolBoxOffsetX") + .HasColumnType("integer"); + + b.Property("ToolBoxOffsetY") + .HasColumnType("integer"); + + b.Property("ToolBoxRequestUri") + .HasColumnType("text"); + + b.Property("ToolBoxStatus") + .HasColumnType("integer"); + + b.Property("ToolBoxType") + .HasColumnType("text"); + + b.HasKey("ToolBoxId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("DeviceGraphToolBoxes"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceIdentity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("DeviceId") + .HasColumnType("uuid"); + + b.Property("IdentityId") + .IsRequired() + .HasColumnType("text"); + + b.Property("IdentityType") + .HasColumnType("integer"); + + b.Property("IdentityValue") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("DeviceId") + .IsUnique(); + + b.ToTable("DeviceIdentities"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceModel", b => + { + b.Property("DeviceModelId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreateDateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("ModelDesc") + .HasColumnType("text"); + + b.Property("ModelName") + .HasColumnType("text"); + + b.Property("ModelStatus") + .HasColumnType("integer"); + + b.HasKey("DeviceModelId"); + + b.ToTable("DeviceModels"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceModelCommand", b => + { + b.Property("CommandId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CommandI18N") + .HasColumnType("text"); + + b.Property("CommandName") + .HasColumnType("text"); + + b.Property("CommandParams") + .HasColumnType("text"); + + b.Property("CommandStatus") + .HasColumnType("integer"); + + b.Property("CommandTemplate") + .HasColumnType("text"); + + b.Property("CommandTitle") + .HasColumnType("text"); + + b.Property("CommandType") + .HasColumnType("integer"); + + b.Property("CreateDateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("DeviceModelId") + .HasColumnType("uuid"); + + b.HasKey("CommandId"); + + b.HasIndex("DeviceModelId"); + + b.ToTable("DeviceModelCommands"); + }); + + modelBuilder.Entity("IoTSharp.Data.DevicePort", b => + { + b.Property("PortId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreateDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Creator") + .HasColumnType("bigint"); + + b.Property("DeviceId") + .HasColumnType("uuid"); + + b.Property("PortDesc") + .HasColumnType("text"); + + b.Property("PortElementId") + .HasColumnType("text"); + + b.Property("PortName") + .HasColumnType("text"); + + b.Property("PortPhyType") + .HasColumnType("integer"); + + b.Property("PortPic") + .HasColumnType("text"); + + b.Property("PortStatus") + .HasColumnType("integer"); + + b.Property("PortType") + .HasColumnType("integer"); + + b.HasKey("PortId"); + + b.ToTable("DevicePorts"); + }); + + modelBuilder.Entity("IoTSharp.Data.DevicePortMapping", b => + { + b.Property("MappingId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreateDate") + .HasColumnType("timestamp with time zone"); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("MappingIndex") + .HasColumnType("integer"); + + b.Property("MappingStatus") + .HasColumnType("integer"); + + b.Property("SourceDeviceId") + .HasColumnType("uuid"); + + b.Property("SourceElementId") + .HasColumnType("text"); + + b.Property("SourceId") + .HasColumnType("text"); + + b.Property("TargeId") + .HasColumnType("text"); + + b.Property("TargetDeviceId") + .HasColumnType("uuid"); + + b.Property("TargetElementId") + .HasColumnType("text"); + + b.HasKey("MappingId"); + + b.ToTable("DevicePortMappings"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceRule", b => + { + b.Property("DeviceRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("ConfigDateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("ConfigUser") + .HasColumnType("uuid"); + + b.Property("DeviceId") + .HasColumnType("uuid"); + + b.Property("EnableTrace") + .HasColumnType("integer"); + + b.Property("FlowRuleRuleId") + .HasColumnType("uuid"); + + b.HasKey("DeviceRuleId"); + + b.HasIndex("DeviceId"); + + b.HasIndex("FlowRuleRuleId"); + + b.ToTable("DeviceRules"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormFieldInfo", b => + { + b.Property("FieldId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("FieldId")); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("FieldCode") + .HasColumnType("text"); + + b.Property("FieldCreateDate") + .HasColumnType("timestamp with time zone"); + + b.Property("FieldEditDate") + .HasColumnType("timestamp with time zone"); + + b.Property("FieldI18nKey") + .HasColumnType("text"); + + b.Property("FieldMaxLength") + .HasColumnType("integer"); + + b.Property("FieldName") + .HasColumnType("text"); + + b.Property("FieldPattern") + .HasColumnType("text"); + + b.Property("FieldPocoTypeName") + .HasColumnType("text"); + + b.Property("FieldStatus") + .HasColumnType("integer"); + + b.Property("FieldUIElement") + .HasColumnType("bigint"); + + b.Property("FieldUIElementSchema") + .HasColumnType("text"); + + b.Property("FieldUnit") + .HasColumnType("text"); + + b.Property("FieldValue") + .HasColumnType("text"); + + b.Property("FieldValueDataSource") + .HasColumnType("text"); + + b.Property("FieldValueLocalDataSource") + .HasColumnType("text"); + + b.Property("FieldValueType") + .HasColumnType("integer"); + + b.Property("FieldValueTypeName") + .HasColumnType("text"); + + b.Property("FormId") + .HasColumnType("bigint"); + + b.Property("IsEnabled") + .HasColumnType("boolean"); + + b.Property("IsRequired") + .HasColumnType("boolean"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.HasKey("FieldId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("DynamicFormFieldInfos"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormFieldValueInfo", b => + { + b.Property("FieldValueId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("FieldValueId")); + + b.Property("BizId") + .HasColumnType("bigint"); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("FieldCode") + .HasColumnType("text"); + + b.Property("FieldCreateDate") + .HasColumnType("timestamp with time zone"); + + b.Property("FieldId") + .HasColumnType("bigint"); + + b.Property("FieldName") + .HasColumnType("text"); + + b.Property("FieldUnit") + .HasColumnType("text"); + + b.Property("FieldValue") + .HasColumnType("text"); + + b.Property("FieldValueType") + .HasColumnType("bigint"); + + b.Property("FromId") + .HasColumnType("bigint"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.HasKey("FieldValueId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("DynamicFormFieldValueInfos"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormInfo", b => + { + b.Property("FormId") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("FormId")); + + b.Property("BizId") + .HasColumnType("bigint"); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("FormCreator") + .HasColumnType("bigint"); + + b.Property("FormDesc") + .HasColumnType("text"); + + b.Property("FormLayout") + .HasColumnType("text"); + + b.Property("FormName") + .HasColumnType("text"); + + b.Property("FormSchame") + .HasColumnType("text"); + + b.Property("FormStatus") + .HasColumnType("integer"); + + b.Property("FromCreateDate") + .HasColumnType("timestamp with time zone"); + + b.Property("IsCompact") + .HasColumnType("boolean"); + + b.Property("ModelClass") + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("Url") + .HasColumnType("text"); + + b.HasKey("FormId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("DynamicFormInfos"); + }); + + modelBuilder.Entity("IoTSharp.Data.Flow", b => + { + b.Property("FlowId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Conditionexpression") + .HasColumnType("text"); + + b.Property("CreateDate") + .HasColumnType("timestamp with time zone"); + + b.Property("CreateId") + .HasColumnType("uuid"); + + b.Property("Createor") + .HasColumnType("uuid"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("ExecutorId") + .HasColumnType("uuid"); + + b.Property("FlowRuleRuleId") + .HasColumnType("uuid"); + + b.Property("FlowStatus") + .HasColumnType("integer"); + + b.Property("FlowType") + .HasColumnType("text"); + + b.Property("Flowdesc") + .HasColumnType("text"); + + b.Property("Flowname") + .HasColumnType("text"); + + b.Property("Incoming") + .HasColumnType("text"); + + b.Property("NodeProcessClass") + .HasColumnType("text"); + + b.Property("NodeProcessMethod") + .HasColumnType("text"); + + b.Property("NodeProcessParams") + .HasColumnType("text"); + + b.Property("NodeProcessScript") + .HasColumnType("text"); + + b.Property("NodeProcessScriptType") + .HasColumnType("text"); + + b.Property("NodeProcessType") + .HasColumnType("text"); + + b.Property("ObjectId") + .HasColumnType("text"); + + b.Property("Outgoing") + .HasColumnType("text"); + + b.Property("SourceId") + .HasColumnType("text"); + + b.Property("TargetId") + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("TestStatus") + .HasColumnType("integer"); + + b.Property("Tester") + .HasColumnType("uuid"); + + b.Property("TesterDateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("bpmnid") + .HasColumnType("text"); + + b.HasKey("FlowId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("ExecutorId"); + + b.HasIndex("FlowRuleRuleId"); + + b.HasIndex("TenantId"); + + b.ToTable("Flows"); + }); + + modelBuilder.Entity("IoTSharp.Data.FlowOperation", b => + { + b.Property("OperationId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AddDate") + .HasColumnType("timestamp with time zone"); + + b.Property("BaseEventEventId") + .HasColumnType("uuid"); + + b.Property("BizId") + .HasColumnType("text"); + + b.Property("Data") + .HasColumnType("text"); + + b.Property("FlowId") + .HasColumnType("uuid"); + + b.Property("FlowRuleRuleId") + .HasColumnType("uuid"); + + b.Property("NodeStatus") + .HasColumnType("integer"); + + b.Property("OperationDesc") + .HasColumnType("text"); + + b.Property("Step") + .HasColumnType("integer"); + + b.Property("Tag") + .HasColumnType("text"); + + b.Property("bpmnid") + .HasColumnType("text"); + + b.HasKey("OperationId"); + + b.HasIndex("BaseEventEventId"); + + b.HasIndex("FlowId"); + + b.HasIndex("FlowRuleRuleId"); + + b.ToTable("FlowOperations"); + }); + + modelBuilder.Entity("IoTSharp.Data.FlowRule", b => + { + b.Property("RuleId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreatTime") + .HasColumnType("timestamp with time zone"); + + b.Property("CreateId") + .HasColumnType("uuid"); + + b.Property("Creator") + .HasColumnType("text"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("DefinitionsXml") + .HasColumnType("text"); + + b.Property("Describes") + .HasColumnType("text"); + + b.Property("ExecutableCode") + .HasColumnType("text"); + + b.Property("MountType") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasColumnType("text"); + + b.Property("ParentRuleId") + .HasColumnType("uuid"); + + b.Property("RuleDesc") + .HasColumnType("text"); + + b.Property("RuleStatus") + .HasColumnType("integer"); + + b.Property("RuleType") + .HasColumnType("integer"); + + b.Property("Runner") + .HasColumnType("text"); + + b.Property("SubVersion") + .HasColumnType("double precision"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("Version") + .HasColumnType("double precision"); + + b.HasKey("RuleId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("FlowRules"); + }); + + modelBuilder.Entity("IoTSharp.Data.RefreshToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AddedDate") + .HasColumnType("timestamp with time zone"); + + b.Property("ExpiryDate") + .HasColumnType("timestamp with time zone"); + + b.Property("IsRevorked") + .HasColumnType("boolean"); + + b.Property("IsUsed") + .HasColumnType("boolean"); + + b.Property("JwtId") + .HasColumnType("text"); + + b.Property("Token") + .HasColumnType("text"); + + b.Property("UserId") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("RefreshTokens"); + }); + + modelBuilder.Entity("IoTSharp.Data.Relationship", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("IdentityUserId") + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("IdentityUserId"); + + b.HasIndex("TenantId"); + + b.ToTable("Relationship"); + }); + + modelBuilder.Entity("IoTSharp.Data.RuleTaskExecutor", b => + { + b.Property("ExecutorId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("AddDateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("DefaultConfig") + .HasColumnType("text"); + + b.Property("ExecutorDesc") + .HasColumnType("text"); + + b.Property("ExecutorName") + .HasColumnType("text"); + + b.Property("ExecutorStatus") + .HasColumnType("integer"); + + b.Property("MataData") + .HasColumnType("text"); + + b.Property("Path") + .HasColumnType("text"); + + b.Property("Tag") + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("TestStatus") + .HasColumnType("integer"); + + b.Property("Tester") + .HasColumnType("uuid"); + + b.Property("TesterDateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("TypeName") + .HasColumnType("text"); + + b.HasKey("ExecutorId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("RuleTaskExecutors"); + }); + + modelBuilder.Entity("IoTSharp.Data.SubscriptionEvent", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("CreateDateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Creator") + .HasColumnType("uuid"); + + b.Property("CustomerId") + .HasColumnType("uuid"); + + b.Property("EventDesc") + .HasColumnType("text"); + + b.Property("EventName") + .HasColumnType("text"); + + b.Property("EventNameSpace") + .HasColumnType("text"); + + b.Property("EventParam") + .HasColumnType("text"); + + b.Property("EventStatus") + .HasColumnType("integer"); + + b.Property("EventTag") + .HasColumnType("text"); + + b.Property("TenantId") + .HasColumnType("uuid"); + + b.Property("Type") + .HasColumnType("integer"); + + b.HasKey("EventId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("SubscriptionEvents"); + }); + + modelBuilder.Entity("IoTSharp.Data.SubscriptionTask", b => + { + b.Property("BindId") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("EventId") + .HasColumnType("uuid"); + + b.Property("RuleTaskExecutorExecutorId") + .HasColumnType("uuid"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("SubscriptionEventId") + .HasColumnType("uuid"); + + b.Property("TaskConfig") + .HasColumnType("text"); + + b.HasKey("BindId"); + + b.HasIndex("RuleTaskExecutorExecutorId"); + + b.HasIndex("SubscriptionEventId"); + + b.ToTable("SubscriptionTasks"); + }); + + modelBuilder.Entity("IoTSharp.Data.TelemetryData", b => + { + b.Property("DeviceId") + .HasColumnType("uuid") + .HasColumnOrder(1); + + b.Property("KeyName") + .HasColumnType("text") + .HasColumnOrder(2); + + b.Property("DateTime") + .HasColumnType("timestamp with time zone") + .HasColumnOrder(3); + + b.Property("DataSide") + .HasColumnType("integer") + .HasColumnOrder(4); + + b.Property("Type") + .HasColumnType("integer") + .HasColumnOrder(5); + + b.Property("Value_Binary") + .HasColumnType("bytea"); + + b.Property("Value_Boolean") + .HasColumnType("boolean"); + + b.Property("Value_DateTime") + .HasColumnType("timestamp with time zone"); + + b.Property("Value_Double") + .HasColumnType("double precision"); + + b.Property("Value_Json") + .HasColumnType("jsonb"); + + b.Property("Value_Long") + .HasColumnType("bigint"); + + b.Property("Value_String") + .HasColumnType("text"); + + b.Property("Value_XML") + .HasColumnType("xml"); + + b.HasKey("DeviceId", "KeyName", "DateTime"); + + b.HasIndex("DeviceId"); + + b.HasIndex("KeyName"); + + b.HasIndex("DeviceId", "KeyName"); + + b.ToTable("TelemetryData"); + }); + + modelBuilder.Entity("IoTSharp.Data.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("uuid"); + + b.Property("Address") + .HasColumnType("text"); + + b.Property("City") + .HasColumnType("text"); + + b.Property("Country") + .HasColumnType("text"); + + b.Property("EMail") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Phone") + .HasColumnType("text"); + + b.Property("Province") + .HasColumnType("text"); + + b.Property("Street") + .HasColumnType("text"); + + b.Property("ZipCode") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.ToTable("Tenant"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("text"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("character varying(256)"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ClaimType") + .HasColumnType("text"); + + b.Property("ClaimValue") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("ProviderKey") + .HasColumnType("text"); + + b.Property("ProviderDisplayName") + .HasColumnType("text"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("RoleId") + .HasColumnType("text"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("text"); + + b.Property("LoginProvider") + .HasColumnType("text"); + + b.Property("Name") + .HasColumnType("text"); + + b.Property("Value") + .HasColumnType("text"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("IoTSharp.Data.AttributeLatest", b => + { + b.HasBaseType("IoTSharp.Data.DataStorage"); + + b.HasDiscriminator().HasValue(2); + }); + + modelBuilder.Entity("IoTSharp.Data.Gateway", b => + { + b.HasBaseType("IoTSharp.Data.Device"); + + b.HasDiscriminator().HasValue(1); + }); + + modelBuilder.Entity("IoTSharp.Data.TelemetryLatest", b => + { + b.HasBaseType("IoTSharp.Data.DataStorage"); + + b.HasDiscriminator().HasValue(4); + }); + + modelBuilder.Entity("IoTSharp.Data.AuditLog", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.AuthorizedKey", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.BaseEvent", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.FlowRule", "FlowRule") + .WithMany() + .HasForeignKey("FlowRuleRuleId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("FlowRule"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.Customer", b => + { + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany("Customers") + .HasForeignKey("TenantId"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.Device", b => + { + b.HasOne("IoTSharp.Data.AuthorizedKey", null) + .WithMany("Devices") + .HasForeignKey("AuthorizedKeyId"); + + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany("Devices") + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.DeviceModel", "DeviceModel") + .WithMany() + .HasForeignKey("DeviceModelId"); + + b.HasOne("IoTSharp.Data.Gateway", "Owner") + .WithMany("Children") + .HasForeignKey("OwnerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany("Devices") + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("DeviceModel"); + + b.Navigation("Owner"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceDiagram", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceGraph", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.DeviceDiagram", "DeviceDiagram") + .WithMany() + .HasForeignKey("DeviceDiagramDiagramId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("DeviceDiagram"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceGraphToolBox", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceIdentity", b => + { + b.HasOne("IoTSharp.Data.Device", "Device") + .WithOne("DeviceIdentity") + .HasForeignKey("IoTSharp.Data.DeviceIdentity", "DeviceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Device"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceModelCommand", b => + { + b.HasOne("IoTSharp.Data.DeviceModel", "DeviceModel") + .WithMany("DeviceModelCommands") + .HasForeignKey("DeviceModelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DeviceModel"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceRule", b => + { + b.HasOne("IoTSharp.Data.Device", "Device") + .WithMany() + .HasForeignKey("DeviceId"); + + b.HasOne("IoTSharp.Data.FlowRule", "FlowRule") + .WithMany() + .HasForeignKey("FlowRuleRuleId"); + + b.Navigation("Device"); + + b.Navigation("FlowRule"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormFieldInfo", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormFieldValueInfo", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormInfo", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.Flow", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.RuleTaskExecutor", "Executor") + .WithMany() + .HasForeignKey("ExecutorId"); + + b.HasOne("IoTSharp.Data.FlowRule", "FlowRule") + .WithMany() + .HasForeignKey("FlowRuleRuleId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Executor"); + + b.Navigation("FlowRule"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.FlowOperation", b => + { + b.HasOne("IoTSharp.Data.BaseEvent", "BaseEvent") + .WithMany() + .HasForeignKey("BaseEventEventId"); + + b.HasOne("IoTSharp.Data.Flow", "Flow") + .WithMany() + .HasForeignKey("FlowId"); + + b.HasOne("IoTSharp.Data.FlowRule", "FlowRule") + .WithMany() + .HasForeignKey("FlowRuleRuleId"); + + b.Navigation("BaseEvent"); + + b.Navigation("Flow"); + + b.Navigation("FlowRule"); + }); + + modelBuilder.Entity("IoTSharp.Data.FlowRule", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.RefreshToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("IoTSharp.Data.Relationship", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "IdentityUser") + .WithMany() + .HasForeignKey("IdentityUserId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("IdentityUser"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.RuleTaskExecutor", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.SubscriptionEvent", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.SubscriptionTask", b => + { + b.HasOne("IoTSharp.Data.RuleTaskExecutor", "RuleTaskExecutor") + .WithMany() + .HasForeignKey("RuleTaskExecutorExecutorId"); + + b.HasOne("IoTSharp.Data.SubscriptionEvent", "Subscription") + .WithMany() + .HasForeignKey("SubscriptionEventId"); + + b.Navigation("RuleTaskExecutor"); + + b.Navigation("Subscription"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("IoTSharp.Data.AuthorizedKey", b => + { + b.Navigation("Devices"); + }); + + modelBuilder.Entity("IoTSharp.Data.Customer", b => + { + b.Navigation("Devices"); + }); + + modelBuilder.Entity("IoTSharp.Data.Device", b => + { + b.Navigation("DeviceIdentity"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceModel", b => + { + b.Navigation("DeviceModelCommands"); + }); + + modelBuilder.Entity("IoTSharp.Data.Tenant", b => + { + b.Navigation("Customers"); + + b.Navigation("Devices"); + }); + + modelBuilder.Entity("IoTSharp.Data.Gateway", b => + { + b.Navigation("Children"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/IoTSharp.Data.PostgreSQL/Migrations/20220212100327_FixTenantInfo.cs b/IoTSharp.Data.PostgreSQL/Migrations/20220212100327_FixTenantInfo.cs new file mode 100644 index 0000000000000000000000000000000000000000..e9806699e46e3e24d45dd2e12bbcfb1981eeffbf --- /dev/null +++ b/IoTSharp.Data.PostgreSQL/Migrations/20220212100327_FixTenantInfo.cs @@ -0,0 +1,1667 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace IoTSharp.Migrations +{ + public partial class FixTenantInfo : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_DeviceDiagrams_Customer_CustomerId", + table: "DeviceDiagrams"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceDiagrams_Tenant_TenantId", + table: "DeviceDiagrams"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceGraphs_Customer_CustomerId", + table: "DeviceGraphs"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceGraphs_Tenant_TenantId", + table: "DeviceGraphs"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceGraphToolBoxes_Customer_CustomerId", + table: "DeviceGraphToolBoxes"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceGraphToolBoxes_Tenant_TenantId", + table: "DeviceGraphToolBoxes"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormFieldInfos_Customer_CustomerId", + table: "DynamicFormFieldInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormFieldInfos_Tenant_TenantId", + table: "DynamicFormFieldInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormFieldValueInfos_Customer_CustomerId", + table: "DynamicFormFieldValueInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormFieldValueInfos_Tenant_TenantId", + table: "DynamicFormFieldValueInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormInfos_Customer_CustomerId", + table: "DynamicFormInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormInfos_Tenant_TenantId", + table: "DynamicFormInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_BaseEvents_BaseEventId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_FlowRules_FlowRuleId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_Flows_FlowId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowRules_Customer_CustomerId", + table: "FlowRules"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowRules_Tenant_TenantId", + table: "FlowRules"); + + migrationBuilder.DropForeignKey( + name: "FK_Flows_Customer_CustomerId", + table: "Flows"); + + migrationBuilder.DropForeignKey( + name: "FK_Flows_Tenant_TenantId", + table: "Flows"); + + migrationBuilder.DropForeignKey( + name: "FK_RuleTaskExecutors_Customer_CustomerId", + table: "RuleTaskExecutors"); + + migrationBuilder.DropForeignKey( + name: "FK_RuleTaskExecutors_Tenant_TenantId", + table: "RuleTaskExecutors"); + + migrationBuilder.DropForeignKey( + name: "FK_SubscriptionEvents_Customer_CustomerId", + table: "SubscriptionEvents"); + + migrationBuilder.DropForeignKey( + name: "FK_SubscriptionEvents_Tenant_TenantId", + table: "SubscriptionEvents"); + + migrationBuilder.DropIndex( + name: "IX_FlowOperations_BaseEventId", + table: "FlowOperations"); + + migrationBuilder.DropIndex( + name: "IX_FlowOperations_FlowRuleId", + table: "FlowOperations"); + + migrationBuilder.DropColumn( + name: "BaseEventId", + table: "FlowOperations"); + + migrationBuilder.DropColumn( + name: "FlowRuleId", + table: "FlowOperations"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "SubscriptionEvents", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "SubscriptionEvents", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "RuleTaskExecutors", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "RuleTaskExecutors", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "Flows", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "Flows", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "FlowRules", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "FlowRules", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "NodeStatus", + table: "FlowOperations", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FlowId", + table: "FlowOperations", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AddColumn( + name: "BaseEventEventId", + table: "FlowOperations", + type: "uuid", + nullable: true); + + migrationBuilder.AddColumn( + name: "FlowRuleRuleId", + table: "FlowOperations", + type: "uuid", + nullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DynamicFormInfos", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "FormStatus", + table: "DynamicFormInfos", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FormCreator", + table: "DynamicFormInfos", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DynamicFormInfos", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "BizId", + table: "DynamicFormInfos", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DynamicFormFieldValueInfos", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "FromId", + table: "DynamicFormFieldValueInfos", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FieldValueType", + table: "DynamicFormFieldValueInfos", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FieldId", + table: "DynamicFormFieldValueInfos", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DynamicFormFieldValueInfos", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "BizId", + table: "DynamicFormFieldValueInfos", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DynamicFormFieldInfos", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "IsRequired", + table: "DynamicFormFieldInfos", + type: "boolean", + nullable: false, + defaultValue: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "IsEnabled", + table: "DynamicFormFieldInfos", + type: "boolean", + nullable: false, + defaultValue: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FormId", + table: "DynamicFormFieldInfos", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FieldValueType", + table: "DynamicFormFieldInfos", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FieldUIElement", + table: "DynamicFormFieldInfos", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FieldStatus", + table: "DynamicFormFieldInfos", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FieldMaxLength", + table: "DynamicFormFieldInfos", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DynamicFormFieldInfos", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "PortType", + table: "DevicePorts", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "PortStatus", + table: "DevicePorts", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "PortPhyType", + table: "DevicePorts", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Creator", + table: "DevicePorts", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MappingStatus", + table: "DevicePortMappings", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MappingIndex", + table: "DevicePortMappings", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ToolBoxStatus", + table: "DeviceGraphToolBoxes", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetY", + table: "DeviceGraphToolBoxes", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetX", + table: "DeviceGraphToolBoxes", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetTopPer", + table: "DeviceGraphToolBoxes", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetLeftPer", + table: "DeviceGraphToolBoxes", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DeviceGraphToolBoxes", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "DeviceId", + table: "DeviceGraphToolBoxes", + type: "bigint", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "bigint", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DeviceGraphToolBoxes", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DeviceGraphs", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "GraphWidth", + table: "DeviceGraphs", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphTextRefY", + table: "DeviceGraphs", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphTextRefX", + table: "DeviceGraphs", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphTextFontSize", + table: "DeviceGraphs", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphStrokeWidth", + table: "DeviceGraphs", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphPostionY", + table: "DeviceGraphs", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphPostionX", + table: "DeviceGraphs", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphHeight", + table: "DeviceGraphs", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "numeric", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DeviceGraphs", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DeviceDiagrams", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.AlterColumn( + name: "IsDefault", + table: "DeviceDiagrams", + type: "boolean", + nullable: false, + defaultValue: false, + oldClrType: typeof(bool), + oldType: "boolean", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DiagramStatus", + table: "DeviceDiagrams", + type: "integer", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "integer", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DeviceDiagrams", + type: "uuid", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uuid"); + + migrationBuilder.CreateIndex( + name: "IX_FlowOperations_BaseEventEventId", + table: "FlowOperations", + column: "BaseEventEventId"); + + migrationBuilder.CreateIndex( + name: "IX_FlowOperations_FlowRuleRuleId", + table: "FlowOperations", + column: "FlowRuleRuleId"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceDiagrams_Customer_CustomerId", + table: "DeviceDiagrams", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceDiagrams_Tenant_TenantId", + table: "DeviceDiagrams", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceGraphs_Customer_CustomerId", + table: "DeviceGraphs", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceGraphs_Tenant_TenantId", + table: "DeviceGraphs", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceGraphToolBoxes_Customer_CustomerId", + table: "DeviceGraphToolBoxes", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceGraphToolBoxes_Tenant_TenantId", + table: "DeviceGraphToolBoxes", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormFieldInfos_Customer_CustomerId", + table: "DynamicFormFieldInfos", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormFieldInfos_Tenant_TenantId", + table: "DynamicFormFieldInfos", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormFieldValueInfos_Customer_CustomerId", + table: "DynamicFormFieldValueInfos", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormFieldValueInfos_Tenant_TenantId", + table: "DynamicFormFieldValueInfos", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormInfos_Customer_CustomerId", + table: "DynamicFormInfos", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormInfos_Tenant_TenantId", + table: "DynamicFormInfos", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_BaseEvents_BaseEventEventId", + table: "FlowOperations", + column: "BaseEventEventId", + principalTable: "BaseEvents", + principalColumn: "EventId"); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_FlowRules_FlowRuleRuleId", + table: "FlowOperations", + column: "FlowRuleRuleId", + principalTable: "FlowRules", + principalColumn: "RuleId"); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_Flows_FlowId", + table: "FlowOperations", + column: "FlowId", + principalTable: "Flows", + principalColumn: "FlowId"); + + migrationBuilder.AddForeignKey( + name: "FK_FlowRules_Customer_CustomerId", + table: "FlowRules", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_FlowRules_Tenant_TenantId", + table: "FlowRules", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Flows_Customer_CustomerId", + table: "Flows", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Flows_Tenant_TenantId", + table: "Flows", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_RuleTaskExecutors_Customer_CustomerId", + table: "RuleTaskExecutors", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_RuleTaskExecutors_Tenant_TenantId", + table: "RuleTaskExecutors", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_SubscriptionEvents_Customer_CustomerId", + table: "SubscriptionEvents", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_SubscriptionEvents_Tenant_TenantId", + table: "SubscriptionEvents", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_DeviceDiagrams_Customer_CustomerId", + table: "DeviceDiagrams"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceDiagrams_Tenant_TenantId", + table: "DeviceDiagrams"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceGraphs_Customer_CustomerId", + table: "DeviceGraphs"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceGraphs_Tenant_TenantId", + table: "DeviceGraphs"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceGraphToolBoxes_Customer_CustomerId", + table: "DeviceGraphToolBoxes"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceGraphToolBoxes_Tenant_TenantId", + table: "DeviceGraphToolBoxes"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormFieldInfos_Customer_CustomerId", + table: "DynamicFormFieldInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormFieldInfos_Tenant_TenantId", + table: "DynamicFormFieldInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormFieldValueInfos_Customer_CustomerId", + table: "DynamicFormFieldValueInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormFieldValueInfos_Tenant_TenantId", + table: "DynamicFormFieldValueInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormInfos_Customer_CustomerId", + table: "DynamicFormInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormInfos_Tenant_TenantId", + table: "DynamicFormInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_BaseEvents_BaseEventEventId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_FlowRules_FlowRuleRuleId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_Flows_FlowId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowRules_Customer_CustomerId", + table: "FlowRules"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowRules_Tenant_TenantId", + table: "FlowRules"); + + migrationBuilder.DropForeignKey( + name: "FK_Flows_Customer_CustomerId", + table: "Flows"); + + migrationBuilder.DropForeignKey( + name: "FK_Flows_Tenant_TenantId", + table: "Flows"); + + migrationBuilder.DropForeignKey( + name: "FK_RuleTaskExecutors_Customer_CustomerId", + table: "RuleTaskExecutors"); + + migrationBuilder.DropForeignKey( + name: "FK_RuleTaskExecutors_Tenant_TenantId", + table: "RuleTaskExecutors"); + + migrationBuilder.DropForeignKey( + name: "FK_SubscriptionEvents_Customer_CustomerId", + table: "SubscriptionEvents"); + + migrationBuilder.DropForeignKey( + name: "FK_SubscriptionEvents_Tenant_TenantId", + table: "SubscriptionEvents"); + + migrationBuilder.DropIndex( + name: "IX_FlowOperations_BaseEventEventId", + table: "FlowOperations"); + + migrationBuilder.DropIndex( + name: "IX_FlowOperations_FlowRuleRuleId", + table: "FlowOperations"); + + migrationBuilder.DropColumn( + name: "BaseEventEventId", + table: "FlowOperations"); + + migrationBuilder.DropColumn( + name: "FlowRuleRuleId", + table: "FlowOperations"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "SubscriptionEvents", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "SubscriptionEvents", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "RuleTaskExecutors", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "RuleTaskExecutors", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "Flows", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "Flows", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "FlowRules", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "FlowRules", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "NodeStatus", + table: "FlowOperations", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "FlowId", + table: "FlowOperations", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AddColumn( + name: "BaseEventId", + table: "FlowOperations", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "FlowRuleId", + table: "FlowOperations", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DynamicFormInfos", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FormStatus", + table: "DynamicFormInfos", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "FormCreator", + table: "DynamicFormInfos", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DynamicFormInfos", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "BizId", + table: "DynamicFormInfos", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DynamicFormFieldValueInfos", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FromId", + table: "DynamicFormFieldValueInfos", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "FieldValueType", + table: "DynamicFormFieldValueInfos", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "FieldId", + table: "DynamicFormFieldValueInfos", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DynamicFormFieldValueInfos", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "BizId", + table: "DynamicFormFieldValueInfos", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DynamicFormFieldInfos", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "IsRequired", + table: "DynamicFormFieldInfos", + type: "boolean", + nullable: true, + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "IsEnabled", + table: "DynamicFormFieldInfos", + type: "boolean", + nullable: true, + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "FormId", + table: "DynamicFormFieldInfos", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "FieldValueType", + table: "DynamicFormFieldInfos", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "FieldUIElement", + table: "DynamicFormFieldInfos", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "FieldStatus", + table: "DynamicFormFieldInfos", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "FieldMaxLength", + table: "DynamicFormFieldInfos", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DynamicFormFieldInfos", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "PortType", + table: "DevicePorts", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "PortStatus", + table: "DevicePorts", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "PortPhyType", + table: "DevicePorts", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "Creator", + table: "DevicePorts", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "MappingStatus", + table: "DevicePortMappings", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "MappingIndex", + table: "DevicePortMappings", + type: "numeric", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ToolBoxStatus", + table: "DeviceGraphToolBoxes", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetY", + table: "DeviceGraphToolBoxes", + type: "numeric", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetX", + table: "DeviceGraphToolBoxes", + type: "numeric", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetTopPer", + table: "DeviceGraphToolBoxes", + type: "numeric", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetLeftPer", + table: "DeviceGraphToolBoxes", + type: "numeric", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DeviceGraphToolBoxes", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeviceId", + table: "DeviceGraphToolBoxes", + type: "bigint", + nullable: true, + oldClrType: typeof(long), + oldType: "bigint"); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DeviceGraphToolBoxes", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DeviceGraphs", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphWidth", + table: "DeviceGraphs", + type: "numeric", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "GraphTextRefY", + table: "DeviceGraphs", + type: "numeric", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "GraphTextRefX", + table: "DeviceGraphs", + type: "numeric", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "GraphTextFontSize", + table: "DeviceGraphs", + type: "numeric", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "GraphStrokeWidth", + table: "DeviceGraphs", + type: "numeric", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "GraphPostionY", + table: "DeviceGraphs", + type: "numeric", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "GraphPostionX", + table: "DeviceGraphs", + type: "numeric", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "GraphHeight", + table: "DeviceGraphs", + type: "numeric", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DeviceGraphs", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DeviceDiagrams", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "IsDefault", + table: "DeviceDiagrams", + type: "boolean", + nullable: true, + oldClrType: typeof(bool), + oldType: "boolean"); + + migrationBuilder.AlterColumn( + name: "DiagramStatus", + table: "DeviceDiagrams", + type: "integer", + nullable: true, + oldClrType: typeof(int), + oldType: "integer"); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DeviceDiagrams", + type: "uuid", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "uuid", + oldNullable: true); + + migrationBuilder.CreateIndex( + name: "IX_FlowOperations_BaseEventId", + table: "FlowOperations", + column: "BaseEventId"); + + migrationBuilder.CreateIndex( + name: "IX_FlowOperations_FlowRuleId", + table: "FlowOperations", + column: "FlowRuleId"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceDiagrams_Customer_CustomerId", + table: "DeviceDiagrams", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceDiagrams_Tenant_TenantId", + table: "DeviceDiagrams", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceGraphs_Customer_CustomerId", + table: "DeviceGraphs", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceGraphs_Tenant_TenantId", + table: "DeviceGraphs", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceGraphToolBoxes_Customer_CustomerId", + table: "DeviceGraphToolBoxes", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceGraphToolBoxes_Tenant_TenantId", + table: "DeviceGraphToolBoxes", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormFieldInfos_Customer_CustomerId", + table: "DynamicFormFieldInfos", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormFieldInfos_Tenant_TenantId", + table: "DynamicFormFieldInfos", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormFieldValueInfos_Customer_CustomerId", + table: "DynamicFormFieldValueInfos", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormFieldValueInfos_Tenant_TenantId", + table: "DynamicFormFieldValueInfos", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormInfos_Customer_CustomerId", + table: "DynamicFormInfos", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormInfos_Tenant_TenantId", + table: "DynamicFormInfos", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_BaseEvents_BaseEventId", + table: "FlowOperations", + column: "BaseEventId", + principalTable: "BaseEvents", + principalColumn: "EventId", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_FlowRules_FlowRuleId", + table: "FlowOperations", + column: "FlowRuleId", + principalTable: "FlowRules", + principalColumn: "RuleId", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_Flows_FlowId", + table: "FlowOperations", + column: "FlowId", + principalTable: "Flows", + principalColumn: "FlowId", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_FlowRules_Customer_CustomerId", + table: "FlowRules", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_FlowRules_Tenant_TenantId", + table: "FlowRules", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Flows_Customer_CustomerId", + table: "Flows", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Flows_Tenant_TenantId", + table: "Flows", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_RuleTaskExecutors_Customer_CustomerId", + table: "RuleTaskExecutors", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_RuleTaskExecutors_Tenant_TenantId", + table: "RuleTaskExecutors", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_SubscriptionEvents_Customer_CustomerId", + table: "SubscriptionEvents", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_SubscriptionEvents_Tenant_TenantId", + table: "SubscriptionEvents", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/IoTSharp.Data.PostgreSQL/Migrations/ApplicationDbContextModelSnapshot.cs b/IoTSharp.Data.PostgreSQL/Migrations/ApplicationDbContextModelSnapshot.cs index 2ba840f012bbd6d254c35dd5222036fef4006f31..e46765d4e42ba1e5f060eb6d04b95b3d08f260ae 100644 --- a/IoTSharp.Data.PostgreSQL/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/IoTSharp.Data.PostgreSQL/Migrations/ApplicationDbContextModelSnapshot.cs @@ -529,7 +529,7 @@ namespace IoTSharp.Migrations b.Property("Creator") .HasColumnType("uuid"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("uuid"); b.Property("DiagramDesc") @@ -541,13 +541,13 @@ namespace IoTSharp.Migrations b.Property("DiagramName") .HasColumnType("text"); - b.Property("DiagramStatus") + b.Property("DiagramStatus") .HasColumnType("integer"); - b.Property("IsDefault") + b.Property("IsDefault") .HasColumnType("boolean"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("uuid"); b.HasKey("DiagramId"); @@ -571,7 +571,7 @@ namespace IoTSharp.Migrations b.Property("Creator") .HasColumnType("uuid"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("uuid"); b.Property("DeviceDiagramDiagramId") @@ -586,14 +586,14 @@ namespace IoTSharp.Migrations b.Property("GraphFill") .HasColumnType("text"); - b.Property("GraphHeight") - .HasColumnType("numeric"); + b.Property("GraphHeight") + .HasColumnType("integer"); - b.Property("GraphPostionX") - .HasColumnType("numeric"); + b.Property("GraphPostionX") + .HasColumnType("integer"); - b.Property("GraphPostionY") - .HasColumnType("numeric"); + b.Property("GraphPostionY") + .HasColumnType("integer"); b.Property("GraphShape") .HasColumnType("text"); @@ -601,8 +601,8 @@ namespace IoTSharp.Migrations b.Property("GraphStroke") .HasColumnType("text"); - b.Property("GraphStrokeWidth") - .HasColumnType("numeric"); + b.Property("GraphStrokeWidth") + .HasColumnType("integer"); b.Property("GraphTextAnchor") .HasColumnType("text"); @@ -613,22 +613,22 @@ namespace IoTSharp.Migrations b.Property("GraphTextFontFamily") .HasColumnType("text"); - b.Property("GraphTextFontSize") - .HasColumnType("numeric"); + b.Property("GraphTextFontSize") + .HasColumnType("integer"); - b.Property("GraphTextRefX") - .HasColumnType("numeric"); + b.Property("GraphTextRefX") + .HasColumnType("integer"); - b.Property("GraphTextRefY") - .HasColumnType("numeric"); + b.Property("GraphTextRefY") + .HasColumnType("integer"); b.Property("GraphTextVerticalAnchor") .HasColumnType("text"); - b.Property("GraphWidth") - .HasColumnType("numeric"); + b.Property("GraphWidth") + .HasColumnType("integer"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("uuid"); b.HasKey("GraphId"); @@ -660,13 +660,13 @@ namespace IoTSharp.Migrations b.Property("Creator") .HasColumnType("uuid"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("uuid"); - b.Property("DeviceId") + b.Property("DeviceId") .HasColumnType("bigint"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("uuid"); b.Property("ToolBoxIcon") @@ -675,22 +675,22 @@ namespace IoTSharp.Migrations b.Property("ToolBoxName") .HasColumnType("text"); - b.Property("ToolBoxOffsetLeftPer") - .HasColumnType("numeric"); + b.Property("ToolBoxOffsetLeftPer") + .HasColumnType("integer"); - b.Property("ToolBoxOffsetTopPer") - .HasColumnType("numeric"); + b.Property("ToolBoxOffsetTopPer") + .HasColumnType("integer"); - b.Property("ToolBoxOffsetX") - .HasColumnType("numeric"); + b.Property("ToolBoxOffsetX") + .HasColumnType("integer"); - b.Property("ToolBoxOffsetY") - .HasColumnType("numeric"); + b.Property("ToolBoxOffsetY") + .HasColumnType("integer"); b.Property("ToolBoxRequestUri") .HasColumnType("text"); - b.Property("ToolBoxStatus") + b.Property("ToolBoxStatus") .HasColumnType("integer"); b.Property("ToolBoxType") @@ -810,7 +810,7 @@ namespace IoTSharp.Migrations b.Property("CreateDate") .HasColumnType("timestamp with time zone"); - b.Property("Creator") + b.Property("Creator") .HasColumnType("bigint"); b.Property("DeviceId") @@ -825,16 +825,16 @@ namespace IoTSharp.Migrations b.Property("PortName") .HasColumnType("text"); - b.Property("PortPhyType") + b.Property("PortPhyType") .HasColumnType("integer"); b.Property("PortPic") .HasColumnType("text"); - b.Property("PortStatus") + b.Property("PortStatus") .HasColumnType("integer"); - b.Property("PortType") + b.Property("PortType") .HasColumnType("integer"); b.HasKey("PortId"); @@ -854,10 +854,10 @@ namespace IoTSharp.Migrations b.Property("Creator") .HasColumnType("uuid"); - b.Property("MappingIndex") - .HasColumnType("numeric"); + b.Property("MappingIndex") + .HasColumnType("integer"); - b.Property("MappingStatus") + b.Property("MappingStatus") .HasColumnType("integer"); b.Property("SourceDeviceId") @@ -924,7 +924,7 @@ namespace IoTSharp.Migrations b.Property("Creator") .HasColumnType("uuid"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("uuid"); b.Property("FieldCode") @@ -939,7 +939,7 @@ namespace IoTSharp.Migrations b.Property("FieldI18nKey") .HasColumnType("text"); - b.Property("FieldMaxLength") + b.Property("FieldMaxLength") .HasColumnType("integer"); b.Property("FieldName") @@ -951,10 +951,10 @@ namespace IoTSharp.Migrations b.Property("FieldPocoTypeName") .HasColumnType("text"); - b.Property("FieldStatus") + b.Property("FieldStatus") .HasColumnType("integer"); - b.Property("FieldUIElement") + b.Property("FieldUIElement") .HasColumnType("bigint"); b.Property("FieldUIElementSchema") @@ -972,22 +972,22 @@ namespace IoTSharp.Migrations b.Property("FieldValueLocalDataSource") .HasColumnType("text"); - b.Property("FieldValueType") + b.Property("FieldValueType") .HasColumnType("integer"); b.Property("FieldValueTypeName") .HasColumnType("text"); - b.Property("FormId") + b.Property("FormId") .HasColumnType("bigint"); - b.Property("IsEnabled") + b.Property("IsEnabled") .HasColumnType("boolean"); - b.Property("IsRequired") + b.Property("IsRequired") .HasColumnType("boolean"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("uuid"); b.HasKey("FieldId"); @@ -1007,13 +1007,13 @@ namespace IoTSharp.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("FieldValueId")); - b.Property("BizId") + b.Property("BizId") .HasColumnType("bigint"); b.Property("Creator") .HasColumnType("uuid"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("uuid"); b.Property("FieldCode") @@ -1022,7 +1022,7 @@ namespace IoTSharp.Migrations b.Property("FieldCreateDate") .HasColumnType("timestamp with time zone"); - b.Property("FieldId") + b.Property("FieldId") .HasColumnType("bigint"); b.Property("FieldName") @@ -1034,13 +1034,13 @@ namespace IoTSharp.Migrations b.Property("FieldValue") .HasColumnType("text"); - b.Property("FieldValueType") + b.Property("FieldValueType") .HasColumnType("bigint"); - b.Property("FromId") + b.Property("FromId") .HasColumnType("bigint"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("uuid"); b.HasKey("FieldValueId"); @@ -1060,16 +1060,16 @@ namespace IoTSharp.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("FormId")); - b.Property("BizId") + b.Property("BizId") .HasColumnType("bigint"); b.Property("Creator") .HasColumnType("uuid"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("uuid"); - b.Property("FormCreator") + b.Property("FormCreator") .HasColumnType("bigint"); b.Property("FormDesc") @@ -1084,7 +1084,7 @@ namespace IoTSharp.Migrations b.Property("FormSchame") .HasColumnType("text"); - b.Property("FormStatus") + b.Property("FormStatus") .HasColumnType("integer"); b.Property("FromCreateDate") @@ -1096,7 +1096,7 @@ namespace IoTSharp.Migrations b.Property("ModelClass") .HasColumnType("text"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("uuid"); b.Property("Url") @@ -1129,7 +1129,7 @@ namespace IoTSharp.Migrations b.Property("Createor") .HasColumnType("uuid"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("uuid"); b.Property("ExecutorId") @@ -1183,7 +1183,7 @@ namespace IoTSharp.Migrations b.Property("TargetId") .HasColumnType("text"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("uuid"); b.Property("TestStatus") @@ -1220,7 +1220,7 @@ namespace IoTSharp.Migrations b.Property("AddDate") .HasColumnType("timestamp with time zone"); - b.Property("BaseEventId") + b.Property("BaseEventEventId") .HasColumnType("uuid"); b.Property("BizId") @@ -1229,13 +1229,13 @@ namespace IoTSharp.Migrations b.Property("Data") .HasColumnType("text"); - b.Property("FlowId") + b.Property("FlowId") .HasColumnType("uuid"); - b.Property("FlowRuleId") + b.Property("FlowRuleRuleId") .HasColumnType("uuid"); - b.Property("NodeStatus") + b.Property("NodeStatus") .HasColumnType("integer"); b.Property("OperationDesc") @@ -1252,11 +1252,11 @@ namespace IoTSharp.Migrations b.HasKey("OperationId"); - b.HasIndex("BaseEventId"); + b.HasIndex("BaseEventEventId"); b.HasIndex("FlowId"); - b.HasIndex("FlowRuleId"); + b.HasIndex("FlowRuleRuleId"); b.ToTable("FlowOperations"); }); @@ -1276,7 +1276,7 @@ namespace IoTSharp.Migrations b.Property("Creator") .HasColumnType("text"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("uuid"); b.Property("DefinitionsXml") @@ -1313,7 +1313,7 @@ namespace IoTSharp.Migrations b.Property("SubVersion") .HasColumnType("double precision"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("uuid"); b.Property("Version") @@ -1400,7 +1400,7 @@ namespace IoTSharp.Migrations b.Property("Creator") .HasColumnType("uuid"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("uuid"); b.Property("DefaultConfig") @@ -1424,7 +1424,7 @@ namespace IoTSharp.Migrations b.Property("Tag") .HasColumnType("text"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("uuid"); b.Property("TestStatus") @@ -1460,7 +1460,7 @@ namespace IoTSharp.Migrations b.Property("Creator") .HasColumnType("uuid"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("uuid"); b.Property("EventDesc") @@ -1481,7 +1481,7 @@ namespace IoTSharp.Migrations b.Property("EventTag") .HasColumnType("text"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("uuid"); b.Property("Type") @@ -1933,15 +1933,11 @@ namespace IoTSharp.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -1952,9 +1948,7 @@ namespace IoTSharp.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.DeviceDiagram", "DeviceDiagram") .WithMany() @@ -1962,9 +1956,7 @@ namespace IoTSharp.Migrations b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -1977,15 +1969,11 @@ namespace IoTSharp.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2033,15 +2021,11 @@ namespace IoTSharp.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2052,15 +2036,11 @@ namespace IoTSharp.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2071,15 +2051,11 @@ namespace IoTSharp.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2090,9 +2066,7 @@ namespace IoTSharp.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.RuleTaskExecutor", "Executor") .WithMany() @@ -2104,9 +2078,7 @@ namespace IoTSharp.Migrations b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2121,21 +2093,15 @@ namespace IoTSharp.Migrations { b.HasOne("IoTSharp.Data.BaseEvent", "BaseEvent") .WithMany() - .HasForeignKey("BaseEventId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("BaseEventEventId"); b.HasOne("IoTSharp.Data.Flow", "Flow") .WithMany() - .HasForeignKey("FlowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("FlowId"); b.HasOne("IoTSharp.Data.FlowRule", "FlowRule") .WithMany() - .HasForeignKey("FlowRuleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("FlowRuleRuleId"); b.Navigation("BaseEvent"); @@ -2148,15 +2114,11 @@ namespace IoTSharp.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2197,15 +2159,11 @@ namespace IoTSharp.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2216,15 +2174,11 @@ namespace IoTSharp.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); diff --git a/IoTSharp.Data.Sqlite/Migrations/20220212100305_FixTenantInfo.Designer.cs b/IoTSharp.Data.Sqlite/Migrations/20220212100305_FixTenantInfo.Designer.cs new file mode 100644 index 0000000000000000000000000000000000000000..ebcef7cecf82e89b94e21f8031952cac96dbe93c --- /dev/null +++ b/IoTSharp.Data.Sqlite/Migrations/20220212100305_FixTenantInfo.Designer.cs @@ -0,0 +1,2269 @@ +// +using System; +using IoTSharp.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace IoTSharp.Data.Sqlite.Migrations +{ + [DbContext(typeof(ApplicationDbContext))] + [Migration("20220212100305_FixTenantInfo")] + partial class FixTenantInfo + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.2"); + + modelBuilder.Entity("IoTSharp.Data.AuditLog", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("ActionData") + .HasColumnType("TEXT"); + + b.Property("ActionName") + .HasColumnType("TEXT"); + + b.Property("ActionResult") + .HasColumnType("TEXT"); + + b.Property("ActiveDateTime") + .HasColumnType("TEXT"); + + b.Property("CustomerId") + .HasColumnType("TEXT"); + + b.Property("ObjectID") + .HasColumnType("TEXT"); + + b.Property("ObjectName") + .HasColumnType("TEXT"); + + b.Property("ObjectType") + .HasColumnType("INTEGER"); + + b.Property("TenantId") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("UserName") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("AuditLog"); + }); + + modelBuilder.Entity("IoTSharp.Data.AuthorizedKey", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("AuthToken") + .HasColumnType("TEXT"); + + b.Property("CustomerId") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("TenantId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("AuthorizedKeys"); + }); + + modelBuilder.Entity("IoTSharp.Data.BaseDictionary", b => + { + b.Property("DictionaryId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Dictionary18NKeyName") + .HasColumnType("TEXT"); + + b.Property("DictionaryColor") + .HasColumnType("TEXT"); + + b.Property("DictionaryDesc") + .HasColumnType("TEXT"); + + b.Property("DictionaryGroupId") + .HasColumnType("INTEGER"); + + b.Property("DictionaryIcon") + .HasColumnType("TEXT"); + + b.Property("DictionaryName") + .HasColumnType("TEXT"); + + b.Property("DictionaryPattern") + .HasColumnType("TEXT"); + + b.Property("DictionaryStatus") + .HasColumnType("INTEGER"); + + b.Property("DictionaryTag") + .HasColumnType("TEXT"); + + b.Property("DictionaryValue") + .HasColumnType("TEXT"); + + b.Property("DictionaryValueType") + .HasColumnType("INTEGER"); + + b.Property("DictionaryValueTypeName") + .HasColumnType("TEXT"); + + b.HasKey("DictionaryId"); + + b.ToTable("BaseDictionaries"); + }); + + modelBuilder.Entity("IoTSharp.Data.BaseDictionaryGroup", b => + { + b.Property("DictionaryGroupId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DictionaryGroup18NKeyName") + .HasColumnType("TEXT"); + + b.Property("DictionaryGroupDesc") + .HasColumnType("TEXT"); + + b.Property("DictionaryGroupKey") + .HasColumnType("TEXT"); + + b.Property("DictionaryGroupName") + .HasColumnType("TEXT"); + + b.Property("DictionaryGroupStatus") + .HasColumnType("INTEGER"); + + b.Property("DictionaryGroupValueType") + .HasColumnType("INTEGER"); + + b.Property("DictionaryGroupValueTypeName") + .HasColumnType("TEXT"); + + b.HasKey("DictionaryGroupId"); + + b.ToTable("BaseDictionaryGroups"); + }); + + modelBuilder.Entity("IoTSharp.Data.BaseEvent", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("BizData") + .HasColumnType("TEXT"); + + b.Property("Bizid") + .HasColumnType("TEXT"); + + b.Property("CreaterDateTime") + .HasColumnType("TEXT"); + + b.Property("Creator") + .HasColumnType("TEXT"); + + b.Property("CustomerId") + .HasColumnType("TEXT"); + + b.Property("EventDesc") + .HasColumnType("TEXT"); + + b.Property("EventName") + .HasColumnType("TEXT"); + + b.Property("EventStaus") + .HasColumnType("INTEGER"); + + b.Property("FlowRuleRuleId") + .HasColumnType("TEXT"); + + b.Property("MataData") + .HasColumnType("TEXT"); + + b.Property("TenantId") + .HasColumnType("TEXT"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.HasKey("EventId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("FlowRuleRuleId"); + + b.HasIndex("TenantId"); + + b.ToTable("BaseEvents"); + }); + + modelBuilder.Entity("IoTSharp.Data.BaseI18N", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AddDate") + .HasColumnType("TEXT"); + + b.Property("KeyName") + .HasColumnType("TEXT"); + + b.Property("ResouceDesc") + .HasColumnType("TEXT"); + + b.Property("ResouceGroupId") + .HasColumnType("INTEGER"); + + b.Property("ResourceId") + .HasColumnType("INTEGER"); + + b.Property("ResourceKey") + .HasColumnType("TEXT"); + + b.Property("ResourceTag") + .HasColumnType("TEXT"); + + b.Property("ResourceType") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("ValueBG") + .HasColumnType("TEXT"); + + b.Property("ValueCS") + .HasColumnType("TEXT"); + + b.Property("ValueDA") + .HasColumnType("TEXT"); + + b.Property("ValueDEDE") + .HasColumnType("TEXT"); + + b.Property("ValueELGR") + .HasColumnType("TEXT"); + + b.Property("ValueENGR") + .HasColumnType("TEXT"); + + b.Property("ValueENUS") + .HasColumnType("TEXT"); + + b.Property("ValueESES") + .HasColumnType("TEXT"); + + b.Property("ValueFI") + .HasColumnType("TEXT"); + + b.Property("ValueFRFR") + .HasColumnType("TEXT"); + + b.Property("ValueHE") + .HasColumnType("TEXT"); + + b.Property("ValueHRHR") + .HasColumnType("TEXT"); + + b.Property("ValueHU") + .HasColumnType("TEXT"); + + b.Property("ValueITIT") + .HasColumnType("TEXT"); + + b.Property("ValueJAJP") + .HasColumnType("TEXT"); + + b.Property("ValueKOKR") + .HasColumnType("TEXT"); + + b.Property("ValueNL") + .HasColumnType("TEXT"); + + b.Property("ValuePLPL") + .HasColumnType("TEXT"); + + b.Property("ValuePT") + .HasColumnType("TEXT"); + + b.Property("ValueSLSL") + .HasColumnType("TEXT"); + + b.Property("ValueSR") + .HasColumnType("TEXT"); + + b.Property("ValueSV") + .HasColumnType("TEXT"); + + b.Property("ValueTRTR") + .HasColumnType("TEXT"); + + b.Property("ValueUK") + .HasColumnType("TEXT"); + + b.Property("ValueVI") + .HasColumnType("TEXT"); + + b.Property("ValueZHCN") + .HasColumnType("TEXT"); + + b.Property("ValueZHTW") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.ToTable("BaseI18Ns"); + }); + + modelBuilder.Entity("IoTSharp.Data.Customer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Address") + .HasColumnType("TEXT"); + + b.Property("City") + .HasColumnType("TEXT"); + + b.Property("Country") + .HasColumnType("TEXT"); + + b.Property("Email") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Phone") + .HasColumnType("TEXT"); + + b.Property("Province") + .HasColumnType("TEXT"); + + b.Property("Street") + .HasColumnType("TEXT"); + + b.Property("TenantId") + .HasColumnType("TEXT"); + + b.Property("ZipCode") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("TenantId"); + + b.ToTable("Customer"); + }); + + modelBuilder.Entity("IoTSharp.Data.DataStorage", b => + { + b.Property("Catalog") + .HasColumnType("INTEGER") + .HasColumnOrder(0); + + b.Property("DeviceId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("KeyName") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("DataSide") + .HasColumnType("INTEGER") + .HasColumnOrder(4); + + b.Property("DateTime") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("Type") + .HasColumnType("INTEGER") + .HasColumnOrder(5); + + b.Property("Value_Binary") + .HasColumnType("BLOB"); + + b.Property("Value_Boolean") + .HasColumnType("INTEGER"); + + b.Property("Value_DateTime") + .HasColumnType("TEXT"); + + b.Property("Value_Double") + .HasColumnType("REAL"); + + b.Property("Value_Json") + .HasColumnType("TEXT"); + + b.Property("Value_Long") + .HasColumnType("INTEGER"); + + b.Property("Value_String") + .HasColumnType("TEXT"); + + b.Property("Value_XML") + .HasColumnType("TEXT"); + + b.HasKey("Catalog", "DeviceId", "KeyName"); + + b.HasIndex("Catalog"); + + b.HasIndex("Catalog", "DeviceId"); + + b.ToTable("DataStorage"); + + b.HasDiscriminator("Catalog").HasValue(0); + }); + + modelBuilder.Entity("IoTSharp.Data.Device", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("AuthorizedKeyId") + .HasColumnType("TEXT"); + + b.Property("CustomerId") + .HasColumnType("TEXT"); + + b.Property("DeviceModelId") + .HasColumnType("TEXT"); + + b.Property("DeviceType") + .HasColumnType("INTEGER"); + + b.Property("LastActive") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Online") + .HasColumnType("INTEGER"); + + b.Property("OwnerId") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("INTEGER"); + + b.Property("TenantId") + .HasColumnType("TEXT"); + + b.Property("Timeout") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("AuthorizedKeyId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("DeviceModelId"); + + b.HasIndex("OwnerId"); + + b.HasIndex("TenantId"); + + b.ToTable("Device"); + + b.HasDiscriminator("DeviceType").HasValue(0); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceDiagram", b => + { + b.Property("DiagramId") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreateDate") + .HasColumnType("TEXT"); + + b.Property("Creator") + .HasColumnType("TEXT"); + + b.Property("CustomerId") + .HasColumnType("TEXT"); + + b.Property("DiagramDesc") + .HasColumnType("TEXT"); + + b.Property("DiagramImage") + .HasColumnType("TEXT"); + + b.Property("DiagramName") + .HasColumnType("TEXT"); + + b.Property("DiagramStatus") + .HasColumnType("INTEGER"); + + b.Property("IsDefault") + .HasColumnType("INTEGER"); + + b.Property("TenantId") + .HasColumnType("TEXT"); + + b.HasKey("DiagramId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("DeviceDiagrams"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceGraph", b => + { + b.Property("GraphId") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreateDate") + .HasColumnType("TEXT"); + + b.Property("Creator") + .HasColumnType("TEXT"); + + b.Property("CustomerId") + .HasColumnType("TEXT"); + + b.Property("DeviceDiagramDiagramId") + .HasColumnType("TEXT"); + + b.Property("DeviceId") + .HasColumnType("TEXT"); + + b.Property("GraphElementId") + .HasColumnType("TEXT"); + + b.Property("GraphFill") + .HasColumnType("TEXT"); + + b.Property("GraphHeight") + .HasColumnType("INTEGER"); + + b.Property("GraphPostionX") + .HasColumnType("INTEGER"); + + b.Property("GraphPostionY") + .HasColumnType("INTEGER"); + + b.Property("GraphShape") + .HasColumnType("TEXT"); + + b.Property("GraphStroke") + .HasColumnType("TEXT"); + + b.Property("GraphStrokeWidth") + .HasColumnType("INTEGER"); + + b.Property("GraphTextAnchor") + .HasColumnType("TEXT"); + + b.Property("GraphTextFill") + .HasColumnType("TEXT"); + + b.Property("GraphTextFontFamily") + .HasColumnType("TEXT"); + + b.Property("GraphTextFontSize") + .HasColumnType("INTEGER"); + + b.Property("GraphTextRefX") + .HasColumnType("INTEGER"); + + b.Property("GraphTextRefY") + .HasColumnType("INTEGER"); + + b.Property("GraphTextVerticalAnchor") + .HasColumnType("TEXT"); + + b.Property("GraphWidth") + .HasColumnType("INTEGER"); + + b.Property("TenantId") + .HasColumnType("TEXT"); + + b.HasKey("GraphId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("DeviceDiagramDiagramId"); + + b.HasIndex("TenantId"); + + b.ToTable("DeviceGraphs"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceGraphToolBox", b => + { + b.Property("ToolBoxId") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CommondParam") + .HasColumnType("TEXT"); + + b.Property("CommondType") + .HasColumnType("TEXT"); + + b.Property("CreateDate") + .HasColumnType("TEXT"); + + b.Property("Creator") + .HasColumnType("TEXT"); + + b.Property("CustomerId") + .HasColumnType("TEXT"); + + b.Property("DeviceId") + .HasColumnType("INTEGER"); + + b.Property("TenantId") + .HasColumnType("TEXT"); + + b.Property("ToolBoxIcon") + .HasColumnType("TEXT"); + + b.Property("ToolBoxName") + .HasColumnType("TEXT"); + + b.Property("ToolBoxOffsetLeftPer") + .HasColumnType("INTEGER"); + + b.Property("ToolBoxOffsetTopPer") + .HasColumnType("INTEGER"); + + b.Property("ToolBoxOffsetX") + .HasColumnType("INTEGER"); + + b.Property("ToolBoxOffsetY") + .HasColumnType("INTEGER"); + + b.Property("ToolBoxRequestUri") + .HasColumnType("TEXT"); + + b.Property("ToolBoxStatus") + .HasColumnType("INTEGER"); + + b.Property("ToolBoxType") + .HasColumnType("TEXT"); + + b.HasKey("ToolBoxId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("DeviceGraphToolBoxes"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceIdentity", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("DeviceId") + .HasColumnType("TEXT"); + + b.Property("IdentityId") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("IdentityType") + .HasColumnType("INTEGER"); + + b.Property("IdentityValue") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("DeviceId") + .IsUnique(); + + b.ToTable("DeviceIdentities"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceModel", b => + { + b.Property("DeviceModelId") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreateDateTime") + .HasColumnType("TEXT"); + + b.Property("Creator") + .HasColumnType("TEXT"); + + b.Property("ModelDesc") + .HasColumnType("TEXT"); + + b.Property("ModelName") + .HasColumnType("TEXT"); + + b.Property("ModelStatus") + .HasColumnType("INTEGER"); + + b.HasKey("DeviceModelId"); + + b.ToTable("DeviceModels"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceModelCommand", b => + { + b.Property("CommandId") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CommandI18N") + .HasColumnType("TEXT"); + + b.Property("CommandName") + .HasColumnType("TEXT"); + + b.Property("CommandParams") + .HasColumnType("TEXT"); + + b.Property("CommandStatus") + .HasColumnType("INTEGER"); + + b.Property("CommandTemplate") + .HasColumnType("TEXT"); + + b.Property("CommandTitle") + .HasColumnType("TEXT"); + + b.Property("CommandType") + .HasColumnType("INTEGER"); + + b.Property("CreateDateTime") + .HasColumnType("TEXT"); + + b.Property("Creator") + .HasColumnType("TEXT"); + + b.Property("DeviceModelId") + .HasColumnType("TEXT"); + + b.HasKey("CommandId"); + + b.HasIndex("DeviceModelId"); + + b.ToTable("DeviceModelCommands"); + }); + + modelBuilder.Entity("IoTSharp.Data.DevicePort", b => + { + b.Property("PortId") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreateDate") + .HasColumnType("TEXT"); + + b.Property("Creator") + .HasColumnType("INTEGER"); + + b.Property("DeviceId") + .HasColumnType("TEXT"); + + b.Property("PortDesc") + .HasColumnType("TEXT"); + + b.Property("PortElementId") + .HasColumnType("TEXT"); + + b.Property("PortName") + .HasColumnType("TEXT"); + + b.Property("PortPhyType") + .HasColumnType("INTEGER"); + + b.Property("PortPic") + .HasColumnType("TEXT"); + + b.Property("PortStatus") + .HasColumnType("INTEGER"); + + b.Property("PortType") + .HasColumnType("INTEGER"); + + b.HasKey("PortId"); + + b.ToTable("DevicePorts"); + }); + + modelBuilder.Entity("IoTSharp.Data.DevicePortMapping", b => + { + b.Property("MappingId") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreateDate") + .HasColumnType("TEXT"); + + b.Property("Creator") + .HasColumnType("TEXT"); + + b.Property("MappingIndex") + .HasColumnType("INTEGER"); + + b.Property("MappingStatus") + .HasColumnType("INTEGER"); + + b.Property("SourceDeviceId") + .HasColumnType("TEXT"); + + b.Property("SourceElementId") + .HasColumnType("TEXT"); + + b.Property("SourceId") + .HasColumnType("TEXT"); + + b.Property("TargeId") + .HasColumnType("TEXT"); + + b.Property("TargetDeviceId") + .HasColumnType("TEXT"); + + b.Property("TargetElementId") + .HasColumnType("TEXT"); + + b.HasKey("MappingId"); + + b.ToTable("DevicePortMappings"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceRule", b => + { + b.Property("DeviceRuleId") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("ConfigDateTime") + .HasColumnType("TEXT"); + + b.Property("ConfigUser") + .HasColumnType("TEXT"); + + b.Property("DeviceId") + .HasColumnType("TEXT"); + + b.Property("EnableTrace") + .HasColumnType("INTEGER"); + + b.Property("FlowRuleRuleId") + .HasColumnType("TEXT"); + + b.HasKey("DeviceRuleId"); + + b.HasIndex("DeviceId"); + + b.HasIndex("FlowRuleRuleId"); + + b.ToTable("DeviceRules"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormFieldInfo", b => + { + b.Property("FieldId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Creator") + .HasColumnType("TEXT"); + + b.Property("CustomerId") + .HasColumnType("TEXT"); + + b.Property("FieldCode") + .HasColumnType("TEXT"); + + b.Property("FieldCreateDate") + .HasColumnType("TEXT"); + + b.Property("FieldEditDate") + .HasColumnType("TEXT"); + + b.Property("FieldI18nKey") + .HasColumnType("TEXT"); + + b.Property("FieldMaxLength") + .HasColumnType("INTEGER"); + + b.Property("FieldName") + .HasColumnType("TEXT"); + + b.Property("FieldPattern") + .HasColumnType("TEXT"); + + b.Property("FieldPocoTypeName") + .HasColumnType("TEXT"); + + b.Property("FieldStatus") + .HasColumnType("INTEGER"); + + b.Property("FieldUIElement") + .HasColumnType("INTEGER"); + + b.Property("FieldUIElementSchema") + .HasColumnType("TEXT"); + + b.Property("FieldUnit") + .HasColumnType("TEXT"); + + b.Property("FieldValue") + .HasColumnType("TEXT"); + + b.Property("FieldValueDataSource") + .HasColumnType("TEXT"); + + b.Property("FieldValueLocalDataSource") + .HasColumnType("TEXT"); + + b.Property("FieldValueType") + .HasColumnType("INTEGER"); + + b.Property("FieldValueTypeName") + .HasColumnType("TEXT"); + + b.Property("FormId") + .HasColumnType("INTEGER"); + + b.Property("IsEnabled") + .HasColumnType("INTEGER"); + + b.Property("IsRequired") + .HasColumnType("INTEGER"); + + b.Property("TenantId") + .HasColumnType("TEXT"); + + b.HasKey("FieldId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("DynamicFormFieldInfos"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormFieldValueInfo", b => + { + b.Property("FieldValueId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("BizId") + .HasColumnType("INTEGER"); + + b.Property("Creator") + .HasColumnType("TEXT"); + + b.Property("CustomerId") + .HasColumnType("TEXT"); + + b.Property("FieldCode") + .HasColumnType("TEXT"); + + b.Property("FieldCreateDate") + .HasColumnType("TEXT"); + + b.Property("FieldId") + .HasColumnType("INTEGER"); + + b.Property("FieldName") + .HasColumnType("TEXT"); + + b.Property("FieldUnit") + .HasColumnType("TEXT"); + + b.Property("FieldValue") + .HasColumnType("TEXT"); + + b.Property("FieldValueType") + .HasColumnType("INTEGER"); + + b.Property("FromId") + .HasColumnType("INTEGER"); + + b.Property("TenantId") + .HasColumnType("TEXT"); + + b.HasKey("FieldValueId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("DynamicFormFieldValueInfos"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormInfo", b => + { + b.Property("FormId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("BizId") + .HasColumnType("INTEGER"); + + b.Property("Creator") + .HasColumnType("TEXT"); + + b.Property("CustomerId") + .HasColumnType("TEXT"); + + b.Property("FormCreator") + .HasColumnType("INTEGER"); + + b.Property("FormDesc") + .HasColumnType("TEXT"); + + b.Property("FormLayout") + .HasColumnType("TEXT"); + + b.Property("FormName") + .HasColumnType("TEXT"); + + b.Property("FormSchame") + .HasColumnType("TEXT"); + + b.Property("FormStatus") + .HasColumnType("INTEGER"); + + b.Property("FromCreateDate") + .HasColumnType("TEXT"); + + b.Property("IsCompact") + .HasColumnType("INTEGER"); + + b.Property("ModelClass") + .HasColumnType("TEXT"); + + b.Property("TenantId") + .HasColumnType("TEXT"); + + b.Property("Url") + .HasColumnType("TEXT"); + + b.HasKey("FormId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("DynamicFormInfos"); + }); + + modelBuilder.Entity("IoTSharp.Data.Flow", b => + { + b.Property("FlowId") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Conditionexpression") + .HasColumnType("TEXT"); + + b.Property("CreateDate") + .HasColumnType("TEXT"); + + b.Property("CreateId") + .HasColumnType("TEXT"); + + b.Property("Createor") + .HasColumnType("TEXT"); + + b.Property("CustomerId") + .HasColumnType("TEXT"); + + b.Property("ExecutorId") + .HasColumnType("TEXT"); + + b.Property("FlowRuleRuleId") + .HasColumnType("TEXT"); + + b.Property("FlowStatus") + .HasColumnType("INTEGER"); + + b.Property("FlowType") + .HasColumnType("TEXT"); + + b.Property("Flowdesc") + .HasColumnType("TEXT"); + + b.Property("Flowname") + .HasColumnType("TEXT"); + + b.Property("Incoming") + .HasColumnType("TEXT"); + + b.Property("NodeProcessClass") + .HasColumnType("TEXT"); + + b.Property("NodeProcessMethod") + .HasColumnType("TEXT"); + + b.Property("NodeProcessParams") + .HasColumnType("TEXT"); + + b.Property("NodeProcessScript") + .HasColumnType("TEXT"); + + b.Property("NodeProcessScriptType") + .HasColumnType("TEXT"); + + b.Property("NodeProcessType") + .HasColumnType("TEXT"); + + b.Property("ObjectId") + .HasColumnType("TEXT"); + + b.Property("Outgoing") + .HasColumnType("TEXT"); + + b.Property("SourceId") + .HasColumnType("TEXT"); + + b.Property("TargetId") + .HasColumnType("TEXT"); + + b.Property("TenantId") + .HasColumnType("TEXT"); + + b.Property("TestStatus") + .HasColumnType("INTEGER"); + + b.Property("Tester") + .HasColumnType("TEXT"); + + b.Property("TesterDateTime") + .HasColumnType("TEXT"); + + b.Property("bpmnid") + .HasColumnType("TEXT"); + + b.HasKey("FlowId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("ExecutorId"); + + b.HasIndex("FlowRuleRuleId"); + + b.HasIndex("TenantId"); + + b.ToTable("Flows"); + }); + + modelBuilder.Entity("IoTSharp.Data.FlowOperation", b => + { + b.Property("OperationId") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("AddDate") + .HasColumnType("TEXT"); + + b.Property("BaseEventEventId") + .HasColumnType("TEXT"); + + b.Property("BizId") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("FlowId") + .HasColumnType("TEXT"); + + b.Property("FlowRuleRuleId") + .HasColumnType("TEXT"); + + b.Property("NodeStatus") + .HasColumnType("INTEGER"); + + b.Property("OperationDesc") + .HasColumnType("TEXT"); + + b.Property("Step") + .HasColumnType("INTEGER"); + + b.Property("Tag") + .HasColumnType("TEXT"); + + b.Property("bpmnid") + .HasColumnType("TEXT"); + + b.HasKey("OperationId"); + + b.HasIndex("BaseEventEventId"); + + b.HasIndex("FlowId"); + + b.HasIndex("FlowRuleRuleId"); + + b.ToTable("FlowOperations"); + }); + + modelBuilder.Entity("IoTSharp.Data.FlowRule", b => + { + b.Property("RuleId") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreatTime") + .HasColumnType("TEXT"); + + b.Property("CreateId") + .HasColumnType("TEXT"); + + b.Property("Creator") + .HasColumnType("TEXT"); + + b.Property("CustomerId") + .HasColumnType("TEXT"); + + b.Property("DefinitionsXml") + .HasColumnType("TEXT"); + + b.Property("Describes") + .HasColumnType("TEXT"); + + b.Property("ExecutableCode") + .HasColumnType("TEXT"); + + b.Property("MountType") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ParentRuleId") + .HasColumnType("TEXT"); + + b.Property("RuleDesc") + .HasColumnType("TEXT"); + + b.Property("RuleStatus") + .HasColumnType("INTEGER"); + + b.Property("RuleType") + .HasColumnType("INTEGER"); + + b.Property("Runner") + .HasColumnType("TEXT"); + + b.Property("SubVersion") + .HasColumnType("REAL"); + + b.Property("TenantId") + .HasColumnType("TEXT"); + + b.Property("Version") + .HasColumnType("REAL"); + + b.HasKey("RuleId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("FlowRules"); + }); + + modelBuilder.Entity("IoTSharp.Data.RefreshToken", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("AddedDate") + .HasColumnType("TEXT"); + + b.Property("ExpiryDate") + .HasColumnType("TEXT"); + + b.Property("IsRevorked") + .HasColumnType("INTEGER"); + + b.Property("IsUsed") + .HasColumnType("INTEGER"); + + b.Property("JwtId") + .HasColumnType("TEXT"); + + b.Property("Token") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("RefreshTokens"); + }); + + modelBuilder.Entity("IoTSharp.Data.Relationship", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CustomerId") + .HasColumnType("TEXT"); + + b.Property("IdentityUserId") + .HasColumnType("TEXT"); + + b.Property("TenantId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CustomerId"); + + b.HasIndex("IdentityUserId"); + + b.HasIndex("TenantId"); + + b.ToTable("Relationship"); + }); + + modelBuilder.Entity("IoTSharp.Data.RuleTaskExecutor", b => + { + b.Property("ExecutorId") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("AddDateTime") + .HasColumnType("TEXT"); + + b.Property("Creator") + .HasColumnType("TEXT"); + + b.Property("CustomerId") + .HasColumnType("TEXT"); + + b.Property("DefaultConfig") + .HasColumnType("TEXT"); + + b.Property("ExecutorDesc") + .HasColumnType("TEXT"); + + b.Property("ExecutorName") + .HasColumnType("TEXT"); + + b.Property("ExecutorStatus") + .HasColumnType("INTEGER"); + + b.Property("MataData") + .HasColumnType("TEXT"); + + b.Property("Path") + .HasColumnType("TEXT"); + + b.Property("Tag") + .HasColumnType("TEXT"); + + b.Property("TenantId") + .HasColumnType("TEXT"); + + b.Property("TestStatus") + .HasColumnType("INTEGER"); + + b.Property("Tester") + .HasColumnType("TEXT"); + + b.Property("TesterDateTime") + .HasColumnType("TEXT"); + + b.Property("TypeName") + .HasColumnType("TEXT"); + + b.HasKey("ExecutorId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("RuleTaskExecutors"); + }); + + modelBuilder.Entity("IoTSharp.Data.SubscriptionEvent", b => + { + b.Property("EventId") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreateDateTime") + .HasColumnType("TEXT"); + + b.Property("Creator") + .HasColumnType("TEXT"); + + b.Property("CustomerId") + .HasColumnType("TEXT"); + + b.Property("EventDesc") + .HasColumnType("TEXT"); + + b.Property("EventName") + .HasColumnType("TEXT"); + + b.Property("EventNameSpace") + .HasColumnType("TEXT"); + + b.Property("EventParam") + .HasColumnType("TEXT"); + + b.Property("EventStatus") + .HasColumnType("INTEGER"); + + b.Property("EventTag") + .HasColumnType("TEXT"); + + b.Property("TenantId") + .HasColumnType("TEXT"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.HasKey("EventId"); + + b.HasIndex("CustomerId"); + + b.HasIndex("TenantId"); + + b.ToTable("SubscriptionEvents"); + }); + + modelBuilder.Entity("IoTSharp.Data.SubscriptionTask", b => + { + b.Property("BindId") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("EventId") + .HasColumnType("TEXT"); + + b.Property("RuleTaskExecutorExecutorId") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("INTEGER"); + + b.Property("SubscriptionEventId") + .HasColumnType("TEXT"); + + b.Property("TaskConfig") + .HasColumnType("TEXT"); + + b.HasKey("BindId"); + + b.HasIndex("RuleTaskExecutorExecutorId"); + + b.HasIndex("SubscriptionEventId"); + + b.ToTable("SubscriptionTasks"); + }); + + modelBuilder.Entity("IoTSharp.Data.TelemetryData", b => + { + b.Property("DeviceId") + .HasColumnType("TEXT") + .HasColumnOrder(1); + + b.Property("KeyName") + .HasColumnType("TEXT") + .HasColumnOrder(2); + + b.Property("DateTime") + .HasColumnType("TEXT") + .HasColumnOrder(3); + + b.Property("DataSide") + .HasColumnType("INTEGER") + .HasColumnOrder(4); + + b.Property("Type") + .HasColumnType("INTEGER") + .HasColumnOrder(5); + + b.Property("Value_Binary") + .HasColumnType("BLOB"); + + b.Property("Value_Boolean") + .HasColumnType("INTEGER"); + + b.Property("Value_DateTime") + .HasColumnType("TEXT"); + + b.Property("Value_Double") + .HasColumnType("REAL"); + + b.Property("Value_Json") + .HasColumnType("TEXT"); + + b.Property("Value_Long") + .HasColumnType("INTEGER"); + + b.Property("Value_String") + .HasColumnType("TEXT"); + + b.Property("Value_XML") + .HasColumnType("TEXT"); + + b.HasKey("DeviceId", "KeyName", "DateTime"); + + b.HasIndex("DeviceId"); + + b.HasIndex("KeyName"); + + b.HasIndex("DeviceId", "KeyName"); + + b.ToTable("TelemetryData"); + }); + + modelBuilder.Entity("IoTSharp.Data.Tenant", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Address") + .HasColumnType("TEXT"); + + b.Property("City") + .HasColumnType("TEXT"); + + b.Property("Country") + .HasColumnType("TEXT"); + + b.Property("EMail") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Phone") + .HasColumnType("TEXT"); + + b.Property("Province") + .HasColumnType("TEXT"); + + b.Property("Street") + .HasColumnType("TEXT"); + + b.Property("ZipCode") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.ToTable("Tenant"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b => + { + b.Property("Id") + .HasColumnType("TEXT"); + + b.Property("AccessFailedCount") + .HasColumnType("INTEGER"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("EmailConfirmed") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnabled") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnd") + .HasColumnType("TEXT"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("PasswordHash") + .HasColumnType("TEXT"); + + b.Property("PhoneNumber") + .HasColumnType("TEXT"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("INTEGER"); + + b.Property("SecurityStamp") + .HasColumnType("TEXT"); + + b.Property("TwoFactorEnabled") + .HasColumnType("INTEGER"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasColumnType("TEXT"); + + b.Property("ProviderKey") + .HasColumnType("TEXT"); + + b.Property("ProviderDisplayName") + .HasColumnType("TEXT"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("LoginProvider") + .HasColumnType("TEXT"); + + b.Property("Name") + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("IoTSharp.Data.AttributeLatest", b => + { + b.HasBaseType("IoTSharp.Data.DataStorage"); + + b.HasDiscriminator().HasValue(2); + }); + + modelBuilder.Entity("IoTSharp.Data.Gateway", b => + { + b.HasBaseType("IoTSharp.Data.Device"); + + b.HasDiscriminator().HasValue(1); + }); + + modelBuilder.Entity("IoTSharp.Data.TelemetryLatest", b => + { + b.HasBaseType("IoTSharp.Data.DataStorage"); + + b.HasDiscriminator().HasValue(4); + }); + + modelBuilder.Entity("IoTSharp.Data.AuditLog", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.AuthorizedKey", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.BaseEvent", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.FlowRule", "FlowRule") + .WithMany() + .HasForeignKey("FlowRuleRuleId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("FlowRule"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.Customer", b => + { + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany("Customers") + .HasForeignKey("TenantId"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.Device", b => + { + b.HasOne("IoTSharp.Data.AuthorizedKey", null) + .WithMany("Devices") + .HasForeignKey("AuthorizedKeyId"); + + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany("Devices") + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.DeviceModel", "DeviceModel") + .WithMany() + .HasForeignKey("DeviceModelId"); + + b.HasOne("IoTSharp.Data.Gateway", "Owner") + .WithMany("Children") + .HasForeignKey("OwnerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany("Devices") + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("DeviceModel"); + + b.Navigation("Owner"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceDiagram", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceGraph", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.DeviceDiagram", "DeviceDiagram") + .WithMany() + .HasForeignKey("DeviceDiagramDiagramId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("DeviceDiagram"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceGraphToolBox", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceIdentity", b => + { + b.HasOne("IoTSharp.Data.Device", "Device") + .WithOne("DeviceIdentity") + .HasForeignKey("IoTSharp.Data.DeviceIdentity", "DeviceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Device"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceModelCommand", b => + { + b.HasOne("IoTSharp.Data.DeviceModel", "DeviceModel") + .WithMany("DeviceModelCommands") + .HasForeignKey("DeviceModelId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("DeviceModel"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceRule", b => + { + b.HasOne("IoTSharp.Data.Device", "Device") + .WithMany() + .HasForeignKey("DeviceId"); + + b.HasOne("IoTSharp.Data.FlowRule", "FlowRule") + .WithMany() + .HasForeignKey("FlowRuleRuleId"); + + b.Navigation("Device"); + + b.Navigation("FlowRule"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormFieldInfo", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormFieldValueInfo", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.DynamicFormInfo", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.Flow", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.RuleTaskExecutor", "Executor") + .WithMany() + .HasForeignKey("ExecutorId"); + + b.HasOne("IoTSharp.Data.FlowRule", "FlowRule") + .WithMany() + .HasForeignKey("FlowRuleRuleId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Executor"); + + b.Navigation("FlowRule"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.FlowOperation", b => + { + b.HasOne("IoTSharp.Data.BaseEvent", "BaseEvent") + .WithMany() + .HasForeignKey("BaseEventEventId"); + + b.HasOne("IoTSharp.Data.Flow", "Flow") + .WithMany() + .HasForeignKey("FlowId"); + + b.HasOne("IoTSharp.Data.FlowRule", "FlowRule") + .WithMany() + .HasForeignKey("FlowRuleRuleId"); + + b.Navigation("BaseEvent"); + + b.Navigation("Flow"); + + b.Navigation("FlowRule"); + }); + + modelBuilder.Entity("IoTSharp.Data.FlowRule", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.RefreshToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "User") + .WithMany() + .HasForeignKey("UserId"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("IoTSharp.Data.Relationship", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", "IdentityUser") + .WithMany() + .HasForeignKey("IdentityUserId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("IdentityUser"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.RuleTaskExecutor", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.SubscriptionEvent", b => + { + b.HasOne("IoTSharp.Data.Customer", "Customer") + .WithMany() + .HasForeignKey("CustomerId"); + + b.HasOne("IoTSharp.Data.Tenant", "Tenant") + .WithMany() + .HasForeignKey("TenantId"); + + b.Navigation("Customer"); + + b.Navigation("Tenant"); + }); + + modelBuilder.Entity("IoTSharp.Data.SubscriptionTask", b => + { + b.HasOne("IoTSharp.Data.RuleTaskExecutor", "RuleTaskExecutor") + .WithMany() + .HasForeignKey("RuleTaskExecutorExecutorId"); + + b.HasOne("IoTSharp.Data.SubscriptionEvent", "Subscription") + .WithMany() + .HasForeignKey("SubscriptionEventId"); + + b.Navigation("RuleTaskExecutor"); + + b.Navigation("Subscription"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("IoTSharp.Data.AuthorizedKey", b => + { + b.Navigation("Devices"); + }); + + modelBuilder.Entity("IoTSharp.Data.Customer", b => + { + b.Navigation("Devices"); + }); + + modelBuilder.Entity("IoTSharp.Data.Device", b => + { + b.Navigation("DeviceIdentity"); + }); + + modelBuilder.Entity("IoTSharp.Data.DeviceModel", b => + { + b.Navigation("DeviceModelCommands"); + }); + + modelBuilder.Entity("IoTSharp.Data.Tenant", b => + { + b.Navigation("Customers"); + + b.Navigation("Devices"); + }); + + modelBuilder.Entity("IoTSharp.Data.Gateway", b => + { + b.Navigation("Children"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/IoTSharp.Data.Sqlite/Migrations/20220212100305_FixTenantInfo.cs b/IoTSharp.Data.Sqlite/Migrations/20220212100305_FixTenantInfo.cs new file mode 100644 index 0000000000000000000000000000000000000000..a10da05d7d6186866f1335d26317d5a8eac1cd14 --- /dev/null +++ b/IoTSharp.Data.Sqlite/Migrations/20220212100305_FixTenantInfo.cs @@ -0,0 +1,1667 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace IoTSharp.Data.Sqlite.Migrations +{ + public partial class FixTenantInfo : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_DeviceDiagrams_Customer_CustomerId", + table: "DeviceDiagrams"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceDiagrams_Tenant_TenantId", + table: "DeviceDiagrams"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceGraphs_Customer_CustomerId", + table: "DeviceGraphs"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceGraphs_Tenant_TenantId", + table: "DeviceGraphs"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceGraphToolBoxes_Customer_CustomerId", + table: "DeviceGraphToolBoxes"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceGraphToolBoxes_Tenant_TenantId", + table: "DeviceGraphToolBoxes"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormFieldInfos_Customer_CustomerId", + table: "DynamicFormFieldInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormFieldInfos_Tenant_TenantId", + table: "DynamicFormFieldInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormFieldValueInfos_Customer_CustomerId", + table: "DynamicFormFieldValueInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormFieldValueInfos_Tenant_TenantId", + table: "DynamicFormFieldValueInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormInfos_Customer_CustomerId", + table: "DynamicFormInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormInfos_Tenant_TenantId", + table: "DynamicFormInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_BaseEvents_BaseEventId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_FlowRules_FlowRuleId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_Flows_FlowId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowRules_Customer_CustomerId", + table: "FlowRules"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowRules_Tenant_TenantId", + table: "FlowRules"); + + migrationBuilder.DropForeignKey( + name: "FK_Flows_Customer_CustomerId", + table: "Flows"); + + migrationBuilder.DropForeignKey( + name: "FK_Flows_Tenant_TenantId", + table: "Flows"); + + migrationBuilder.DropForeignKey( + name: "FK_RuleTaskExecutors_Customer_CustomerId", + table: "RuleTaskExecutors"); + + migrationBuilder.DropForeignKey( + name: "FK_RuleTaskExecutors_Tenant_TenantId", + table: "RuleTaskExecutors"); + + migrationBuilder.DropForeignKey( + name: "FK_SubscriptionEvents_Customer_CustomerId", + table: "SubscriptionEvents"); + + migrationBuilder.DropForeignKey( + name: "FK_SubscriptionEvents_Tenant_TenantId", + table: "SubscriptionEvents"); + + migrationBuilder.DropIndex( + name: "IX_FlowOperations_BaseEventId", + table: "FlowOperations"); + + migrationBuilder.DropIndex( + name: "IX_FlowOperations_FlowRuleId", + table: "FlowOperations"); + + migrationBuilder.DropColumn( + name: "BaseEventId", + table: "FlowOperations"); + + migrationBuilder.DropColumn( + name: "FlowRuleId", + table: "FlowOperations"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "SubscriptionEvents", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "SubscriptionEvents", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "RuleTaskExecutors", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "RuleTaskExecutors", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "Flows", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "Flows", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "FlowRules", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "FlowRules", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "NodeStatus", + table: "FlowOperations", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FlowId", + table: "FlowOperations", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AddColumn( + name: "BaseEventEventId", + table: "FlowOperations", + type: "TEXT", + nullable: true); + + migrationBuilder.AddColumn( + name: "FlowRuleRuleId", + table: "FlowOperations", + type: "TEXT", + nullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DynamicFormInfos", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "FormStatus", + table: "DynamicFormInfos", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FormCreator", + table: "DynamicFormInfos", + type: "INTEGER", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DynamicFormInfos", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "BizId", + table: "DynamicFormInfos", + type: "INTEGER", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DynamicFormFieldValueInfos", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "FromId", + table: "DynamicFormFieldValueInfos", + type: "INTEGER", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FieldValueType", + table: "DynamicFormFieldValueInfos", + type: "INTEGER", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FieldId", + table: "DynamicFormFieldValueInfos", + type: "INTEGER", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DynamicFormFieldValueInfos", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "BizId", + table: "DynamicFormFieldValueInfos", + type: "INTEGER", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DynamicFormFieldInfos", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "IsRequired", + table: "DynamicFormFieldInfos", + type: "INTEGER", + nullable: false, + defaultValue: false, + oldClrType: typeof(bool), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "IsEnabled", + table: "DynamicFormFieldInfos", + type: "INTEGER", + nullable: false, + defaultValue: false, + oldClrType: typeof(bool), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FormId", + table: "DynamicFormFieldInfos", + type: "INTEGER", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FieldValueType", + table: "DynamicFormFieldInfos", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FieldUIElement", + table: "DynamicFormFieldInfos", + type: "INTEGER", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FieldStatus", + table: "DynamicFormFieldInfos", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FieldMaxLength", + table: "DynamicFormFieldInfos", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DynamicFormFieldInfos", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "PortType", + table: "DevicePorts", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "PortStatus", + table: "DevicePorts", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "PortPhyType", + table: "DevicePorts", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Creator", + table: "DevicePorts", + type: "INTEGER", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MappingStatus", + table: "DevicePortMappings", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "MappingIndex", + table: "DevicePortMappings", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ToolBoxStatus", + table: "DeviceGraphToolBoxes", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetY", + table: "DeviceGraphToolBoxes", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetX", + table: "DeviceGraphToolBoxes", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetTopPer", + table: "DeviceGraphToolBoxes", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetLeftPer", + table: "DeviceGraphToolBoxes", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DeviceGraphToolBoxes", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "DeviceId", + table: "DeviceGraphToolBoxes", + type: "INTEGER", + nullable: false, + defaultValue: 0L, + oldClrType: typeof(long), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DeviceGraphToolBoxes", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DeviceGraphs", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "GraphWidth", + table: "DeviceGraphs", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphTextRefY", + table: "DeviceGraphs", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphTextRefX", + table: "DeviceGraphs", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphTextFontSize", + table: "DeviceGraphs", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphStrokeWidth", + table: "DeviceGraphs", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphPostionY", + table: "DeviceGraphs", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphPostionX", + table: "DeviceGraphs", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphHeight", + table: "DeviceGraphs", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(decimal), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DeviceGraphs", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DeviceDiagrams", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "IsDefault", + table: "DeviceDiagrams", + type: "INTEGER", + nullable: false, + defaultValue: false, + oldClrType: typeof(bool), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DiagramStatus", + table: "DeviceDiagrams", + type: "INTEGER", + nullable: false, + defaultValue: 0, + oldClrType: typeof(int), + oldType: "INTEGER", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DeviceDiagrams", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.CreateIndex( + name: "IX_FlowOperations_BaseEventEventId", + table: "FlowOperations", + column: "BaseEventEventId"); + + migrationBuilder.CreateIndex( + name: "IX_FlowOperations_FlowRuleRuleId", + table: "FlowOperations", + column: "FlowRuleRuleId"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceDiagrams_Customer_CustomerId", + table: "DeviceDiagrams", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceDiagrams_Tenant_TenantId", + table: "DeviceDiagrams", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceGraphs_Customer_CustomerId", + table: "DeviceGraphs", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceGraphs_Tenant_TenantId", + table: "DeviceGraphs", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceGraphToolBoxes_Customer_CustomerId", + table: "DeviceGraphToolBoxes", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceGraphToolBoxes_Tenant_TenantId", + table: "DeviceGraphToolBoxes", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormFieldInfos_Customer_CustomerId", + table: "DynamicFormFieldInfos", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormFieldInfos_Tenant_TenantId", + table: "DynamicFormFieldInfos", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormFieldValueInfos_Customer_CustomerId", + table: "DynamicFormFieldValueInfos", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormFieldValueInfos_Tenant_TenantId", + table: "DynamicFormFieldValueInfos", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormInfos_Customer_CustomerId", + table: "DynamicFormInfos", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormInfos_Tenant_TenantId", + table: "DynamicFormInfos", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_BaseEvents_BaseEventEventId", + table: "FlowOperations", + column: "BaseEventEventId", + principalTable: "BaseEvents", + principalColumn: "EventId"); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_FlowRules_FlowRuleRuleId", + table: "FlowOperations", + column: "FlowRuleRuleId", + principalTable: "FlowRules", + principalColumn: "RuleId"); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_Flows_FlowId", + table: "FlowOperations", + column: "FlowId", + principalTable: "Flows", + principalColumn: "FlowId"); + + migrationBuilder.AddForeignKey( + name: "FK_FlowRules_Customer_CustomerId", + table: "FlowRules", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_FlowRules_Tenant_TenantId", + table: "FlowRules", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Flows_Customer_CustomerId", + table: "Flows", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Flows_Tenant_TenantId", + table: "Flows", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_RuleTaskExecutors_Customer_CustomerId", + table: "RuleTaskExecutors", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_RuleTaskExecutors_Tenant_TenantId", + table: "RuleTaskExecutors", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_SubscriptionEvents_Customer_CustomerId", + table: "SubscriptionEvents", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_SubscriptionEvents_Tenant_TenantId", + table: "SubscriptionEvents", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_DeviceDiagrams_Customer_CustomerId", + table: "DeviceDiagrams"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceDiagrams_Tenant_TenantId", + table: "DeviceDiagrams"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceGraphs_Customer_CustomerId", + table: "DeviceGraphs"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceGraphs_Tenant_TenantId", + table: "DeviceGraphs"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceGraphToolBoxes_Customer_CustomerId", + table: "DeviceGraphToolBoxes"); + + migrationBuilder.DropForeignKey( + name: "FK_DeviceGraphToolBoxes_Tenant_TenantId", + table: "DeviceGraphToolBoxes"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormFieldInfos_Customer_CustomerId", + table: "DynamicFormFieldInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormFieldInfos_Tenant_TenantId", + table: "DynamicFormFieldInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormFieldValueInfos_Customer_CustomerId", + table: "DynamicFormFieldValueInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormFieldValueInfos_Tenant_TenantId", + table: "DynamicFormFieldValueInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormInfos_Customer_CustomerId", + table: "DynamicFormInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_DynamicFormInfos_Tenant_TenantId", + table: "DynamicFormInfos"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_BaseEvents_BaseEventEventId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_FlowRules_FlowRuleRuleId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowOperations_Flows_FlowId", + table: "FlowOperations"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowRules_Customer_CustomerId", + table: "FlowRules"); + + migrationBuilder.DropForeignKey( + name: "FK_FlowRules_Tenant_TenantId", + table: "FlowRules"); + + migrationBuilder.DropForeignKey( + name: "FK_Flows_Customer_CustomerId", + table: "Flows"); + + migrationBuilder.DropForeignKey( + name: "FK_Flows_Tenant_TenantId", + table: "Flows"); + + migrationBuilder.DropForeignKey( + name: "FK_RuleTaskExecutors_Customer_CustomerId", + table: "RuleTaskExecutors"); + + migrationBuilder.DropForeignKey( + name: "FK_RuleTaskExecutors_Tenant_TenantId", + table: "RuleTaskExecutors"); + + migrationBuilder.DropForeignKey( + name: "FK_SubscriptionEvents_Customer_CustomerId", + table: "SubscriptionEvents"); + + migrationBuilder.DropForeignKey( + name: "FK_SubscriptionEvents_Tenant_TenantId", + table: "SubscriptionEvents"); + + migrationBuilder.DropIndex( + name: "IX_FlowOperations_BaseEventEventId", + table: "FlowOperations"); + + migrationBuilder.DropIndex( + name: "IX_FlowOperations_FlowRuleRuleId", + table: "FlowOperations"); + + migrationBuilder.DropColumn( + name: "BaseEventEventId", + table: "FlowOperations"); + + migrationBuilder.DropColumn( + name: "FlowRuleRuleId", + table: "FlowOperations"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "SubscriptionEvents", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "SubscriptionEvents", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "RuleTaskExecutors", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "RuleTaskExecutors", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "Flows", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "Flows", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "FlowRules", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "FlowRules", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "NodeStatus", + table: "FlowOperations", + type: "INTEGER", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "FlowId", + table: "FlowOperations", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AddColumn( + name: "BaseEventId", + table: "FlowOperations", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AddColumn( + name: "FlowRuleId", + table: "FlowOperations", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DynamicFormInfos", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FormStatus", + table: "DynamicFormInfos", + type: "INTEGER", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "FormCreator", + table: "DynamicFormInfos", + type: "INTEGER", + nullable: true, + oldClrType: typeof(long), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DynamicFormInfos", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "BizId", + table: "DynamicFormInfos", + type: "INTEGER", + nullable: true, + oldClrType: typeof(long), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DynamicFormFieldValueInfos", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FromId", + table: "DynamicFormFieldValueInfos", + type: "INTEGER", + nullable: true, + oldClrType: typeof(long), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "FieldValueType", + table: "DynamicFormFieldValueInfos", + type: "INTEGER", + nullable: true, + oldClrType: typeof(long), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "FieldId", + table: "DynamicFormFieldValueInfos", + type: "INTEGER", + nullable: true, + oldClrType: typeof(long), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DynamicFormFieldValueInfos", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "BizId", + table: "DynamicFormFieldValueInfos", + type: "INTEGER", + nullable: true, + oldClrType: typeof(long), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DynamicFormFieldInfos", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "IsRequired", + table: "DynamicFormFieldInfos", + type: "INTEGER", + nullable: true, + oldClrType: typeof(bool), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "IsEnabled", + table: "DynamicFormFieldInfos", + type: "INTEGER", + nullable: true, + oldClrType: typeof(bool), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "FormId", + table: "DynamicFormFieldInfos", + type: "INTEGER", + nullable: true, + oldClrType: typeof(long), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "FieldValueType", + table: "DynamicFormFieldInfos", + type: "INTEGER", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "FieldUIElement", + table: "DynamicFormFieldInfos", + type: "INTEGER", + nullable: true, + oldClrType: typeof(long), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "FieldStatus", + table: "DynamicFormFieldInfos", + type: "INTEGER", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "FieldMaxLength", + table: "DynamicFormFieldInfos", + type: "INTEGER", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DynamicFormFieldInfos", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "PortType", + table: "DevicePorts", + type: "INTEGER", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "PortStatus", + table: "DevicePorts", + type: "INTEGER", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "PortPhyType", + table: "DevicePorts", + type: "INTEGER", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "Creator", + table: "DevicePorts", + type: "INTEGER", + nullable: true, + oldClrType: typeof(long), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "MappingStatus", + table: "DevicePortMappings", + type: "INTEGER", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "MappingIndex", + table: "DevicePortMappings", + type: "TEXT", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "ToolBoxStatus", + table: "DeviceGraphToolBoxes", + type: "INTEGER", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetY", + table: "DeviceGraphToolBoxes", + type: "TEXT", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetX", + table: "DeviceGraphToolBoxes", + type: "TEXT", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetTopPer", + table: "DeviceGraphToolBoxes", + type: "TEXT", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "ToolBoxOffsetLeftPer", + table: "DeviceGraphToolBoxes", + type: "TEXT", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DeviceGraphToolBoxes", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "DeviceId", + table: "DeviceGraphToolBoxes", + type: "INTEGER", + nullable: true, + oldClrType: typeof(long), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DeviceGraphToolBoxes", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DeviceGraphs", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "GraphWidth", + table: "DeviceGraphs", + type: "TEXT", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "GraphTextRefY", + table: "DeviceGraphs", + type: "TEXT", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "GraphTextRefX", + table: "DeviceGraphs", + type: "TEXT", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "GraphTextFontSize", + table: "DeviceGraphs", + type: "TEXT", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "GraphStrokeWidth", + table: "DeviceGraphs", + type: "TEXT", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "GraphPostionY", + table: "DeviceGraphs", + type: "TEXT", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "GraphPostionX", + table: "DeviceGraphs", + type: "TEXT", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "GraphHeight", + table: "DeviceGraphs", + type: "TEXT", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DeviceGraphs", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TenantId", + table: "DeviceDiagrams", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "IsDefault", + table: "DeviceDiagrams", + type: "INTEGER", + nullable: true, + oldClrType: typeof(bool), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "DiagramStatus", + table: "DeviceDiagrams", + type: "INTEGER", + nullable: true, + oldClrType: typeof(int), + oldType: "INTEGER"); + + migrationBuilder.AlterColumn( + name: "CustomerId", + table: "DeviceDiagrams", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.CreateIndex( + name: "IX_FlowOperations_BaseEventId", + table: "FlowOperations", + column: "BaseEventId"); + + migrationBuilder.CreateIndex( + name: "IX_FlowOperations_FlowRuleId", + table: "FlowOperations", + column: "FlowRuleId"); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceDiagrams_Customer_CustomerId", + table: "DeviceDiagrams", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceDiagrams_Tenant_TenantId", + table: "DeviceDiagrams", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceGraphs_Customer_CustomerId", + table: "DeviceGraphs", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceGraphs_Tenant_TenantId", + table: "DeviceGraphs", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceGraphToolBoxes_Customer_CustomerId", + table: "DeviceGraphToolBoxes", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DeviceGraphToolBoxes_Tenant_TenantId", + table: "DeviceGraphToolBoxes", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormFieldInfos_Customer_CustomerId", + table: "DynamicFormFieldInfos", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormFieldInfos_Tenant_TenantId", + table: "DynamicFormFieldInfos", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormFieldValueInfos_Customer_CustomerId", + table: "DynamicFormFieldValueInfos", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormFieldValueInfos_Tenant_TenantId", + table: "DynamicFormFieldValueInfos", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormInfos_Customer_CustomerId", + table: "DynamicFormInfos", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_DynamicFormInfos_Tenant_TenantId", + table: "DynamicFormInfos", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_BaseEvents_BaseEventId", + table: "FlowOperations", + column: "BaseEventId", + principalTable: "BaseEvents", + principalColumn: "EventId", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_FlowRules_FlowRuleId", + table: "FlowOperations", + column: "FlowRuleId", + principalTable: "FlowRules", + principalColumn: "RuleId", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_FlowOperations_Flows_FlowId", + table: "FlowOperations", + column: "FlowId", + principalTable: "Flows", + principalColumn: "FlowId", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_FlowRules_Customer_CustomerId", + table: "FlowRules", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_FlowRules_Tenant_TenantId", + table: "FlowRules", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Flows_Customer_CustomerId", + table: "Flows", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Flows_Tenant_TenantId", + table: "Flows", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_RuleTaskExecutors_Customer_CustomerId", + table: "RuleTaskExecutors", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_RuleTaskExecutors_Tenant_TenantId", + table: "RuleTaskExecutors", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_SubscriptionEvents_Customer_CustomerId", + table: "SubscriptionEvents", + column: "CustomerId", + principalTable: "Customer", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_SubscriptionEvents_Tenant_TenantId", + table: "SubscriptionEvents", + column: "TenantId", + principalTable: "Tenant", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/IoTSharp.Data.Sqlite/Migrations/ApplicationDbContextModelSnapshot.cs b/IoTSharp.Data.Sqlite/Migrations/ApplicationDbContextModelSnapshot.cs index 9e8ad1d7c7d1bc7a8a9eb49e86cf8dd6b10d0ed4..c3498fa18a68952f8ce1546e75c6925da1c74bbb 100644 --- a/IoTSharp.Data.Sqlite/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/IoTSharp.Data.Sqlite/Migrations/ApplicationDbContextModelSnapshot.cs @@ -518,7 +518,7 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("Creator") .HasColumnType("TEXT"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("TEXT"); b.Property("DiagramDesc") @@ -530,13 +530,13 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("DiagramName") .HasColumnType("TEXT"); - b.Property("DiagramStatus") + b.Property("DiagramStatus") .HasColumnType("INTEGER"); - b.Property("IsDefault") + b.Property("IsDefault") .HasColumnType("INTEGER"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("TEXT"); b.HasKey("DiagramId"); @@ -560,7 +560,7 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("Creator") .HasColumnType("TEXT"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("TEXT"); b.Property("DeviceDiagramDiagramId") @@ -575,14 +575,14 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("GraphFill") .HasColumnType("TEXT"); - b.Property("GraphHeight") - .HasColumnType("TEXT"); + b.Property("GraphHeight") + .HasColumnType("INTEGER"); - b.Property("GraphPostionX") - .HasColumnType("TEXT"); + b.Property("GraphPostionX") + .HasColumnType("INTEGER"); - b.Property("GraphPostionY") - .HasColumnType("TEXT"); + b.Property("GraphPostionY") + .HasColumnType("INTEGER"); b.Property("GraphShape") .HasColumnType("TEXT"); @@ -590,8 +590,8 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("GraphStroke") .HasColumnType("TEXT"); - b.Property("GraphStrokeWidth") - .HasColumnType("TEXT"); + b.Property("GraphStrokeWidth") + .HasColumnType("INTEGER"); b.Property("GraphTextAnchor") .HasColumnType("TEXT"); @@ -602,22 +602,22 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("GraphTextFontFamily") .HasColumnType("TEXT"); - b.Property("GraphTextFontSize") - .HasColumnType("TEXT"); + b.Property("GraphTextFontSize") + .HasColumnType("INTEGER"); - b.Property("GraphTextRefX") - .HasColumnType("TEXT"); + b.Property("GraphTextRefX") + .HasColumnType("INTEGER"); - b.Property("GraphTextRefY") - .HasColumnType("TEXT"); + b.Property("GraphTextRefY") + .HasColumnType("INTEGER"); b.Property("GraphTextVerticalAnchor") .HasColumnType("TEXT"); - b.Property("GraphWidth") - .HasColumnType("TEXT"); + b.Property("GraphWidth") + .HasColumnType("INTEGER"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("TEXT"); b.HasKey("GraphId"); @@ -649,13 +649,13 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("Creator") .HasColumnType("TEXT"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("TEXT"); - b.Property("DeviceId") + b.Property("DeviceId") .HasColumnType("INTEGER"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("TEXT"); b.Property("ToolBoxIcon") @@ -664,22 +664,22 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("ToolBoxName") .HasColumnType("TEXT"); - b.Property("ToolBoxOffsetLeftPer") - .HasColumnType("TEXT"); + b.Property("ToolBoxOffsetLeftPer") + .HasColumnType("INTEGER"); - b.Property("ToolBoxOffsetTopPer") - .HasColumnType("TEXT"); + b.Property("ToolBoxOffsetTopPer") + .HasColumnType("INTEGER"); - b.Property("ToolBoxOffsetX") - .HasColumnType("TEXT"); + b.Property("ToolBoxOffsetX") + .HasColumnType("INTEGER"); - b.Property("ToolBoxOffsetY") - .HasColumnType("TEXT"); + b.Property("ToolBoxOffsetY") + .HasColumnType("INTEGER"); b.Property("ToolBoxRequestUri") .HasColumnType("TEXT"); - b.Property("ToolBoxStatus") + b.Property("ToolBoxStatus") .HasColumnType("INTEGER"); b.Property("ToolBoxType") @@ -799,7 +799,7 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("CreateDate") .HasColumnType("TEXT"); - b.Property("Creator") + b.Property("Creator") .HasColumnType("INTEGER"); b.Property("DeviceId") @@ -814,16 +814,16 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("PortName") .HasColumnType("TEXT"); - b.Property("PortPhyType") + b.Property("PortPhyType") .HasColumnType("INTEGER"); b.Property("PortPic") .HasColumnType("TEXT"); - b.Property("PortStatus") + b.Property("PortStatus") .HasColumnType("INTEGER"); - b.Property("PortType") + b.Property("PortType") .HasColumnType("INTEGER"); b.HasKey("PortId"); @@ -843,10 +843,10 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("Creator") .HasColumnType("TEXT"); - b.Property("MappingIndex") - .HasColumnType("TEXT"); + b.Property("MappingIndex") + .HasColumnType("INTEGER"); - b.Property("MappingStatus") + b.Property("MappingStatus") .HasColumnType("INTEGER"); b.Property("SourceDeviceId") @@ -911,7 +911,7 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("Creator") .HasColumnType("TEXT"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("TEXT"); b.Property("FieldCode") @@ -926,7 +926,7 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("FieldI18nKey") .HasColumnType("TEXT"); - b.Property("FieldMaxLength") + b.Property("FieldMaxLength") .HasColumnType("INTEGER"); b.Property("FieldName") @@ -938,10 +938,10 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("FieldPocoTypeName") .HasColumnType("TEXT"); - b.Property("FieldStatus") + b.Property("FieldStatus") .HasColumnType("INTEGER"); - b.Property("FieldUIElement") + b.Property("FieldUIElement") .HasColumnType("INTEGER"); b.Property("FieldUIElementSchema") @@ -959,22 +959,22 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("FieldValueLocalDataSource") .HasColumnType("TEXT"); - b.Property("FieldValueType") + b.Property("FieldValueType") .HasColumnType("INTEGER"); b.Property("FieldValueTypeName") .HasColumnType("TEXT"); - b.Property("FormId") + b.Property("FormId") .HasColumnType("INTEGER"); - b.Property("IsEnabled") + b.Property("IsEnabled") .HasColumnType("INTEGER"); - b.Property("IsRequired") + b.Property("IsRequired") .HasColumnType("INTEGER"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("TEXT"); b.HasKey("FieldId"); @@ -992,13 +992,13 @@ namespace IoTSharp.Data.Sqlite.Migrations .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); - b.Property("BizId") + b.Property("BizId") .HasColumnType("INTEGER"); b.Property("Creator") .HasColumnType("TEXT"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("TEXT"); b.Property("FieldCode") @@ -1007,7 +1007,7 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("FieldCreateDate") .HasColumnType("TEXT"); - b.Property("FieldId") + b.Property("FieldId") .HasColumnType("INTEGER"); b.Property("FieldName") @@ -1019,13 +1019,13 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("FieldValue") .HasColumnType("TEXT"); - b.Property("FieldValueType") + b.Property("FieldValueType") .HasColumnType("INTEGER"); - b.Property("FromId") + b.Property("FromId") .HasColumnType("INTEGER"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("TEXT"); b.HasKey("FieldValueId"); @@ -1043,16 +1043,16 @@ namespace IoTSharp.Data.Sqlite.Migrations .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); - b.Property("BizId") + b.Property("BizId") .HasColumnType("INTEGER"); b.Property("Creator") .HasColumnType("TEXT"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("TEXT"); - b.Property("FormCreator") + b.Property("FormCreator") .HasColumnType("INTEGER"); b.Property("FormDesc") @@ -1067,7 +1067,7 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("FormSchame") .HasColumnType("TEXT"); - b.Property("FormStatus") + b.Property("FormStatus") .HasColumnType("INTEGER"); b.Property("FromCreateDate") @@ -1079,7 +1079,7 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("ModelClass") .HasColumnType("TEXT"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("TEXT"); b.Property("Url") @@ -1112,7 +1112,7 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("Createor") .HasColumnType("TEXT"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("TEXT"); b.Property("ExecutorId") @@ -1166,7 +1166,7 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("TargetId") .HasColumnType("TEXT"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("TEXT"); b.Property("TestStatus") @@ -1203,7 +1203,7 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("AddDate") .HasColumnType("TEXT"); - b.Property("BaseEventId") + b.Property("BaseEventEventId") .HasColumnType("TEXT"); b.Property("BizId") @@ -1212,13 +1212,13 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("Data") .HasColumnType("TEXT"); - b.Property("FlowId") + b.Property("FlowId") .HasColumnType("TEXT"); - b.Property("FlowRuleId") + b.Property("FlowRuleRuleId") .HasColumnType("TEXT"); - b.Property("NodeStatus") + b.Property("NodeStatus") .HasColumnType("INTEGER"); b.Property("OperationDesc") @@ -1235,11 +1235,11 @@ namespace IoTSharp.Data.Sqlite.Migrations b.HasKey("OperationId"); - b.HasIndex("BaseEventId"); + b.HasIndex("BaseEventEventId"); b.HasIndex("FlowId"); - b.HasIndex("FlowRuleId"); + b.HasIndex("FlowRuleRuleId"); b.ToTable("FlowOperations"); }); @@ -1259,7 +1259,7 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("Creator") .HasColumnType("TEXT"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("TEXT"); b.Property("DefinitionsXml") @@ -1296,7 +1296,7 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("SubVersion") .HasColumnType("REAL"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("TEXT"); b.Property("Version") @@ -1383,7 +1383,7 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("Creator") .HasColumnType("TEXT"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("TEXT"); b.Property("DefaultConfig") @@ -1407,7 +1407,7 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("Tag") .HasColumnType("TEXT"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("TEXT"); b.Property("TestStatus") @@ -1443,7 +1443,7 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("Creator") .HasColumnType("TEXT"); - b.Property("CustomerId") + b.Property("CustomerId") .HasColumnType("TEXT"); b.Property("EventDesc") @@ -1464,7 +1464,7 @@ namespace IoTSharp.Data.Sqlite.Migrations b.Property("EventTag") .HasColumnType("TEXT"); - b.Property("TenantId") + b.Property("TenantId") .HasColumnType("TEXT"); b.Property("Type") @@ -1912,15 +1912,11 @@ namespace IoTSharp.Data.Sqlite.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -1931,9 +1927,7 @@ namespace IoTSharp.Data.Sqlite.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.DeviceDiagram", "DeviceDiagram") .WithMany() @@ -1941,9 +1935,7 @@ namespace IoTSharp.Data.Sqlite.Migrations b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -1956,15 +1948,11 @@ namespace IoTSharp.Data.Sqlite.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2012,15 +2000,11 @@ namespace IoTSharp.Data.Sqlite.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2031,15 +2015,11 @@ namespace IoTSharp.Data.Sqlite.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2050,15 +2030,11 @@ namespace IoTSharp.Data.Sqlite.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2069,9 +2045,7 @@ namespace IoTSharp.Data.Sqlite.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.RuleTaskExecutor", "Executor") .WithMany() @@ -2083,9 +2057,7 @@ namespace IoTSharp.Data.Sqlite.Migrations b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2100,21 +2072,15 @@ namespace IoTSharp.Data.Sqlite.Migrations { b.HasOne("IoTSharp.Data.BaseEvent", "BaseEvent") .WithMany() - .HasForeignKey("BaseEventId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("BaseEventEventId"); b.HasOne("IoTSharp.Data.Flow", "Flow") .WithMany() - .HasForeignKey("FlowId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("FlowId"); b.HasOne("IoTSharp.Data.FlowRule", "FlowRule") .WithMany() - .HasForeignKey("FlowRuleId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("FlowRuleRuleId"); b.Navigation("BaseEvent"); @@ -2127,15 +2093,11 @@ namespace IoTSharp.Data.Sqlite.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2176,15 +2138,11 @@ namespace IoTSharp.Data.Sqlite.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); @@ -2195,15 +2153,11 @@ namespace IoTSharp.Data.Sqlite.Migrations { b.HasOne("IoTSharp.Data.Customer", "Customer") .WithMany() - .HasForeignKey("CustomerId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("CustomerId"); b.HasOne("IoTSharp.Data.Tenant", "Tenant") .WithMany() - .HasForeignKey("TenantId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + .HasForeignKey("TenantId"); b.Navigation("Customer"); diff --git a/IoTSharp/appsettings.MySql.json b/IoTSharp/appsettings.MySql.json index a9102606d1aa379549de8a895e97caac87dfa128..cc4fe9fe67e7eab0f5dea8f160e6fa4983e50ba9 100644 --- a/IoTSharp/appsettings.MySql.json +++ b/IoTSharp/appsettings.MySql.json @@ -8,8 +8,8 @@ }, "DataBase": "MySql", "ConnectionStrings": { - "IoTSharp": "server=localhost;user=root;password=kissme;database=IoTSharp", - "TelemetryStorage": "server=localhost;user=root;password=kissme;database=IoTSharp" + "IoTSharp": "server=localhost;user=root;password=kissme;database=IoTSharp1", + "TelemetryStorage": "server=localhost;user=root;password=kissme;database=IoTSharp1" }, "JwtKey": "kissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissmekissme", "JwtExpireHours": 3,