提交 d5ac97fc 编写于 作者: 麦壳饼's avatar 麦壳饼

优化租户和客户相关

上级 5f02f9d2
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace IoTSharp.Data.MySql.Migrations
{
public partial class AddTenantInfoAndRefToken : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}
......@@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace IoTSharp.Data.MySql.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20220211154512_AddTenantInfoAndRefToken")]
partial class AddTenantInfoAndRefToken
[Migration("20220212025925_AddTenantInfoAndToken")]
partial class AddTenantInfoAndToken
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
......@@ -193,7 +193,7 @@ namespace IoTSharp.Data.MySql.Migrations
b.Property<Guid>("Creator")
.HasColumnType("char(36)");
b.Property<Guid>("CustomerId")
b.Property<Guid?>("CustomerId")
.HasColumnType("char(36)");
b.Property<string>("EventDesc")
......@@ -211,7 +211,7 @@ namespace IoTSharp.Data.MySql.Migrations
b.Property<string>("MataData")
.HasColumnType("longtext");
b.Property<Guid>("TenantId")
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)");
b.Property<int>("Type")
......@@ -1855,9 +1855,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.FlowRule", "FlowRule")
.WithMany()
......@@ -1865,9 +1863,7 @@ namespace IoTSharp.Data.MySql.Migrations
b.HasOne("IoTSharp.Data.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("TenantId");
b.Navigation("Customer");
......
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<Guid>(
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<Guid>(
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<Guid>(
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<Guid>(
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);
}
}
}
......@@ -191,7 +191,7 @@ namespace IoTSharp.Data.MySql.Migrations
b.Property<Guid>("Creator")
.HasColumnType("char(36)");
b.Property<Guid>("CustomerId")
b.Property<Guid?>("CustomerId")
.HasColumnType("char(36)");
b.Property<string>("EventDesc")
......@@ -209,7 +209,7 @@ namespace IoTSharp.Data.MySql.Migrations
b.Property<string>("MataData")
.HasColumnType("longtext");
b.Property<Guid>("TenantId")
b.Property<Guid?>("TenantId")
.HasColumnType("char(36)");
b.Property<int>("Type")
......@@ -1853,9 +1853,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.FlowRule", "FlowRule")
.WithMany()
......@@ -1863,9 +1861,7 @@ namespace IoTSharp.Data.MySql.Migrations
b.HasOne("IoTSharp.Data.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("TenantId");
b.Navigation("Customer");
......
using Microsoft.EntityFrameworkCore.Migrations;
namespace IoTSharp.Migrations
{
public partial class addexecfield : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace IoTSharp.Migrations
{
public partial class renametableeexecutor : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace IoTSharp.Migrations
{
public partial class modifyrulemounttype : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}
......@@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace IoTSharp.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20220212023819_FixIX_TelemetryData_DeviceId_KeyName_DateTime")]
partial class FixIX_TelemetryData_DeviceId_KeyName_DateTime
[Migration("20220212025708_AddTenantInfoAndToken")]
partial class AddTenantInfoAndToken
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
......
......@@ -5,7 +5,7 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace IoTSharp.Migrations
{
public partial class FixIX_TelemetryData_DeviceId_KeyName_DateTime : Migration
public partial class AddTenantInfoAndToken : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
......
......@@ -16,4 +16,8 @@
<ProjectReference Include="..\IoTSharp.Data\IoTSharp.Data.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
</Project>
......@@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace IoTSharp.Data.SqlServer.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20220211155105_AddTenantInfoAndRefToken")]
partial class AddTenantInfoAndRefToken
[Migration("20220212034148_SQLServerSchema2022")]
partial class SQLServerSchema2022
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
......@@ -200,7 +200,7 @@ namespace IoTSharp.Data.SqlServer.Migrations
b.Property<Guid>("Creator")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("CustomerId")
b.Property<Guid?>("CustomerId")
.HasColumnType("uniqueidentifier");
b.Property<string>("EventDesc")
......@@ -218,7 +218,7 @@ namespace IoTSharp.Data.SqlServer.Migrations
b.Property<string>("MataData")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("TenantId")
b.Property<Guid?>("TenantId")
.HasColumnType("uniqueidentifier");
b.Property<int>("Type")
......@@ -1131,7 +1131,7 @@ namespace IoTSharp.Data.SqlServer.Migrations
b.Property<Guid>("Createor")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("CustomerId")
b.Property<Guid?>("CustomerId")
.HasColumnType("uniqueidentifier");
b.Property<Guid?>("ExecutorId")
......@@ -1185,7 +1185,7 @@ namespace IoTSharp.Data.SqlServer.Migrations
b.Property<string>("TargetId")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("TenantId")
b.Property<Guid?>("TenantId")
.HasColumnType("uniqueidentifier");
b.Property<int>("TestStatus")
......@@ -1222,7 +1222,7 @@ namespace IoTSharp.Data.SqlServer.Migrations
b.Property<DateTime?>("AddDate")
.HasColumnType("datetime2");
b.Property<Guid>("BaseEventId")
b.Property<Guid?>("BaseEventEventId")
.HasColumnType("uniqueidentifier");
b.Property<string>("BizId")
......@@ -1231,10 +1231,10 @@ namespace IoTSharp.Data.SqlServer.Migrations
b.Property<string>("Data")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("FlowId")
b.Property<Guid?>("FlowId")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("FlowRuleId")
b.Property<Guid?>("FlowRuleRuleId")
.HasColumnType("uniqueidentifier");
b.Property<int?>("NodeStatus")
......@@ -1254,11 +1254,11 @@ namespace IoTSharp.Data.SqlServer.Migrations
b.HasKey("OperationId");
b.HasIndex("BaseEventId");
b.HasIndex("BaseEventEventId");
b.HasIndex("FlowId");
b.HasIndex("FlowRuleId");
b.HasIndex("FlowRuleRuleId");
b.ToTable("FlowOperations");
});
......@@ -1278,7 +1278,7 @@ namespace IoTSharp.Data.SqlServer.Migrations
b.Property<string>("Creator")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("CustomerId")
b.Property<Guid?>("CustomerId")
.HasColumnType("uniqueidentifier");
b.Property<string>("DefinitionsXml")
......@@ -1315,7 +1315,7 @@ namespace IoTSharp.Data.SqlServer.Migrations
b.Property<double>("SubVersion")
.HasColumnType("float");
b.Property<Guid>("TenantId")
b.Property<Guid?>("TenantId")
.HasColumnType("uniqueidentifier");
b.Property<double>("Version")
......@@ -1402,7 +1402,7 @@ namespace IoTSharp.Data.SqlServer.Migrations
b.Property<Guid>("Creator")
.HasColumnType("uniqueidentifier");
b.Property<Guid>("CustomerId")
b.Property<Guid?>("CustomerId")
.HasColumnType("uniqueidentifier");
b.Property<string>("DefaultConfig")
......@@ -1426,7 +1426,7 @@ namespace IoTSharp.Data.SqlServer.Migrations
b.Property<string>("Tag")
.HasColumnType("nvarchar(max)");
b.Property<Guid>("TenantId")
b.Property<Guid?>("TenantId")
.HasColumnType("uniqueidentifier");
b.Property<int>("TestStatus")
......@@ -1876,9 +1876,7 @@ namespace IoTSharp.Data.SqlServer.Migrations
{
b.HasOne("IoTSharp.Data.Customer", "Customer")
.WithMany()
.HasForeignKey("CustomerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("CustomerId");
b.HasOne("IoTSharp.Data.FlowRule", "FlowRule")
.WithMany()
......@@ -1886,9 +1884,7 @@ namespace IoTSharp.Data.SqlServer.Migrations
b.HasOne("IoTSharp.Data.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("TenantId");
b.Navigation("Customer");
......@@ -2098,9 +2094,7 @@ namespace IoTSharp.Data.SqlServer.Migrations
{
b.HasOne("IoTSharp.Data.Customer", "Customer")
.WithMany()
.HasForeignKey("CustomerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("CustomerId");
b.HasOne("IoTSharp.Data.RuleTaskExecutor", "Executor")
.WithMany()
......@@ -2112,9 +2106,7 @@ namespace IoTSharp.Data.SqlServer.Migrations
b.HasOne("IoTSharp.Data.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("TenantId");
b.Navigation("Customer");
......@@ -2129,21 +2121,15 @@ namespace IoTSharp.Data.SqlServer.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");
......@@ -2156,15 +2142,11 @@ namespace IoTSharp.Data.SqlServer.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");
......@@ -2205,15 +2187,11 @@ namespace IoTSharp.Data.SqlServer.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");
......
......@@ -11,8 +11,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace IoTSharp.Data.Sqlite.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20220211154534_AddTenantInfoAndRefToken")]
partial class AddTenantInfoAndRefToken
[Migration("20220212030026_AddTenantInfoAndToken")]
partial class AddTenantInfoAndToken
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
......@@ -191,7 +191,7 @@ namespace IoTSharp.Data.Sqlite.Migrations
b.Property<Guid>("Creator")
.HasColumnType("TEXT");
b.Property<Guid>("CustomerId")
b.Property<Guid?>("CustomerId")
.HasColumnType("TEXT");
b.Property<string>("EventDesc")
......@@ -209,7 +209,7 @@ namespace IoTSharp.Data.Sqlite.Migrations
b.Property<string>("MataData")
.HasColumnType("TEXT");
b.Property<Guid>("TenantId")
b.Property<Guid?>("TenantId")
.HasColumnType("TEXT");
b.Property<int>("Type")
......@@ -1853,9 +1853,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.FlowRule", "FlowRule")
.WithMany()
......@@ -1863,9 +1861,7 @@ namespace IoTSharp.Data.Sqlite.Migrations
b.HasOne("IoTSharp.Data.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("TenantId");
b.Navigation("Customer");
......
......@@ -189,7 +189,7 @@ namespace IoTSharp.Data.Sqlite.Migrations
b.Property<Guid>("Creator")
.HasColumnType("TEXT");
b.Property<Guid>("CustomerId")
b.Property<Guid?>("CustomerId")
.HasColumnType("TEXT");
b.Property<string>("EventDesc")
......@@ -207,7 +207,7 @@ namespace IoTSharp.Data.Sqlite.Migrations
b.Property<string>("MataData")
.HasColumnType("TEXT");
b.Property<Guid>("TenantId")
b.Property<Guid?>("TenantId")
.HasColumnType("TEXT");
b.Property<int>("Type")
......@@ -1851,9 +1851,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.FlowRule", "FlowRule")
.WithMany()
......@@ -1861,9 +1859,7 @@ namespace IoTSharp.Data.Sqlite.Migrations
b.HasOne("IoTSharp.Data.Tenant", "Tenant")
.WithMany()
.HasForeignKey("TenantId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
.HasForeignKey("TenantId");
b.Navigation("Customer");
......
......@@ -39,9 +39,7 @@ namespace IoTSharp.Data
public Tenant Tenant { get; set; }
public Guid TenantId { get; set; }
public Guid CustomerId { get; set; }
public Customer Customer { get; set; }
}
......
......@@ -23,11 +23,8 @@ namespace IoTSharp.Data
public string BizId { get; set; }
public string bpmnid { get; set; }
public Flow Flow { get; set; }
public Guid FlowId { get; set; }
public FlowRule FlowRule { get; set; }
public Guid FlowRuleId { get; set; }
public BaseEvent BaseEvent { get; set; }
public Guid BaseEventId { get; set; }
public int Step { get; set; }
public string Tag { get; set; }
}
......
......@@ -12,7 +12,9 @@ namespace IoTSharp.Data
{
[Key] public Guid RuleId { get; set; }
public RuleType RuleType { get; set; }
[Required] public string Name { get; set; }
[Required]
public string Name { get; set; }
public string Describes { get; set; }
public string Runner { get; set; }
public string ExecutableCode { get; set; }
......@@ -28,9 +30,7 @@ namespace IoTSharp.Data
public Guid CreateId { get; set; }
public MountType MountType { get; set; }
public Tenant Tenant { get; set; }
public Guid TenantId { get; set; }
public Guid CustomerId { get; set; }
public Customer Customer { get; set; }
}
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册