//
using System;
using DongfangHydro.Dashboard.Api.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace DongfangHydro.Dashboard.Api.Data.Migrations
{
[DbContext(typeof(DashboardDbContext))]
[Migration("20260710025438_InitialCreate")]
partial class InitialCreate
{
///
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.20")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("DongfangHydro.Dashboard.Api.Domain.Partner", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property("Code")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("nvarchar(40)");
b.Property("ContactName")
.IsRequired()
.HasMaxLength(80)
.HasColumnType("nvarchar(80)");
b.Property("ContactPhone")
.IsRequired()
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.Property("Name")
.IsRequired()
.HasMaxLength(120)
.HasColumnType("nvarchar(120)");
b.Property("PartnerType")
.IsRequired()
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.HasKey("Id");
b.HasIndex("Code")
.IsUnique();
b.ToTable("Partners", (string)null);
});
modelBuilder.Entity("DongfangHydro.Dashboard.Api.Domain.ProductionLine", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property("Code")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("nvarchar(40)");
b.Property("IsActive")
.HasColumnType("bit");
b.Property("Name")
.IsRequired()
.HasMaxLength(80)
.HasColumnType("nvarchar(80)");
b.Property("Owner")
.IsRequired()
.HasMaxLength(80)
.HasColumnType("nvarchar(80)");
b.HasKey("Id");
b.HasIndex("Code")
.IsUnique();
b.ToTable("ProductionLines", (string)null);
});
modelBuilder.Entity("DongfangHydro.Dashboard.Api.Domain.ProductionNode", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property("ActualEnd")
.HasColumnType("datetime2");
b.Property("ActualStart")
.HasColumnType("datetime2");
b.Property("Code")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("nvarchar(60)");
b.Property("CompletedQty")
.HasColumnType("int");
b.Property("DefectQty")
.HasColumnType("int");
b.Property("DelayDays")
.HasColumnType("int");
b.Property("DelayReason")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property("Level")
.HasColumnType("int");
b.Property("MaterialCode")
.IsRequired()
.HasMaxLength(80)
.HasColumnType("nvarchar(80)");
b.Property("Name")
.IsRequired()
.HasMaxLength(240)
.HasColumnType("nvarchar(240)");
b.Property("NodeType")
.IsRequired()
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.Property("OperationCode")
.IsRequired()
.HasMaxLength(60)
.HasColumnType("nvarchar(60)");
b.Property("OrderId")
.HasColumnType("uniqueidentifier");
b.Property("Owner")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property("ParentNodeId")
.HasColumnType("uniqueidentifier");
b.Property("PlannedEnd")
.HasColumnType("datetime2");
b.Property("PlannedStart")
.HasColumnType("datetime2");
b.Property("Progress")
.HasColumnType("int");
b.Property("RequiredQty")
.HasColumnType("int");
b.Property("RiskLevel")
.IsRequired()
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.Property("RowVersion")
.IsConcurrencyToken()
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("rowversion");
b.Property("SortOrder")
.HasColumnType("int");
b.Property("StationName")
.IsRequired()
.HasMaxLength(120)
.HasColumnType("nvarchar(120)");
b.Property("Status")
.IsRequired()
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.Property("SupplyType")
.IsRequired()
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.Property("UpdatedAt")
.HasColumnType("datetimeoffset");
b.Property("Vendor")
.IsRequired()
.HasMaxLength(120)
.HasColumnType("nvarchar(120)");
b.Property("VisualKey")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("nvarchar(40)");
b.HasKey("Id");
b.HasIndex("OrderId", "ParentNodeId", "SortOrder");
b.HasIndex("OrderId", "NodeType", "RiskLevel", "Status");
b.ToTable("ProductionNodes", (string)null);
});
modelBuilder.Entity("DongfangHydro.Dashboard.Api.Domain.ProductionOrder", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property("BatchQty")
.HasColumnType("int");
b.Property("Code")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("nvarchar(40)");
b.Property("CompletedQty")
.HasColumnType("int");
b.Property("CreatedAt")
.HasColumnType("datetimeoffset");
b.Property("DailyDelta")
.HasColumnType("float");
b.Property("DelayDays")
.HasColumnType("int");
b.Property("LineId")
.HasColumnType("uniqueidentifier");
b.Property("LineName")
.IsRequired()
.HasMaxLength(80)
.HasColumnType("nvarchar(80)");
b.Property("Owner")
.IsRequired()
.HasMaxLength(80)
.HasColumnType("nvarchar(80)");
b.Property("PlanAchievement")
.HasColumnType("float");
b.Property("PlannedEnd")
.HasColumnType("datetime2");
b.Property("PlannedStart")
.HasColumnType("datetime2");
b.Property("ProductName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("nvarchar(200)");
b.Property("Progress")
.HasColumnType("int");
b.Property("RequiredQty")
.HasColumnType("int");
b.Property("RiskLevel")
.IsRequired()
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.Property("RowVersion")
.IsConcurrencyToken()
.IsRequired()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("rowversion");
b.Property("Status")
.IsRequired()
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.Property("ThumbnailKey")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("nvarchar(40)");
b.Property("UpdatedAt")
.HasColumnType("datetimeoffset");
b.HasKey("Id");
b.HasIndex("Code")
.IsUnique();
b.HasIndex("LineId");
b.HasIndex("Status", "RiskLevel", "PlannedEnd");
b.ToTable("ProductionOrders", (string)null);
});
modelBuilder.Entity("DongfangHydro.Dashboard.Api.Domain.ProductionTrendPoint", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property("Achievement")
.HasColumnType("float");
b.Property("ActualQty")
.HasColumnType("int");
b.Property("Completion")
.HasColumnType("int");
b.Property("OrderId")
.HasColumnType("uniqueidentifier");
b.Property("PlannedQty")
.HasColumnType("int");
b.Property("Risk")
.HasColumnType("int");
b.Property("SampleTime")
.HasColumnType("datetimeoffset");
b.HasKey("Id");
b.HasIndex("OrderId", "SampleTime")
.IsDescending(false, true);
b.ToTable("ProductionTrendPoints", (string)null);
});
modelBuilder.Entity("DongfangHydro.Dashboard.Api.Domain.RiskEvent", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd()
.HasColumnType("uniqueidentifier");
b.Property("HandlingStatus")
.IsRequired()
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.Property("Message")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("nvarchar(500)");
b.Property("NodeId")
.HasColumnType("uniqueidentifier");
b.Property("NodeName")
.IsRequired()
.HasMaxLength(240)
.HasColumnType("nvarchar(240)");
b.Property("OccurredAt")
.HasColumnType("datetimeoffset");
b.Property("OrderCode")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("nvarchar(40)");
b.Property("OrderId")
.HasColumnType("uniqueidentifier");
b.Property("RiskLevel")
.IsRequired()
.HasMaxLength(32)
.HasColumnType("nvarchar(32)");
b.HasKey("Id");
b.HasIndex("OrderId", "NodeId");
b.HasIndex("OrderId", "OccurredAt")
.IsDescending(false, true);
b.ToTable("RiskEvents", (string)null);
});
modelBuilder.Entity("DongfangHydro.Dashboard.Api.Domain.ProductionNode", b =>
{
b.HasOne("DongfangHydro.Dashboard.Api.Domain.ProductionOrder", null)
.WithMany()
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DongfangHydro.Dashboard.Api.Domain.ProductionNode", null)
.WithMany()
.HasForeignKey("OrderId", "ParentNodeId")
.HasPrincipalKey("OrderId", "Id")
.OnDelete(DeleteBehavior.Restrict);
});
modelBuilder.Entity("DongfangHydro.Dashboard.Api.Domain.ProductionOrder", b =>
{
b.HasOne("DongfangHydro.Dashboard.Api.Domain.ProductionLine", null)
.WithMany()
.HasForeignKey("LineId")
.OnDelete(DeleteBehavior.SetNull);
});
modelBuilder.Entity("DongfangHydro.Dashboard.Api.Domain.ProductionTrendPoint", b =>
{
b.HasOne("DongfangHydro.Dashboard.Api.Domain.ProductionOrder", null)
.WithMany()
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("DongfangHydro.Dashboard.Api.Domain.RiskEvent", b =>
{
b.HasOne("DongfangHydro.Dashboard.Api.Domain.ProductionOrder", null)
.WithMany()
.HasForeignKey("OrderId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DongfangHydro.Dashboard.Api.Domain.ProductionNode", null)
.WithMany()
.HasForeignKey("OrderId", "NodeId")
.HasPrincipalKey("OrderId", "Id")
.OnDelete(DeleteBehavior.NoAction)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}