feat: remove Supplier/SupplierOffering/PurchaseItem entities and migrate schema
This commit is contained in:
@@ -12,15 +12,12 @@ public class ApplicationDbContext : DbContext
|
|||||||
|
|
||||||
public DbSet<Material> Materials => Set<Material>();
|
public DbSet<Material> Materials => Set<Material>();
|
||||||
public DbSet<MaterialDimensions> MaterialDimensions => Set<MaterialDimensions>();
|
public DbSet<MaterialDimensions> MaterialDimensions => Set<MaterialDimensions>();
|
||||||
public DbSet<Supplier> Suppliers => Set<Supplier>();
|
|
||||||
public DbSet<StockItem> StockItems => Set<StockItem>();
|
public DbSet<StockItem> StockItems => Set<StockItem>();
|
||||||
public DbSet<SupplierOffering> SupplierOfferings => Set<SupplierOffering>();
|
|
||||||
public DbSet<StockTransaction> StockTransactions => Set<StockTransaction>();
|
public DbSet<StockTransaction> StockTransactions => Set<StockTransaction>();
|
||||||
public DbSet<CuttingTool> CuttingTools => Set<CuttingTool>();
|
public DbSet<CuttingTool> CuttingTools => Set<CuttingTool>();
|
||||||
public DbSet<Job> Jobs => Set<Job>();
|
public DbSet<Job> Jobs => Set<Job>();
|
||||||
public DbSet<JobPart> JobParts => Set<JobPart>();
|
public DbSet<JobPart> JobParts => Set<JobPart>();
|
||||||
public DbSet<JobStock> JobStocks => Set<JobStock>();
|
public DbSet<JobStock> JobStocks => Set<JobStock>();
|
||||||
public DbSet<PurchaseItem> PurchaseItems => Set<PurchaseItem>();
|
|
||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
@@ -143,15 +140,6 @@ public class ApplicationDbContext : DbContext
|
|||||||
entity.HasIndex(e => e.NominalSize);
|
entity.HasIndex(e => e.NominalSize);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Supplier
|
|
||||||
modelBuilder.Entity<Supplier>(entity =>
|
|
||||||
{
|
|
||||||
entity.HasKey(e => e.Id);
|
|
||||||
entity.Property(e => e.Name).HasMaxLength(100).IsRequired();
|
|
||||||
entity.Property(e => e.ContactInfo).HasMaxLength(500);
|
|
||||||
entity.Property(e => e.CreatedAt).HasDefaultValueSql("GETUTCDATE()");
|
|
||||||
});
|
|
||||||
|
|
||||||
// StockItem
|
// StockItem
|
||||||
modelBuilder.Entity<StockItem>(entity =>
|
modelBuilder.Entity<StockItem>(entity =>
|
||||||
{
|
{
|
||||||
@@ -174,7 +162,6 @@ public class ApplicationDbContext : DbContext
|
|||||||
{
|
{
|
||||||
entity.HasKey(e => e.Id);
|
entity.HasKey(e => e.Id);
|
||||||
entity.Property(e => e.Notes).HasMaxLength(500);
|
entity.Property(e => e.Notes).HasMaxLength(500);
|
||||||
entity.Property(e => e.UnitPrice).HasPrecision(10, 2);
|
|
||||||
entity.Property(e => e.CreatedAt).HasDefaultValueSql("GETUTCDATE()");
|
entity.Property(e => e.CreatedAt).HasDefaultValueSql("GETUTCDATE()");
|
||||||
|
|
||||||
entity.HasOne(e => e.StockItem)
|
entity.HasOne(e => e.StockItem)
|
||||||
@@ -186,33 +173,6 @@ public class ApplicationDbContext : DbContext
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey(e => e.JobId)
|
.HasForeignKey(e => e.JobId)
|
||||||
.OnDelete(DeleteBehavior.SetNull);
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
entity.HasOne(e => e.Supplier)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey(e => e.SupplierId)
|
|
||||||
.OnDelete(DeleteBehavior.SetNull);
|
|
||||||
});
|
|
||||||
|
|
||||||
// SupplierOffering
|
|
||||||
modelBuilder.Entity<SupplierOffering>(entity =>
|
|
||||||
{
|
|
||||||
entity.HasKey(e => e.Id);
|
|
||||||
entity.Property(e => e.PartNumber).HasMaxLength(100);
|
|
||||||
entity.Property(e => e.SupplierDescription).HasMaxLength(255);
|
|
||||||
entity.Property(e => e.Price).HasPrecision(10, 2);
|
|
||||||
entity.Property(e => e.Notes).HasMaxLength(255);
|
|
||||||
|
|
||||||
entity.HasOne(e => e.StockItem)
|
|
||||||
.WithMany(s => s.SupplierOfferings)
|
|
||||||
.HasForeignKey(e => e.StockItemId)
|
|
||||||
.OnDelete(DeleteBehavior.Cascade);
|
|
||||||
|
|
||||||
entity.HasOne(e => e.Supplier)
|
|
||||||
.WithMany(s => s.Offerings)
|
|
||||||
.HasForeignKey(e => e.SupplierId)
|
|
||||||
.OnDelete(DeleteBehavior.Cascade);
|
|
||||||
|
|
||||||
entity.HasIndex(e => new { e.SupplierId, e.StockItemId }).IsUnique();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// CuttingTool
|
// CuttingTool
|
||||||
@@ -282,34 +242,6 @@ public class ApplicationDbContext : DbContext
|
|||||||
.OnDelete(DeleteBehavior.SetNull);
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
});
|
});
|
||||||
|
|
||||||
// PurchaseItem
|
|
||||||
modelBuilder.Entity<PurchaseItem>(entity =>
|
|
||||||
{
|
|
||||||
entity.HasKey(e => e.Id);
|
|
||||||
entity.Property(e => e.Notes).HasMaxLength(500);
|
|
||||||
entity.Property(e => e.Status)
|
|
||||||
.HasMaxLength(20)
|
|
||||||
.HasConversion(
|
|
||||||
v => v.ToString(),
|
|
||||||
v => Enum.Parse<PurchaseItemStatus>(v));
|
|
||||||
entity.Property(e => e.CreatedAt).HasDefaultValueSql("GETUTCDATE()");
|
|
||||||
|
|
||||||
entity.HasOne(e => e.StockItem)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey(e => e.StockItemId)
|
|
||||||
.OnDelete(DeleteBehavior.Cascade);
|
|
||||||
|
|
||||||
entity.HasOne(e => e.Supplier)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey(e => e.SupplierId)
|
|
||||||
.OnDelete(DeleteBehavior.SetNull);
|
|
||||||
|
|
||||||
entity.HasOne(e => e.Job)
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey(e => e.JobId)
|
|
||||||
.OnDelete(DeleteBehavior.SetNull);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Seed default cutting tools
|
// Seed default cutting tools
|
||||||
modelBuilder.Entity<CuttingTool>().HasData(
|
modelBuilder.Entity<CuttingTool>().HasData(
|
||||||
new CuttingTool { Id = 1, Name = "Bandsaw", KerfInches = 0.0625m, IsDefault = true, IsActive = true },
|
new CuttingTool { Id = 1, Name = "Bandsaw", KerfInches = 0.0625m, IsDefault = true, IsActive = true },
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
namespace CutList.Web.Data.Entities;
|
|
||||||
|
|
||||||
public enum PurchaseItemStatus
|
|
||||||
{
|
|
||||||
Pending,
|
|
||||||
Ordered,
|
|
||||||
Received
|
|
||||||
}
|
|
||||||
|
|
||||||
public class PurchaseItem
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int StockItemId { get; set; }
|
|
||||||
public int? SupplierId { get; set; }
|
|
||||||
public int Quantity { get; set; }
|
|
||||||
public int? JobId { get; set; }
|
|
||||||
public string? Notes { get; set; }
|
|
||||||
public PurchaseItemStatus Status { get; set; } = PurchaseItemStatus.Pending;
|
|
||||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
|
||||||
public DateTime? UpdatedAt { get; set; }
|
|
||||||
|
|
||||||
public StockItem StockItem { get; set; } = null!;
|
|
||||||
public Supplier? Supplier { get; set; }
|
|
||||||
public Job? Job { get; set; }
|
|
||||||
}
|
|
||||||
@@ -13,6 +13,5 @@ public class StockItem
|
|||||||
public DateTime? UpdatedAt { get; set; }
|
public DateTime? UpdatedAt { get; set; }
|
||||||
|
|
||||||
public Material Material { get; set; } = null!;
|
public Material Material { get; set; } = null!;
|
||||||
public ICollection<SupplierOffering> SupplierOfferings { get; set; } = new List<SupplierOffering>();
|
|
||||||
public ICollection<StockTransaction> Transactions { get; set; } = new List<StockTransaction>();
|
public ICollection<StockTransaction> Transactions { get; set; } = new List<StockTransaction>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,11 @@ public class StockTransaction
|
|||||||
public int Quantity { get; set; }
|
public int Quantity { get; set; }
|
||||||
public StockTransactionType Type { get; set; }
|
public StockTransactionType Type { get; set; }
|
||||||
public int? JobId { get; set; }
|
public int? JobId { get; set; }
|
||||||
public int? SupplierId { get; set; }
|
|
||||||
public decimal? UnitPrice { get; set; }
|
|
||||||
public string? Notes { get; set; }
|
public string? Notes { get; set; }
|
||||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||||
|
|
||||||
public StockItem StockItem { get; set; } = null!;
|
public StockItem StockItem { get; set; } = null!;
|
||||||
public Job? Job { get; set; }
|
public Job? Job { get; set; }
|
||||||
public Supplier? Supplier { get; set; }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum StockTransactionType
|
public enum StockTransactionType
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
namespace CutList.Web.Data.Entities;
|
|
||||||
|
|
||||||
public class Supplier
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public string Name { get; set; } = string.Empty;
|
|
||||||
public string? ContactInfo { get; set; }
|
|
||||||
public string? Notes { get; set; }
|
|
||||||
public bool IsActive { get; set; } = true;
|
|
||||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
|
||||||
|
|
||||||
public ICollection<SupplierOffering> Offerings { get; set; } = new List<SupplierOffering>();
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
namespace CutList.Web.Data.Entities;
|
|
||||||
|
|
||||||
public class SupplierOffering
|
|
||||||
{
|
|
||||||
public int Id { get; set; }
|
|
||||||
public int StockItemId { get; set; }
|
|
||||||
public int SupplierId { get; set; }
|
|
||||||
public string? PartNumber { get; set; }
|
|
||||||
public string? SupplierDescription { get; set; }
|
|
||||||
public decimal? Price { get; set; }
|
|
||||||
public string? Notes { get; set; }
|
|
||||||
public bool IsActive { get; set; } = true;
|
|
||||||
|
|
||||||
public StockItem StockItem { get; set; } = null!;
|
|
||||||
public Supplier Supplier { get; set; } = null!;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,684 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using CutList.Web.Data;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace CutList.Web.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(ApplicationDbContext))]
|
||||||
|
[Migration("20260801124832_RemoveVendorData")]
|
||||||
|
partial class RemoveVendorData
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "10.0.4")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.HasSequence("MaterialDimensionsSequence");
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.CuttingTool", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<bool>("IsActive")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<bool>("IsDefault")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<decimal>("KerfInches")
|
||||||
|
.HasPrecision(6, 4)
|
||||||
|
.HasColumnType("decimal(6,4)");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("nvarchar(50)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("CuttingTools");
|
||||||
|
|
||||||
|
b.HasData(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
IsActive = true,
|
||||||
|
IsDefault = true,
|
||||||
|
KerfInches = 0.0625m,
|
||||||
|
Name = "Bandsaw"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
IsActive = true,
|
||||||
|
IsDefault = false,
|
||||||
|
KerfInches = 0.125m,
|
||||||
|
Name = "Chop Saw"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 3,
|
||||||
|
IsActive = true,
|
||||||
|
IsDefault = false,
|
||||||
|
KerfInches = 0.0625m,
|
||||||
|
Name = "Cold Cut Saw"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 4,
|
||||||
|
IsActive = true,
|
||||||
|
IsDefault = false,
|
||||||
|
KerfInches = 0.0625m,
|
||||||
|
Name = "Hacksaw"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.Job", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("datetime2")
|
||||||
|
.HasDefaultValueSql("GETUTCDATE()");
|
||||||
|
|
||||||
|
b.Property<string>("Customer")
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("nvarchar(100)");
|
||||||
|
|
||||||
|
b.Property<int?>("CuttingToolId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("JobNumber")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(20)
|
||||||
|
.HasColumnType("nvarchar(20)");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("LockedAt")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("nvarchar(100)");
|
||||||
|
|
||||||
|
b.Property<string>("Notes")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("OptimizationResultJson")
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("OptimizedAt")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("UpdatedAt")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("CuttingToolId");
|
||||||
|
|
||||||
|
b.HasIndex("JobNumber")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("Jobs");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.JobPart", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("JobId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<decimal>("LengthInches")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.Property<int>("MaterialId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("nvarchar(100)");
|
||||||
|
|
||||||
|
b.Property<int>("Quantity")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("SortOrder")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("JobId");
|
||||||
|
|
||||||
|
b.HasIndex("MaterialId");
|
||||||
|
|
||||||
|
b.ToTable("JobParts");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.JobStock", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<bool>("IsCustomLength")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<int>("JobId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<decimal>("LengthInches")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.Property<int>("MaterialId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Priority")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Quantity")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("SortOrder")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int?>("StockItemId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("JobId");
|
||||||
|
|
||||||
|
b.HasIndex("MaterialId");
|
||||||
|
|
||||||
|
b.HasIndex("StockItemId");
|
||||||
|
|
||||||
|
b.ToTable("JobStocks");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.Material", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("datetime2")
|
||||||
|
.HasDefaultValueSql("GETUTCDATE()");
|
||||||
|
|
||||||
|
b.Property<string>("Description")
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("nvarchar(255)");
|
||||||
|
|
||||||
|
b.Property<string>("Grade")
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("nvarchar(50)");
|
||||||
|
|
||||||
|
b.Property<bool>("IsActive")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<string>("Shape")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(50)
|
||||||
|
.HasColumnType("nvarchar(50)");
|
||||||
|
|
||||||
|
b.Property<string>("Size")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("nvarchar(100)");
|
||||||
|
|
||||||
|
b.Property<int>("SortOrder")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Type")
|
||||||
|
.IsRequired()
|
||||||
|
.HasMaxLength(20)
|
||||||
|
.HasColumnType("nvarchar(20)");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("UpdatedAt")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Materials");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.MaterialDimensions", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int")
|
||||||
|
.HasDefaultValueSql("NEXT VALUE FOR [MaterialDimensionsSequence]");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseSequence(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("MaterialId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("MaterialId")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable((string)null);
|
||||||
|
|
||||||
|
b.UseTpcMappingStrategy();
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.StockItem", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("datetime2")
|
||||||
|
.HasDefaultValueSql("GETUTCDATE()");
|
||||||
|
|
||||||
|
b.Property<bool>("IsActive")
|
||||||
|
.HasColumnType("bit");
|
||||||
|
|
||||||
|
b.Property<decimal>("LengthInches")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.Property<int>("MaterialId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.HasMaxLength(100)
|
||||||
|
.HasColumnType("nvarchar(100)");
|
||||||
|
|
||||||
|
b.Property<string>("Notes")
|
||||||
|
.HasMaxLength(255)
|
||||||
|
.HasColumnType("nvarchar(255)");
|
||||||
|
|
||||||
|
b.Property<int>("QuantityOnHand")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("UpdatedAt")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("MaterialId", "LengthInches")
|
||||||
|
.IsUnique();
|
||||||
|
|
||||||
|
b.ToTable("StockItems");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.StockTransaction", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<DateTime>("CreatedAt")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("datetime2")
|
||||||
|
.HasDefaultValueSql("GETUTCDATE()");
|
||||||
|
|
||||||
|
b.Property<int?>("JobId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Notes")
|
||||||
|
.HasMaxLength(500)
|
||||||
|
.HasColumnType("nvarchar(500)");
|
||||||
|
|
||||||
|
b.Property<int>("Quantity")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("StockItemId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Type")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("JobId");
|
||||||
|
|
||||||
|
b.HasIndex("StockItemId");
|
||||||
|
|
||||||
|
b.ToTable("StockTransactions");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.AngleDimensions", b =>
|
||||||
|
{
|
||||||
|
b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions");
|
||||||
|
|
||||||
|
b.Property<decimal>("Leg1")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.Property<decimal>("Leg2")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.Property<decimal>("Thickness")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.HasIndex("Leg1");
|
||||||
|
|
||||||
|
b.ToTable("DimAngle", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.ChannelDimensions", b =>
|
||||||
|
{
|
||||||
|
b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions");
|
||||||
|
|
||||||
|
b.Property<decimal>("Flange")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.Property<decimal>("Height")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.Property<decimal>("Web")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.HasIndex("Height");
|
||||||
|
|
||||||
|
b.ToTable("DimChannel", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.FlatBarDimensions", b =>
|
||||||
|
{
|
||||||
|
b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions");
|
||||||
|
|
||||||
|
b.Property<decimal>("Thickness")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.Property<decimal>("Width")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.HasIndex("Width");
|
||||||
|
|
||||||
|
b.ToTable("DimFlatBar", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.IBeamDimensions", b =>
|
||||||
|
{
|
||||||
|
b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions");
|
||||||
|
|
||||||
|
b.Property<decimal>("Height")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.Property<decimal>("WeightPerFoot")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.HasIndex("Height");
|
||||||
|
|
||||||
|
b.ToTable("DimIBeam", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.PipeDimensions", b =>
|
||||||
|
{
|
||||||
|
b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions");
|
||||||
|
|
||||||
|
b.Property<decimal>("NominalSize")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.Property<string>("Schedule")
|
||||||
|
.HasMaxLength(20)
|
||||||
|
.HasColumnType("nvarchar(20)");
|
||||||
|
|
||||||
|
b.Property<decimal?>("Wall")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.HasIndex("NominalSize");
|
||||||
|
|
||||||
|
b.ToTable("DimPipe", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.RectangularTubeDimensions", b =>
|
||||||
|
{
|
||||||
|
b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions");
|
||||||
|
|
||||||
|
b.Property<decimal>("Height")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.Property<decimal>("Wall")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.Property<decimal>("Width")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.HasIndex("Width");
|
||||||
|
|
||||||
|
b.ToTable("DimRectangularTube", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.RoundBarDimensions", b =>
|
||||||
|
{
|
||||||
|
b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions");
|
||||||
|
|
||||||
|
b.Property<decimal>("Diameter")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.HasIndex("Diameter");
|
||||||
|
|
||||||
|
b.ToTable("DimRoundBar", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.RoundTubeDimensions", b =>
|
||||||
|
{
|
||||||
|
b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions");
|
||||||
|
|
||||||
|
b.Property<decimal>("OuterDiameter")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.Property<decimal>("Wall")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.HasIndex("OuterDiameter");
|
||||||
|
|
||||||
|
b.ToTable("DimRoundTube", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.SquareBarDimensions", b =>
|
||||||
|
{
|
||||||
|
b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions");
|
||||||
|
|
||||||
|
b.Property<decimal>("Size")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.HasIndex("Size");
|
||||||
|
|
||||||
|
b.ToTable("DimSquareBar", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.SquareTubeDimensions", b =>
|
||||||
|
{
|
||||||
|
b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions");
|
||||||
|
|
||||||
|
b.Property<decimal>("Size")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.Property<decimal>("Wall")
|
||||||
|
.HasPrecision(10, 4)
|
||||||
|
.HasColumnType("decimal(10,4)");
|
||||||
|
|
||||||
|
b.HasIndex("Size");
|
||||||
|
|
||||||
|
b.ToTable("DimSquareTube", (string)null);
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.Job", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("CutList.Web.Data.Entities.CuttingTool", "CuttingTool")
|
||||||
|
.WithMany("Jobs")
|
||||||
|
.HasForeignKey("CuttingToolId")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.Navigation("CuttingTool");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.JobPart", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("CutList.Web.Data.Entities.Job", "Job")
|
||||||
|
.WithMany("Parts")
|
||||||
|
.HasForeignKey("JobId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("CutList.Web.Data.Entities.Material", "Material")
|
||||||
|
.WithMany("JobParts")
|
||||||
|
.HasForeignKey("MaterialId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Job");
|
||||||
|
|
||||||
|
b.Navigation("Material");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.JobStock", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("CutList.Web.Data.Entities.Job", "Job")
|
||||||
|
.WithMany("Stock")
|
||||||
|
.HasForeignKey("JobId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("CutList.Web.Data.Entities.Material", "Material")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("MaterialId")
|
||||||
|
.OnDelete(DeleteBehavior.Restrict)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("CutList.Web.Data.Entities.StockItem", "StockItem")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("StockItemId")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.Navigation("Job");
|
||||||
|
|
||||||
|
b.Navigation("Material");
|
||||||
|
|
||||||
|
b.Navigation("StockItem");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.MaterialDimensions", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("CutList.Web.Data.Entities.Material", "Material")
|
||||||
|
.WithOne("Dimensions")
|
||||||
|
.HasForeignKey("CutList.Web.Data.Entities.MaterialDimensions", "MaterialId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Material");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.StockItem", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("CutList.Web.Data.Entities.Material", "Material")
|
||||||
|
.WithMany("StockItems")
|
||||||
|
.HasForeignKey("MaterialId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Material");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.StockTransaction", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("CutList.Web.Data.Entities.Job", "Job")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("JobId")
|
||||||
|
.OnDelete(DeleteBehavior.SetNull);
|
||||||
|
|
||||||
|
b.HasOne("CutList.Web.Data.Entities.StockItem", "StockItem")
|
||||||
|
.WithMany("Transactions")
|
||||||
|
.HasForeignKey("StockItemId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Job");
|
||||||
|
|
||||||
|
b.Navigation("StockItem");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.CuttingTool", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Jobs");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.Job", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Parts");
|
||||||
|
|
||||||
|
b.Navigation("Stock");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.Material", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Dimensions");
|
||||||
|
|
||||||
|
b.Navigation("JobParts");
|
||||||
|
|
||||||
|
b.Navigation("StockItems");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("CutList.Web.Data.Entities.StockItem", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Transactions");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,183 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace CutList.Web.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class RemoveVendorData : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_StockTransactions_Suppliers_SupplierId",
|
||||||
|
table: "StockTransactions");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "PurchaseItems");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "SupplierOfferings");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Suppliers");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_StockTransactions_SupplierId",
|
||||||
|
table: "StockTransactions");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "SupplierId",
|
||||||
|
table: "StockTransactions");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "UnitPrice",
|
||||||
|
table: "StockTransactions");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "SupplierId",
|
||||||
|
table: "StockTransactions",
|
||||||
|
type: "int",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<decimal>(
|
||||||
|
name: "UnitPrice",
|
||||||
|
table: "StockTransactions",
|
||||||
|
type: "decimal(10,2)",
|
||||||
|
precision: 10,
|
||||||
|
scale: 2,
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Suppliers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ContactInfo = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValueSql: "GETUTCDATE()"),
|
||||||
|
IsActive = table.Column<bool>(type: "bit", nullable: false),
|
||||||
|
Name = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: false),
|
||||||
|
Notes = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Suppliers", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "PurchaseItems",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
JobId = table.Column<int>(type: "int", nullable: true),
|
||||||
|
StockItemId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
SupplierId = table.Column<int>(type: "int", nullable: true),
|
||||||
|
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false, defaultValueSql: "GETUTCDATE()"),
|
||||||
|
Notes = table.Column<string>(type: "nvarchar(500)", maxLength: 500, nullable: true),
|
||||||
|
Quantity = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Status = table.Column<string>(type: "nvarchar(20)", maxLength: 20, nullable: false),
|
||||||
|
UpdatedAt = table.Column<DateTime>(type: "datetime2", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_PurchaseItems", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PurchaseItems_Jobs_JobId",
|
||||||
|
column: x => x.JobId,
|
||||||
|
principalTable: "Jobs",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.SetNull);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PurchaseItems_StockItems_StockItemId",
|
||||||
|
column: x => x.StockItemId,
|
||||||
|
principalTable: "StockItems",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_PurchaseItems_Suppliers_SupplierId",
|
||||||
|
column: x => x.SupplierId,
|
||||||
|
principalTable: "Suppliers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.SetNull);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "SupplierOfferings",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
StockItemId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
SupplierId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
IsActive = table.Column<bool>(type: "bit", nullable: false),
|
||||||
|
Notes = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: true),
|
||||||
|
PartNumber = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
|
||||||
|
Price = table.Column<decimal>(type: "decimal(10,2)", precision: 10, scale: 2, nullable: true),
|
||||||
|
SupplierDescription = table.Column<string>(type: "nvarchar(255)", maxLength: 255, nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_SupplierOfferings", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_SupplierOfferings_StockItems_StockItemId",
|
||||||
|
column: x => x.StockItemId,
|
||||||
|
principalTable: "StockItems",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_SupplierOfferings_Suppliers_SupplierId",
|
||||||
|
column: x => x.SupplierId,
|
||||||
|
principalTable: "Suppliers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_StockTransactions_SupplierId",
|
||||||
|
table: "StockTransactions",
|
||||||
|
column: "SupplierId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PurchaseItems_JobId",
|
||||||
|
table: "PurchaseItems",
|
||||||
|
column: "JobId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PurchaseItems_StockItemId",
|
||||||
|
table: "PurchaseItems",
|
||||||
|
column: "StockItemId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_PurchaseItems_SupplierId",
|
||||||
|
table: "PurchaseItems",
|
||||||
|
column: "SupplierId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_SupplierOfferings_StockItemId",
|
||||||
|
table: "SupplierOfferings",
|
||||||
|
column: "StockItemId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_SupplierOfferings_SupplierId_StockItemId",
|
||||||
|
table: "SupplierOfferings",
|
||||||
|
columns: new[] { "SupplierId", "StockItemId" },
|
||||||
|
unique: true);
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_StockTransactions_Suppliers_SupplierId",
|
||||||
|
table: "StockTransactions",
|
||||||
|
column: "SupplierId",
|
||||||
|
principalTable: "Suppliers",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.SetNull);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,7 +17,7 @@ namespace CutList.Web.Migrations
|
|||||||
{
|
{
|
||||||
#pragma warning disable 612, 618
|
#pragma warning disable 612, 618
|
||||||
modelBuilder
|
modelBuilder
|
||||||
.HasAnnotation("ProductVersion", "8.0.11")
|
.HasAnnotation("ProductVersion", "10.0.4")
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
@@ -294,54 +294,6 @@ namespace CutList.Web.Migrations
|
|||||||
b.UseTpcMappingStrategy();
|
b.UseTpcMappingStrategy();
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("CutList.Web.Data.Entities.PurchaseItem", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("datetime2")
|
|
||||||
.HasDefaultValueSql("GETUTCDATE()");
|
|
||||||
|
|
||||||
b.Property<int?>("JobId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("Notes")
|
|
||||||
.HasMaxLength(500)
|
|
||||||
.HasColumnType("nvarchar(500)");
|
|
||||||
|
|
||||||
b.Property<int>("Quantity")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("Status")
|
|
||||||
.IsRequired()
|
|
||||||
.HasMaxLength(20)
|
|
||||||
.HasColumnType("nvarchar(20)");
|
|
||||||
|
|
||||||
b.Property<int>("StockItemId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int?>("SupplierId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<DateTime?>("UpdatedAt")
|
|
||||||
.HasColumnType("datetime2");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("JobId");
|
|
||||||
|
|
||||||
b.HasIndex("StockItemId");
|
|
||||||
|
|
||||||
b.HasIndex("SupplierId");
|
|
||||||
|
|
||||||
b.ToTable("PurchaseItems");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("CutList.Web.Data.Entities.StockItem", b =>
|
modelBuilder.Entity("CutList.Web.Data.Entities.StockItem", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@@ -413,103 +365,18 @@ namespace CutList.Web.Migrations
|
|||||||
b.Property<int>("StockItemId")
|
b.Property<int>("StockItemId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<int?>("SupplierId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Type")
|
b.Property<int>("Type")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<decimal?>("UnitPrice")
|
|
||||||
.HasPrecision(10, 2)
|
|
||||||
.HasColumnType("decimal(10,2)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("JobId");
|
b.HasIndex("JobId");
|
||||||
|
|
||||||
b.HasIndex("StockItemId");
|
b.HasIndex("StockItemId");
|
||||||
|
|
||||||
b.HasIndex("SupplierId");
|
|
||||||
|
|
||||||
b.ToTable("StockTransactions");
|
b.ToTable("StockTransactions");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("CutList.Web.Data.Entities.Supplier", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ContactInfo")
|
|
||||||
.HasMaxLength(500)
|
|
||||||
.HasColumnType("nvarchar(500)");
|
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("datetime2")
|
|
||||||
.HasDefaultValueSql("GETUTCDATE()");
|
|
||||||
|
|
||||||
b.Property<bool>("IsActive")
|
|
||||||
.HasColumnType("bit");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasMaxLength(100)
|
|
||||||
.HasColumnType("nvarchar(100)");
|
|
||||||
|
|
||||||
b.Property<string>("Notes")
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Suppliers");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("CutList.Web.Data.Entities.SupplierOffering", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<bool>("IsActive")
|
|
||||||
.HasColumnType("bit");
|
|
||||||
|
|
||||||
b.Property<string>("Notes")
|
|
||||||
.HasMaxLength(255)
|
|
||||||
.HasColumnType("nvarchar(255)");
|
|
||||||
|
|
||||||
b.Property<string>("PartNumber")
|
|
||||||
.HasMaxLength(100)
|
|
||||||
.HasColumnType("nvarchar(100)");
|
|
||||||
|
|
||||||
b.Property<decimal?>("Price")
|
|
||||||
.HasPrecision(10, 2)
|
|
||||||
.HasColumnType("decimal(10,2)");
|
|
||||||
|
|
||||||
b.Property<int>("StockItemId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("SupplierDescription")
|
|
||||||
.HasMaxLength(255)
|
|
||||||
.HasColumnType("nvarchar(255)");
|
|
||||||
|
|
||||||
b.Property<int>("SupplierId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("StockItemId");
|
|
||||||
|
|
||||||
b.HasIndex("SupplierId", "StockItemId")
|
|
||||||
.IsUnique();
|
|
||||||
|
|
||||||
b.ToTable("SupplierOfferings");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("CutList.Web.Data.Entities.AngleDimensions", b =>
|
modelBuilder.Entity("CutList.Web.Data.Entities.AngleDimensions", b =>
|
||||||
{
|
{
|
||||||
b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions");
|
b.HasBaseType("CutList.Web.Data.Entities.MaterialDimensions");
|
||||||
@@ -754,31 +621,6 @@ namespace CutList.Web.Migrations
|
|||||||
b.Navigation("Material");
|
b.Navigation("Material");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("CutList.Web.Data.Entities.PurchaseItem", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("CutList.Web.Data.Entities.Job", "Job")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("JobId")
|
|
||||||
.OnDelete(DeleteBehavior.SetNull);
|
|
||||||
|
|
||||||
b.HasOne("CutList.Web.Data.Entities.StockItem", "StockItem")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("StockItemId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("CutList.Web.Data.Entities.Supplier", "Supplier")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("SupplierId")
|
|
||||||
.OnDelete(DeleteBehavior.SetNull);
|
|
||||||
|
|
||||||
b.Navigation("Job");
|
|
||||||
|
|
||||||
b.Navigation("StockItem");
|
|
||||||
|
|
||||||
b.Navigation("Supplier");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("CutList.Web.Data.Entities.StockItem", b =>
|
modelBuilder.Entity("CutList.Web.Data.Entities.StockItem", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("CutList.Web.Data.Entities.Material", "Material")
|
b.HasOne("CutList.Web.Data.Entities.Material", "Material")
|
||||||
@@ -803,35 +645,9 @@ namespace CutList.Web.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("CutList.Web.Data.Entities.Supplier", "Supplier")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("SupplierId")
|
|
||||||
.OnDelete(DeleteBehavior.SetNull);
|
|
||||||
|
|
||||||
b.Navigation("Job");
|
b.Navigation("Job");
|
||||||
|
|
||||||
b.Navigation("StockItem");
|
b.Navigation("StockItem");
|
||||||
|
|
||||||
b.Navigation("Supplier");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("CutList.Web.Data.Entities.SupplierOffering", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("CutList.Web.Data.Entities.StockItem", "StockItem")
|
|
||||||
.WithMany("SupplierOfferings")
|
|
||||||
.HasForeignKey("StockItemId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("CutList.Web.Data.Entities.Supplier", "Supplier")
|
|
||||||
.WithMany("Offerings")
|
|
||||||
.HasForeignKey("SupplierId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("StockItem");
|
|
||||||
|
|
||||||
b.Navigation("Supplier");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("CutList.Web.Data.Entities.CuttingTool", b =>
|
modelBuilder.Entity("CutList.Web.Data.Entities.CuttingTool", b =>
|
||||||
@@ -857,15 +673,8 @@ namespace CutList.Web.Migrations
|
|||||||
|
|
||||||
modelBuilder.Entity("CutList.Web.Data.Entities.StockItem", b =>
|
modelBuilder.Entity("CutList.Web.Data.Entities.StockItem", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("SupplierOfferings");
|
|
||||||
|
|
||||||
b.Navigation("Transactions");
|
b.Navigation("Transactions");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("CutList.Web.Data.Entities.Supplier", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Offerings");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
#pragma warning restore 612, 618
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user