Refactor code structure for int in alll ids instesd defult using long

This commit is contained in:
2026-07-15 15:35:54 +05:30
parent 6c7f53350f
commit ed2ee87c68
120 changed files with 2775 additions and 12494 deletions
+1 -1
View File
@@ -30,5 +30,5 @@ public sealed class CurrentUser : ICurrentUser
}
}
public long AuditUserId => long.TryParse(UserId, out var id) ? id : User.SystemUserId;
public int AuditUserId => int.TryParse(UserId, out var id) ? id : User.SystemUserId;
}
+1 -1
View File
@@ -15,7 +15,7 @@ public interface ICurrentUser
/// Resolves the token <c>sub</c> to a user id; falls back to the seeded system
/// user (<see cref="Entities.User.SystemUserId"/>) while auth is deferred (§6).
/// </summary>
long AuditUserId { get; }
int AuditUserId { get; }
/// <summary>True when the request carries an authenticated principal.</summary>
bool IsAuthenticated { get; }
@@ -12,7 +12,7 @@ namespace ERPCore.Infra.Auth;
/// AuthHex tokens carry the user as a custom <c>UserId</c> (GUID) claim and no
/// <c>sub</c>/<c>nameid</c>. This transformation JIT-provisions a local shadow
/// <see cref="User"/> (keyed by <c>auth_user_id</c>) and injects the local
/// <c>long</c> id as <see cref="ClaimTypes.NameIdentifier"/>, so
/// <c>int</c> id as <see cref="ClaimTypes.NameIdentifier"/>, so
/// <see cref="ICurrentUser"/>/<c>AuditUserId</c> resolve the real user unchanged.
/// Idempotent — <see cref="IClaimsTransformation"/> may run several times per request.
/// </summary>
@@ -40,7 +40,7 @@ public sealed class ShadowUserClaimsTransformation : IClaimsTransformation
return principal;
}
private async Task<long> ResolveOrProvisionAsync(Guid authUserId, string? nic)
private async Task<int> ResolveOrProvisionAsync(Guid authUserId, string? nic)
{
var existing = await _db.Users.AsNoTracking()
.Where(u => u.AuthUserId == authUserId)
@@ -8,7 +8,7 @@ using Microsoft.EntityFrameworkCore.ChangeTracking;
namespace ERPCore.Infra.Persistence.Auditing;
/// <summary>A mutation captured before save, awaiting its (possibly generated) key.</summary>
public sealed record PendingAudit(EntityEntry Entry, string EntityType, AuditAction Action, string ChangeSet, long CapturedId, bool IsAdded);
public sealed record PendingAudit(EntityEntry Entry, string EntityType, AuditAction Action, string ChangeSet, int CapturedId, bool IsAdded);
/// <summary>
/// Builds audit-trail rows from the EF change tracker (FR-X-02). High-volume /
@@ -54,7 +54,7 @@ public static class AuditScribe
return pending;
}
public static AuditLog ToLog(PendingAudit p, long userId, DateTime now) => new()
public static AuditLog ToLog(PendingAudit p, int userId, DateTime now) => new()
{
UserId = userId,
EntityType = p.EntityType,
@@ -64,12 +64,12 @@ public static class AuditScribe
CreatedAt = now,
};
private static long ReadKey(EntityEntry entry)
private static int ReadKey(EntityEntry entry)
{
var pk = entry.Metadata.FindPrimaryKey();
if (pk is null || pk.Properties.Count != 1) return 0;
var value = entry.Property(pk.Properties[0].Name).CurrentValue;
return value is null ? 0 : Convert.ToInt64(value);
return value is null ? 0 : Convert.ToInt32(value);
}
private static string BuildChangeSet(EntityEntry entry, AuditAction action)
@@ -1,445 +0,0 @@
// <auto-generated />
using System;
using ERPCore.Infra.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace ERPCore.Infra.Persistence.Migrations
{
[DbContext(typeof(ErpDbContext))]
[Migration("20260709095653_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.9")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("ERPCore.Domain.Entities.Bin", b =>
{
b.Property<long>("BinId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("BinId"));
b.Property<string>("BinType")
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Code")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<long>("WarehouseId")
.HasColumnType("bigint");
b.HasKey("BinId");
b.HasIndex("WarehouseId", "Code")
.IsUnique();
b.ToTable("bins", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.Category", b =>
{
b.Property<long>("CategoryId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("CategoryId"));
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<long?>("ParentId")
.HasColumnType("bigint");
b.HasKey("CategoryId");
b.HasIndex("ParentId");
b.ToTable("categories", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.Item", b =>
{
b.Property<long>("ItemId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("ItemId"));
b.Property<long>("BaseUomId")
.HasColumnType("bigint");
b.Property<long>("CategoryId")
.HasColumnType("bigint");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<long?>("DefaultVendorId")
.HasColumnType("bigint");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("ItemType")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<uint>("RowVersion")
.IsConcurrencyToken()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("xid")
.HasColumnName("xmin");
b.Property<string>("Sku")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Status")
.IsRequired()
.ValueGeneratedOnAdd()
.HasMaxLength(20)
.HasColumnType("character varying(20)")
.HasDefaultValue("Active");
b.Property<string>("TaxClass")
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("TrackingMode")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("ItemId");
b.HasIndex("BaseUomId");
b.HasIndex("CategoryId");
b.HasIndex("DefaultVendorId");
b.HasIndex("Sku")
.IsUnique();
b.HasIndex("Status");
b.ToTable("items", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.ItemReorder", b =>
{
b.Property<long>("ReorderId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("ReorderId"));
b.Property<long>("ItemId")
.HasColumnType("bigint");
b.Property<decimal>("ReorderPoint")
.HasPrecision(18, 4)
.HasColumnType("numeric(18,4)");
b.Property<decimal>("ReorderQty")
.HasPrecision(18, 4)
.HasColumnType("numeric(18,4)");
b.Property<long>("WarehouseId")
.HasColumnType("bigint");
b.HasKey("ReorderId");
b.HasIndex("WarehouseId");
b.HasIndex("ItemId", "WarehouseId")
.IsUnique();
b.ToTable("item_reorders", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.Uom", b =>
{
b.Property<long>("UomId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("UomId"));
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("UomId");
b.HasIndex("Name")
.IsUnique();
b.ToTable("uoms", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.UomConversion", b =>
{
b.Property<long>("ConversionId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("ConversionId"));
b.Property<decimal>("Factor")
.HasPrecision(18, 6)
.HasColumnType("numeric(18,6)");
b.Property<long>("FromUomId")
.HasColumnType("bigint");
b.Property<long>("ItemId")
.HasColumnType("bigint");
b.Property<long>("ToUomId")
.HasColumnType("bigint");
b.HasKey("ConversionId");
b.HasIndex("FromUomId");
b.HasIndex("ToUomId");
b.HasIndex("ItemId", "FromUomId", "ToUomId")
.IsUnique();
b.ToTable("uom_conversions", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.Vendor", b =>
{
b.Property<long>("VendorId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("VendorId"));
b.Property<string>("Code")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Currency")
.IsRequired()
.ValueGeneratedOnAdd()
.HasMaxLength(3)
.HasColumnType("character varying(3)")
.HasDefaultValue("LKR");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<uint>("RowVersion")
.IsConcurrencyToken()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("xid")
.HasColumnName("xmin");
b.Property<string>("Status")
.IsRequired()
.ValueGeneratedOnAdd()
.HasMaxLength(20)
.HasColumnType("character varying(20)")
.HasDefaultValue("Active");
b.Property<string>("TaxReg")
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Terms")
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("VendorId");
b.HasIndex("Code")
.IsUnique();
b.HasIndex("Status");
b.ToTable("vendors", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.Warehouse", b =>
{
b.Property<long>("WarehouseId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("WarehouseId"));
b.Property<string>("Code")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.HasKey("WarehouseId");
b.HasIndex("Code")
.IsUnique();
b.ToTable("warehouses", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.Bin", b =>
{
b.HasOne("ERPCore.Domain.Entities.Warehouse", "Warehouse")
.WithMany("Bins")
.HasForeignKey("WarehouseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Warehouse");
});
modelBuilder.Entity("ERPCore.Domain.Entities.Category", b =>
{
b.HasOne("ERPCore.Domain.Entities.Category", "Parent")
.WithMany("Children")
.HasForeignKey("ParentId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Parent");
});
modelBuilder.Entity("ERPCore.Domain.Entities.Item", b =>
{
b.HasOne("ERPCore.Domain.Entities.Uom", "BaseUom")
.WithMany()
.HasForeignKey("BaseUomId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Category", "Category")
.WithMany()
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Vendor", "DefaultVendor")
.WithMany()
.HasForeignKey("DefaultVendorId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("BaseUom");
b.Navigation("Category");
b.Navigation("DefaultVendor");
});
modelBuilder.Entity("ERPCore.Domain.Entities.ItemReorder", b =>
{
b.HasOne("ERPCore.Domain.Entities.Item", "Item")
.WithMany("ReorderSettings")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Warehouse", "Warehouse")
.WithMany()
.HasForeignKey("WarehouseId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Item");
b.Navigation("Warehouse");
});
modelBuilder.Entity("ERPCore.Domain.Entities.UomConversion", b =>
{
b.HasOne("ERPCore.Domain.Entities.Uom", "FromUom")
.WithMany()
.HasForeignKey("FromUomId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Item", "Item")
.WithMany("UomConversions")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Uom", "ToUom")
.WithMany()
.HasForeignKey("ToUomId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("FromUom");
b.Navigation("Item");
b.Navigation("ToUom");
});
modelBuilder.Entity("ERPCore.Domain.Entities.Category", b =>
{
b.Navigation("Children");
});
modelBuilder.Entity("ERPCore.Domain.Entities.Item", b =>
{
b.Navigation("ReorderSettings");
b.Navigation("UomConversions");
});
modelBuilder.Entity("ERPCore.Domain.Entities.Warehouse", b =>
{
b.Navigation("Bins");
});
#pragma warning restore 612, 618
}
}
}
@@ -1,325 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace ERPCore.Infra.Persistence.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "categories",
columns: table => new
{
CategoryId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
ParentId = table.Column<long>(type: "bigint", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_categories", x => x.CategoryId);
table.ForeignKey(
name: "FK_categories_categories_ParentId",
column: x => x.ParentId,
principalTable: "categories",
principalColumn: "CategoryId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "uoms",
columns: table => new
{
UomId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_uoms", x => x.UomId);
});
migrationBuilder.CreateTable(
name: "vendors",
columns: table => new
{
VendorId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Code = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
Name = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
Terms = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
TaxReg = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
Currency = table.Column<string>(type: "character varying(3)", maxLength: 3, nullable: false, defaultValue: "LKR"),
Status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
xmin = table.Column<uint>(type: "xid", rowVersion: true, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_vendors", x => x.VendorId);
});
migrationBuilder.CreateTable(
name: "warehouses",
columns: table => new
{
WarehouseId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Code = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
Name = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_warehouses", x => x.WarehouseId);
});
migrationBuilder.CreateTable(
name: "items",
columns: table => new
{
ItemId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Sku = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
Name = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
Description = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: true),
CategoryId = table.Column<long>(type: "bigint", nullable: false),
BaseUomId = table.Column<long>(type: "bigint", nullable: false),
DefaultVendorId = table.Column<long>(type: "bigint", nullable: true),
ItemType = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
TrackingMode = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
TaxClass = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: true),
Status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false, defaultValue: "Active"),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
xmin = table.Column<uint>(type: "xid", rowVersion: true, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_items", x => x.ItemId);
table.ForeignKey(
name: "FK_items_categories_CategoryId",
column: x => x.CategoryId,
principalTable: "categories",
principalColumn: "CategoryId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_items_uoms_BaseUomId",
column: x => x.BaseUomId,
principalTable: "uoms",
principalColumn: "UomId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_items_vendors_DefaultVendorId",
column: x => x.DefaultVendorId,
principalTable: "vendors",
principalColumn: "VendorId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "bins",
columns: table => new
{
BinId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
WarehouseId = table.Column<long>(type: "bigint", nullable: false),
Code = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
BinType = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_bins", x => x.BinId);
table.ForeignKey(
name: "FK_bins_warehouses_WarehouseId",
column: x => x.WarehouseId,
principalTable: "warehouses",
principalColumn: "WarehouseId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "item_reorders",
columns: table => new
{
ReorderId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ItemId = table.Column<long>(type: "bigint", nullable: false),
WarehouseId = table.Column<long>(type: "bigint", nullable: false),
ReorderPoint = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false),
ReorderQty = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_item_reorders", x => x.ReorderId);
table.ForeignKey(
name: "FK_item_reorders_items_ItemId",
column: x => x.ItemId,
principalTable: "items",
principalColumn: "ItemId",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_item_reorders_warehouses_WarehouseId",
column: x => x.WarehouseId,
principalTable: "warehouses",
principalColumn: "WarehouseId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "uom_conversions",
columns: table => new
{
ConversionId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ItemId = table.Column<long>(type: "bigint", nullable: false),
FromUomId = table.Column<long>(type: "bigint", nullable: false),
ToUomId = table.Column<long>(type: "bigint", nullable: false),
Factor = table.Column<decimal>(type: "numeric(18,6)", precision: 18, scale: 6, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_uom_conversions", x => x.ConversionId);
table.ForeignKey(
name: "FK_uom_conversions_items_ItemId",
column: x => x.ItemId,
principalTable: "items",
principalColumn: "ItemId",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_uom_conversions_uoms_FromUomId",
column: x => x.FromUomId,
principalTable: "uoms",
principalColumn: "UomId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_uom_conversions_uoms_ToUomId",
column: x => x.ToUomId,
principalTable: "uoms",
principalColumn: "UomId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_bins_WarehouseId_Code",
table: "bins",
columns: new[] { "WarehouseId", "Code" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_categories_ParentId",
table: "categories",
column: "ParentId");
migrationBuilder.CreateIndex(
name: "IX_item_reorders_ItemId_WarehouseId",
table: "item_reorders",
columns: new[] { "ItemId", "WarehouseId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_item_reorders_WarehouseId",
table: "item_reorders",
column: "WarehouseId");
migrationBuilder.CreateIndex(
name: "IX_items_BaseUomId",
table: "items",
column: "BaseUomId");
migrationBuilder.CreateIndex(
name: "IX_items_CategoryId",
table: "items",
column: "CategoryId");
migrationBuilder.CreateIndex(
name: "IX_items_DefaultVendorId",
table: "items",
column: "DefaultVendorId");
migrationBuilder.CreateIndex(
name: "IX_items_Sku",
table: "items",
column: "Sku",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_items_Status",
table: "items",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_uom_conversions_FromUomId",
table: "uom_conversions",
column: "FromUomId");
migrationBuilder.CreateIndex(
name: "IX_uom_conversions_ItemId_FromUomId_ToUomId",
table: "uom_conversions",
columns: new[] { "ItemId", "FromUomId", "ToUomId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_uom_conversions_ToUomId",
table: "uom_conversions",
column: "ToUomId");
migrationBuilder.CreateIndex(
name: "IX_uoms_Name",
table: "uoms",
column: "Name",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_vendors_Code",
table: "vendors",
column: "Code",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_vendors_Status",
table: "vendors",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_warehouses_Code",
table: "warehouses",
column: "Code",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "bins");
migrationBuilder.DropTable(
name: "item_reorders");
migrationBuilder.DropTable(
name: "uom_conversions");
migrationBuilder.DropTable(
name: "warehouses");
migrationBuilder.DropTable(
name: "items");
migrationBuilder.DropTable(
name: "categories");
migrationBuilder.DropTable(
name: "uoms");
migrationBuilder.DropTable(
name: "vendors");
}
}
}
@@ -1,445 +0,0 @@
// <auto-generated />
using System;
using ERPCore.Infra.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace ERPCore.Infra.Persistence.Migrations
{
[DbContext(typeof(ErpDbContext))]
[Migration("20260709124415_initial")]
partial class initial
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.9")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("ERPCore.Domain.Entities.Bin", b =>
{
b.Property<long>("BinId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("BinId"));
b.Property<string>("BinType")
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Code")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<long>("WarehouseId")
.HasColumnType("bigint");
b.HasKey("BinId");
b.HasIndex("WarehouseId", "Code")
.IsUnique();
b.ToTable("bins", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.Category", b =>
{
b.Property<long>("CategoryId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("CategoryId"));
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<long?>("ParentId")
.HasColumnType("bigint");
b.HasKey("CategoryId");
b.HasIndex("ParentId");
b.ToTable("categories", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.Item", b =>
{
b.Property<long>("ItemId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("ItemId"));
b.Property<long>("BaseUomId")
.HasColumnType("bigint");
b.Property<long>("CategoryId")
.HasColumnType("bigint");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<long?>("DefaultVendorId")
.HasColumnType("bigint");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("ItemType")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<uint>("RowVersion")
.IsConcurrencyToken()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("xid")
.HasColumnName("xmin");
b.Property<string>("Sku")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Status")
.IsRequired()
.ValueGeneratedOnAdd()
.HasMaxLength(20)
.HasColumnType("character varying(20)")
.HasDefaultValue("Active");
b.Property<string>("TaxClass")
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("TrackingMode")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("ItemId");
b.HasIndex("BaseUomId");
b.HasIndex("CategoryId");
b.HasIndex("DefaultVendorId");
b.HasIndex("Sku")
.IsUnique();
b.HasIndex("Status");
b.ToTable("items", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.ItemReorder", b =>
{
b.Property<long>("ReorderId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("ReorderId"));
b.Property<long>("ItemId")
.HasColumnType("bigint");
b.Property<decimal>("ReorderPoint")
.HasPrecision(18, 4)
.HasColumnType("numeric(18,4)");
b.Property<decimal>("ReorderQty")
.HasPrecision(18, 4)
.HasColumnType("numeric(18,4)");
b.Property<long>("WarehouseId")
.HasColumnType("bigint");
b.HasKey("ReorderId");
b.HasIndex("WarehouseId");
b.HasIndex("ItemId", "WarehouseId")
.IsUnique();
b.ToTable("item_reorders", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.Uom", b =>
{
b.Property<long>("UomId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("UomId"));
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("UomId");
b.HasIndex("Name")
.IsUnique();
b.ToTable("uoms", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.UomConversion", b =>
{
b.Property<long>("ConversionId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("ConversionId"));
b.Property<decimal>("Factor")
.HasPrecision(18, 6)
.HasColumnType("numeric(18,6)");
b.Property<long>("FromUomId")
.HasColumnType("bigint");
b.Property<long>("ItemId")
.HasColumnType("bigint");
b.Property<long>("ToUomId")
.HasColumnType("bigint");
b.HasKey("ConversionId");
b.HasIndex("FromUomId");
b.HasIndex("ToUomId");
b.HasIndex("ItemId", "FromUomId", "ToUomId")
.IsUnique();
b.ToTable("uom_conversions", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.Vendor", b =>
{
b.Property<long>("VendorId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("VendorId"));
b.Property<string>("Code")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Currency")
.IsRequired()
.ValueGeneratedOnAdd()
.HasMaxLength(3)
.HasColumnType("character varying(3)")
.HasDefaultValue("LKR");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<uint>("RowVersion")
.IsConcurrencyToken()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("xid")
.HasColumnName("xmin");
b.Property<string>("Status")
.IsRequired()
.ValueGeneratedOnAdd()
.HasMaxLength(20)
.HasColumnType("character varying(20)")
.HasDefaultValue("Active");
b.Property<string>("TaxReg")
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Terms")
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("VendorId");
b.HasIndex("Code")
.IsUnique();
b.HasIndex("Status");
b.ToTable("vendors", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.Warehouse", b =>
{
b.Property<long>("WarehouseId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("WarehouseId"));
b.Property<string>("Code")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.HasKey("WarehouseId");
b.HasIndex("Code")
.IsUnique();
b.ToTable("warehouses", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.Bin", b =>
{
b.HasOne("ERPCore.Domain.Entities.Warehouse", "Warehouse")
.WithMany("Bins")
.HasForeignKey("WarehouseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Warehouse");
});
modelBuilder.Entity("ERPCore.Domain.Entities.Category", b =>
{
b.HasOne("ERPCore.Domain.Entities.Category", "Parent")
.WithMany("Children")
.HasForeignKey("ParentId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Parent");
});
modelBuilder.Entity("ERPCore.Domain.Entities.Item", b =>
{
b.HasOne("ERPCore.Domain.Entities.Uom", "BaseUom")
.WithMany()
.HasForeignKey("BaseUomId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Category", "Category")
.WithMany()
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Vendor", "DefaultVendor")
.WithMany()
.HasForeignKey("DefaultVendorId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("BaseUom");
b.Navigation("Category");
b.Navigation("DefaultVendor");
});
modelBuilder.Entity("ERPCore.Domain.Entities.ItemReorder", b =>
{
b.HasOne("ERPCore.Domain.Entities.Item", "Item")
.WithMany("ReorderSettings")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Warehouse", "Warehouse")
.WithMany()
.HasForeignKey("WarehouseId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Item");
b.Navigation("Warehouse");
});
modelBuilder.Entity("ERPCore.Domain.Entities.UomConversion", b =>
{
b.HasOne("ERPCore.Domain.Entities.Uom", "FromUom")
.WithMany()
.HasForeignKey("FromUomId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Item", "Item")
.WithMany("UomConversions")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Uom", "ToUom")
.WithMany()
.HasForeignKey("ToUomId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("FromUom");
b.Navigation("Item");
b.Navigation("ToUom");
});
modelBuilder.Entity("ERPCore.Domain.Entities.Category", b =>
{
b.Navigation("Children");
});
modelBuilder.Entity("ERPCore.Domain.Entities.Item", b =>
{
b.Navigation("ReorderSettings");
b.Navigation("UomConversions");
});
modelBuilder.Entity("ERPCore.Domain.Entities.Warehouse", b =>
{
b.Navigation("Bins");
});
#pragma warning restore 612, 618
}
}
}
@@ -1,22 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ERPCore.Infra.Persistence.Migrations
{
/// <inheritdoc />
public partial class initial : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}
@@ -1,987 +0,0 @@
// <auto-generated />
using System;
using ERPCore.Infra.Persistence;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace ERPCore.Infra.Persistence.Migrations
{
[DbContext(typeof(ErpDbContext))]
[Migration("20260710090753_AddProcurement")]
partial class AddProcurement
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "10.0.9")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("ERPCore.Domain.Entities.Bin", b =>
{
b.Property<long>("BinId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("BinId"));
b.Property<string>("BinType")
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Code")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<long>("WarehouseId")
.HasColumnType("bigint");
b.HasKey("BinId");
b.HasIndex("WarehouseId", "Code")
.IsUnique();
b.ToTable("bins", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.Category", b =>
{
b.Property<long>("CategoryId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("CategoryId"));
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<long?>("ParentId")
.HasColumnType("bigint");
b.HasKey("CategoryId");
b.HasIndex("ParentId");
b.ToTable("categories", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.Item", b =>
{
b.Property<long>("ItemId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("ItemId"));
b.Property<long>("BaseUomId")
.HasColumnType("bigint");
b.Property<long>("CategoryId")
.HasColumnType("bigint");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<long?>("DefaultVendorId")
.HasColumnType("bigint");
b.Property<string>("Description")
.HasMaxLength(1000)
.HasColumnType("character varying(1000)");
b.Property<string>("ItemType")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<uint>("RowVersion")
.IsConcurrencyToken()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("xid")
.HasColumnName("xmin");
b.Property<string>("Sku")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Status")
.IsRequired()
.ValueGeneratedOnAdd()
.HasMaxLength(20)
.HasColumnType("character varying(20)")
.HasDefaultValue("Active");
b.Property<string>("TaxClass")
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("TrackingMode")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("ItemId");
b.HasIndex("BaseUomId");
b.HasIndex("CategoryId");
b.HasIndex("DefaultVendorId");
b.HasIndex("Sku")
.IsUnique();
b.HasIndex("Status");
b.ToTable("items", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.ItemReorder", b =>
{
b.Property<long>("ReorderId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("ReorderId"));
b.Property<long>("ItemId")
.HasColumnType("bigint");
b.Property<decimal>("ReorderPoint")
.HasPrecision(18, 4)
.HasColumnType("numeric(18,4)");
b.Property<decimal>("ReorderQty")
.HasPrecision(18, 4)
.HasColumnType("numeric(18,4)");
b.Property<long>("WarehouseId")
.HasColumnType("bigint");
b.HasKey("ReorderId");
b.HasIndex("WarehouseId");
b.HasIndex("ItemId", "WarehouseId")
.IsUnique();
b.ToTable("item_reorders", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.NumberSequence", b =>
{
b.Property<long>("SequenceId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("SequenceId"));
b.Property<string>("DocType")
.IsRequired()
.HasMaxLength(10)
.HasColumnType("character varying(10)")
.HasColumnName("doc_type");
b.Property<long>("LastNumber")
.HasColumnType("bigint")
.HasColumnName("last_number");
b.Property<int>("Year")
.HasColumnType("integer")
.HasColumnName("year");
b.HasKey("SequenceId");
b.HasIndex("DocType", "Year")
.IsUnique();
b.ToTable("number_sequences", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.PoLine", b =>
{
b.Property<long>("PoLineId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("PoLineId"));
b.Property<long>("ItemId")
.HasColumnType("bigint");
b.Property<long>("PoId")
.HasColumnType("bigint");
b.Property<decimal>("Qty")
.HasPrecision(18, 4)
.HasColumnType("numeric(18,4)");
b.Property<decimal>("QtyReceived")
.HasPrecision(18, 4)
.HasColumnType("numeric(18,4)");
b.Property<decimal>("Tax")
.HasPrecision(9, 4)
.HasColumnType("numeric(9,4)");
b.Property<decimal>("UnitPrice")
.HasPrecision(18, 4)
.HasColumnType("numeric(18,4)");
b.Property<long>("UomId")
.HasColumnType("bigint");
b.Property<long>("WarehouseId")
.HasColumnType("bigint");
b.HasKey("PoLineId");
b.HasIndex("ItemId");
b.HasIndex("PoId");
b.HasIndex("UomId");
b.HasIndex("WarehouseId");
b.ToTable("po_lines", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.PurchaseOrder", b =>
{
b.Property<long>("PoId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("PoId"));
b.Property<bool>("ApprovalRequired")
.HasColumnType("boolean");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<long>("CreatedBy")
.HasColumnType("bigint");
b.Property<string>("DocNo")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<long?>("RequisitionId")
.HasColumnType("bigint");
b.Property<uint>("RowVersion")
.IsConcurrencyToken()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("xid")
.HasColumnName("xmin");
b.Property<string>("Status")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<long>("VendorId")
.HasColumnType("bigint");
b.HasKey("PoId");
b.HasIndex("CreatedBy");
b.HasIndex("DocNo")
.IsUnique();
b.HasIndex("RequisitionId");
b.HasIndex("Status");
b.HasIndex("VendorId");
b.ToTable("purchase_orders", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.Requisition", b =>
{
b.Property<long>("RequisitionId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("RequisitionId"));
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DocNo")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<long>("RequestedBy")
.HasColumnType("bigint");
b.Property<string>("Status")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.HasKey("RequisitionId");
b.HasIndex("DocNo")
.IsUnique();
b.HasIndex("RequestedBy");
b.HasIndex("Status");
b.ToTable("requisitions", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.RequisitionLine", b =>
{
b.Property<long>("ReqLineId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("ReqLineId"));
b.Property<long>("ItemId")
.HasColumnType("bigint");
b.Property<decimal>("Qty")
.HasPrecision(18, 4)
.HasColumnType("numeric(18,4)");
b.Property<DateOnly?>("RequiredBy")
.HasColumnType("date");
b.Property<long>("RequisitionId")
.HasColumnType("bigint");
b.HasKey("ReqLineId");
b.HasIndex("ItemId");
b.HasIndex("RequisitionId");
b.ToTable("requisition_lines", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.Rfq", b =>
{
b.Property<long>("RfqId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("RfqId"));
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("DocNo")
.IsRequired()
.HasMaxLength(30)
.HasColumnType("character varying(30)");
b.Property<long>("RequisitionId")
.HasColumnType("bigint");
b.Property<string>("Status")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.HasKey("RfqId");
b.HasIndex("DocNo")
.IsUnique();
b.HasIndex("RequisitionId");
b.ToTable("rfqs", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.RfqLine", b =>
{
b.Property<long>("RfqLineId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("RfqLineId"));
b.Property<long>("ItemId")
.HasColumnType("bigint");
b.Property<decimal>("Qty")
.HasPrecision(18, 4)
.HasColumnType("numeric(18,4)");
b.Property<long>("RfqId")
.HasColumnType("bigint");
b.HasKey("RfqLineId");
b.HasIndex("ItemId");
b.HasIndex("RfqId");
b.ToTable("rfq_lines", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.Uom", b =>
{
b.Property<long>("UomId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("UomId"));
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.HasKey("UomId");
b.HasIndex("Name")
.IsUnique();
b.ToTable("uoms", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.UomConversion", b =>
{
b.Property<long>("ConversionId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("ConversionId"));
b.Property<decimal>("Factor")
.HasPrecision(18, 6)
.HasColumnType("numeric(18,6)");
b.Property<long>("FromUomId")
.HasColumnType("bigint");
b.Property<long>("ItemId")
.HasColumnType("bigint");
b.Property<long>("ToUomId")
.HasColumnType("bigint");
b.HasKey("ConversionId");
b.HasIndex("FromUomId");
b.HasIndex("ToUomId");
b.HasIndex("ItemId", "FromUomId", "ToUomId")
.IsUnique();
b.ToTable("uom_conversions", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.User", b =>
{
b.Property<long>("UserId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("UserId"));
b.Property<string>("DisplayName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<string>("Status")
.IsRequired()
.HasMaxLength(20)
.HasColumnType("character varying(20)");
b.Property<string>("Username")
.IsRequired()
.HasMaxLength(100)
.HasColumnType("character varying(100)");
b.HasKey("UserId");
b.HasIndex("Username")
.IsUnique();
b.ToTable("users", (string)null);
b.HasData(
new
{
UserId = 1L,
DisplayName = "System",
Status = "Active",
Username = "system"
});
});
modelBuilder.Entity("ERPCore.Domain.Entities.Vendor", b =>
{
b.Property<long>("VendorId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("VendorId"));
b.Property<string>("Code")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Currency")
.IsRequired()
.ValueGeneratedOnAdd()
.HasMaxLength(3)
.HasColumnType("character varying(3)")
.HasDefaultValue("LKR");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.Property<uint>("RowVersion")
.IsConcurrencyToken()
.ValueGeneratedOnAddOrUpdate()
.HasColumnType("xid")
.HasColumnName("xmin");
b.Property<string>("Status")
.IsRequired()
.ValueGeneratedOnAdd()
.HasMaxLength(20)
.HasColumnType("character varying(20)")
.HasDefaultValue("Active");
b.Property<string>("TaxReg")
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Terms")
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<DateTime?>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("VendorId");
b.HasIndex("Code")
.IsUnique();
b.HasIndex("Status");
b.ToTable("vendors", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.VendorQuotation", b =>
{
b.Property<long>("QuotationId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("QuotationId"));
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<long>("RfqId")
.HasColumnType("bigint");
b.Property<long>("VendorId")
.HasColumnType("bigint");
b.HasKey("QuotationId");
b.HasIndex("VendorId");
b.HasIndex("RfqId", "VendorId")
.IsUnique();
b.ToTable("vendor_quotations", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.VendorQuotationLine", b =>
{
b.Property<long>("QuotationLineId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("QuotationLineId"));
b.Property<long>("ItemId")
.HasColumnType("bigint");
b.Property<int>("LeadDays")
.HasColumnType("integer");
b.Property<long>("QuotationId")
.HasColumnType("bigint");
b.Property<decimal>("UnitPrice")
.HasPrecision(18, 4)
.HasColumnType("numeric(18,4)");
b.HasKey("QuotationLineId");
b.HasIndex("ItemId");
b.HasIndex("QuotationId");
b.ToTable("vendor_quotation_lines", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.Warehouse", b =>
{
b.Property<long>("WarehouseId")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<long>("WarehouseId"));
b.Property<string>("Code")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("character varying(50)");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("character varying(200)");
b.HasKey("WarehouseId");
b.HasIndex("Code")
.IsUnique();
b.ToTable("warehouses", (string)null);
});
modelBuilder.Entity("ERPCore.Domain.Entities.Bin", b =>
{
b.HasOne("ERPCore.Domain.Entities.Warehouse", "Warehouse")
.WithMany("Bins")
.HasForeignKey("WarehouseId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Warehouse");
});
modelBuilder.Entity("ERPCore.Domain.Entities.Category", b =>
{
b.HasOne("ERPCore.Domain.Entities.Category", "Parent")
.WithMany("Children")
.HasForeignKey("ParentId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("Parent");
});
modelBuilder.Entity("ERPCore.Domain.Entities.Item", b =>
{
b.HasOne("ERPCore.Domain.Entities.Uom", "BaseUom")
.WithMany()
.HasForeignKey("BaseUomId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Category", "Category")
.WithMany()
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Vendor", "DefaultVendor")
.WithMany()
.HasForeignKey("DefaultVendorId")
.OnDelete(DeleteBehavior.Restrict);
b.Navigation("BaseUom");
b.Navigation("Category");
b.Navigation("DefaultVendor");
});
modelBuilder.Entity("ERPCore.Domain.Entities.ItemReorder", b =>
{
b.HasOne("ERPCore.Domain.Entities.Item", "Item")
.WithMany("ReorderSettings")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Warehouse", "Warehouse")
.WithMany()
.HasForeignKey("WarehouseId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Item");
b.Navigation("Warehouse");
});
modelBuilder.Entity("ERPCore.Domain.Entities.PoLine", b =>
{
b.HasOne("ERPCore.Domain.Entities.Item", "Item")
.WithMany()
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.PurchaseOrder", "PurchaseOrder")
.WithMany("Lines")
.HasForeignKey("PoId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Uom", "Uom")
.WithMany()
.HasForeignKey("UomId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Warehouse", "Warehouse")
.WithMany()
.HasForeignKey("WarehouseId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Item");
b.Navigation("PurchaseOrder");
b.Navigation("Uom");
b.Navigation("Warehouse");
});
modelBuilder.Entity("ERPCore.Domain.Entities.PurchaseOrder", b =>
{
b.HasOne("ERPCore.Domain.Entities.User", "Creator")
.WithMany()
.HasForeignKey("CreatedBy")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Requisition", "Requisition")
.WithMany()
.HasForeignKey("RequisitionId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("ERPCore.Domain.Entities.Vendor", "Vendor")
.WithMany()
.HasForeignKey("VendorId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Creator");
b.Navigation("Requisition");
b.Navigation("Vendor");
});
modelBuilder.Entity("ERPCore.Domain.Entities.Requisition", b =>
{
b.HasOne("ERPCore.Domain.Entities.User", "Requester")
.WithMany()
.HasForeignKey("RequestedBy")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Requester");
});
modelBuilder.Entity("ERPCore.Domain.Entities.RequisitionLine", b =>
{
b.HasOne("ERPCore.Domain.Entities.Item", "Item")
.WithMany()
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Requisition", "Requisition")
.WithMany("Lines")
.HasForeignKey("RequisitionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Item");
b.Navigation("Requisition");
});
modelBuilder.Entity("ERPCore.Domain.Entities.Rfq", b =>
{
b.HasOne("ERPCore.Domain.Entities.Requisition", "Requisition")
.WithMany()
.HasForeignKey("RequisitionId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Requisition");
});
modelBuilder.Entity("ERPCore.Domain.Entities.RfqLine", b =>
{
b.HasOne("ERPCore.Domain.Entities.Item", "Item")
.WithMany()
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Rfq", "Rfq")
.WithMany("Lines")
.HasForeignKey("RfqId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Item");
b.Navigation("Rfq");
});
modelBuilder.Entity("ERPCore.Domain.Entities.UomConversion", b =>
{
b.HasOne("ERPCore.Domain.Entities.Uom", "FromUom")
.WithMany()
.HasForeignKey("FromUomId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Item", "Item")
.WithMany("UomConversions")
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Uom", "ToUom")
.WithMany()
.HasForeignKey("ToUomId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("FromUom");
b.Navigation("Item");
b.Navigation("ToUom");
});
modelBuilder.Entity("ERPCore.Domain.Entities.VendorQuotation", b =>
{
b.HasOne("ERPCore.Domain.Entities.Rfq", "Rfq")
.WithMany("Quotations")
.HasForeignKey("RfqId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.Vendor", "Vendor")
.WithMany()
.HasForeignKey("VendorId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Rfq");
b.Navigation("Vendor");
});
modelBuilder.Entity("ERPCore.Domain.Entities.VendorQuotationLine", b =>
{
b.HasOne("ERPCore.Domain.Entities.Item", "Item")
.WithMany()
.HasForeignKey("ItemId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("ERPCore.Domain.Entities.VendorQuotation", "Quotation")
.WithMany("Lines")
.HasForeignKey("QuotationId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Item");
b.Navigation("Quotation");
});
modelBuilder.Entity("ERPCore.Domain.Entities.Category", b =>
{
b.Navigation("Children");
});
modelBuilder.Entity("ERPCore.Domain.Entities.Item", b =>
{
b.Navigation("ReorderSettings");
b.Navigation("UomConversions");
});
modelBuilder.Entity("ERPCore.Domain.Entities.PurchaseOrder", b =>
{
b.Navigation("Lines");
});
modelBuilder.Entity("ERPCore.Domain.Entities.Requisition", b =>
{
b.Navigation("Lines");
});
modelBuilder.Entity("ERPCore.Domain.Entities.Rfq", b =>
{
b.Navigation("Lines");
b.Navigation("Quotations");
});
modelBuilder.Entity("ERPCore.Domain.Entities.VendorQuotation", b =>
{
b.Navigation("Lines");
});
modelBuilder.Entity("ERPCore.Domain.Entities.Warehouse", b =>
{
b.Navigation("Bins");
});
#pragma warning restore 612, 618
}
}
}
@@ -1,448 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace ERPCore.Infra.Persistence.Migrations
{
/// <inheritdoc />
public partial class AddProcurement : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "number_sequences",
columns: table => new
{
SequenceId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
doc_type = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false),
year = table.Column<int>(type: "integer", nullable: false),
last_number = table.Column<long>(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_number_sequences", x => x.SequenceId);
});
migrationBuilder.CreateTable(
name: "users",
columns: table => new
{
UserId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Username = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
DisplayName = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
Status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_users", x => x.UserId);
});
migrationBuilder.CreateTable(
name: "requisitions",
columns: table => new
{
RequisitionId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
DocNo = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
RequestedBy = table.Column<long>(type: "bigint", nullable: false),
Status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_requisitions", x => x.RequisitionId);
table.ForeignKey(
name: "FK_requisitions_users_RequestedBy",
column: x => x.RequestedBy,
principalTable: "users",
principalColumn: "UserId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "purchase_orders",
columns: table => new
{
PoId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
DocNo = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
VendorId = table.Column<long>(type: "bigint", nullable: false),
RequisitionId = table.Column<long>(type: "bigint", nullable: true),
Status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
ApprovalRequired = table.Column<bool>(type: "boolean", nullable: false),
CreatedBy = table.Column<long>(type: "bigint", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
xmin = table.Column<uint>(type: "xid", rowVersion: true, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_purchase_orders", x => x.PoId);
table.ForeignKey(
name: "FK_purchase_orders_requisitions_RequisitionId",
column: x => x.RequisitionId,
principalTable: "requisitions",
principalColumn: "RequisitionId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_purchase_orders_users_CreatedBy",
column: x => x.CreatedBy,
principalTable: "users",
principalColumn: "UserId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_purchase_orders_vendors_VendorId",
column: x => x.VendorId,
principalTable: "vendors",
principalColumn: "VendorId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "requisition_lines",
columns: table => new
{
ReqLineId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
RequisitionId = table.Column<long>(type: "bigint", nullable: false),
ItemId = table.Column<long>(type: "bigint", nullable: false),
Qty = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false),
RequiredBy = table.Column<DateOnly>(type: "date", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_requisition_lines", x => x.ReqLineId);
table.ForeignKey(
name: "FK_requisition_lines_items_ItemId",
column: x => x.ItemId,
principalTable: "items",
principalColumn: "ItemId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_requisition_lines_requisitions_RequisitionId",
column: x => x.RequisitionId,
principalTable: "requisitions",
principalColumn: "RequisitionId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "rfqs",
columns: table => new
{
RfqId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
DocNo = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
RequisitionId = table.Column<long>(type: "bigint", nullable: false),
Status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_rfqs", x => x.RfqId);
table.ForeignKey(
name: "FK_rfqs_requisitions_RequisitionId",
column: x => x.RequisitionId,
principalTable: "requisitions",
principalColumn: "RequisitionId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "po_lines",
columns: table => new
{
PoLineId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
PoId = table.Column<long>(type: "bigint", nullable: false),
ItemId = table.Column<long>(type: "bigint", nullable: false),
UomId = table.Column<long>(type: "bigint", nullable: false),
WarehouseId = table.Column<long>(type: "bigint", nullable: false),
Qty = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false),
UnitPrice = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false),
Tax = table.Column<decimal>(type: "numeric(9,4)", precision: 9, scale: 4, nullable: false),
QtyReceived = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_po_lines", x => x.PoLineId);
table.ForeignKey(
name: "FK_po_lines_items_ItemId",
column: x => x.ItemId,
principalTable: "items",
principalColumn: "ItemId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_po_lines_purchase_orders_PoId",
column: x => x.PoId,
principalTable: "purchase_orders",
principalColumn: "PoId",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_po_lines_uoms_UomId",
column: x => x.UomId,
principalTable: "uoms",
principalColumn: "UomId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_po_lines_warehouses_WarehouseId",
column: x => x.WarehouseId,
principalTable: "warehouses",
principalColumn: "WarehouseId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "rfq_lines",
columns: table => new
{
RfqLineId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
RfqId = table.Column<long>(type: "bigint", nullable: false),
ItemId = table.Column<long>(type: "bigint", nullable: false),
Qty = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_rfq_lines", x => x.RfqLineId);
table.ForeignKey(
name: "FK_rfq_lines_items_ItemId",
column: x => x.ItemId,
principalTable: "items",
principalColumn: "ItemId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_rfq_lines_rfqs_RfqId",
column: x => x.RfqId,
principalTable: "rfqs",
principalColumn: "RfqId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "vendor_quotations",
columns: table => new
{
QuotationId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
RfqId = table.Column<long>(type: "bigint", nullable: false),
VendorId = table.Column<long>(type: "bigint", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_vendor_quotations", x => x.QuotationId);
table.ForeignKey(
name: "FK_vendor_quotations_rfqs_RfqId",
column: x => x.RfqId,
principalTable: "rfqs",
principalColumn: "RfqId",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_vendor_quotations_vendors_VendorId",
column: x => x.VendorId,
principalTable: "vendors",
principalColumn: "VendorId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "vendor_quotation_lines",
columns: table => new
{
QuotationLineId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
QuotationId = table.Column<long>(type: "bigint", nullable: false),
ItemId = table.Column<long>(type: "bigint", nullable: false),
UnitPrice = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false),
LeadDays = table.Column<int>(type: "integer", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_vendor_quotation_lines", x => x.QuotationLineId);
table.ForeignKey(
name: "FK_vendor_quotation_lines_items_ItemId",
column: x => x.ItemId,
principalTable: "items",
principalColumn: "ItemId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_vendor_quotation_lines_vendor_quotations_QuotationId",
column: x => x.QuotationId,
principalTable: "vendor_quotations",
principalColumn: "QuotationId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
table: "users",
columns: new[] { "UserId", "DisplayName", "Status", "Username" },
values: new object[] { 1L, "System", "Active", "system" });
migrationBuilder.CreateIndex(
name: "IX_number_sequences_doc_type_year",
table: "number_sequences",
columns: new[] { "doc_type", "year" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_po_lines_ItemId",
table: "po_lines",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_po_lines_PoId",
table: "po_lines",
column: "PoId");
migrationBuilder.CreateIndex(
name: "IX_po_lines_UomId",
table: "po_lines",
column: "UomId");
migrationBuilder.CreateIndex(
name: "IX_po_lines_WarehouseId",
table: "po_lines",
column: "WarehouseId");
migrationBuilder.CreateIndex(
name: "IX_purchase_orders_CreatedBy",
table: "purchase_orders",
column: "CreatedBy");
migrationBuilder.CreateIndex(
name: "IX_purchase_orders_DocNo",
table: "purchase_orders",
column: "DocNo",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_purchase_orders_RequisitionId",
table: "purchase_orders",
column: "RequisitionId");
migrationBuilder.CreateIndex(
name: "IX_purchase_orders_Status",
table: "purchase_orders",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_purchase_orders_VendorId",
table: "purchase_orders",
column: "VendorId");
migrationBuilder.CreateIndex(
name: "IX_requisition_lines_ItemId",
table: "requisition_lines",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_requisition_lines_RequisitionId",
table: "requisition_lines",
column: "RequisitionId");
migrationBuilder.CreateIndex(
name: "IX_requisitions_DocNo",
table: "requisitions",
column: "DocNo",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_requisitions_RequestedBy",
table: "requisitions",
column: "RequestedBy");
migrationBuilder.CreateIndex(
name: "IX_requisitions_Status",
table: "requisitions",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_rfq_lines_ItemId",
table: "rfq_lines",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_rfq_lines_RfqId",
table: "rfq_lines",
column: "RfqId");
migrationBuilder.CreateIndex(
name: "IX_rfqs_DocNo",
table: "rfqs",
column: "DocNo",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_rfqs_RequisitionId",
table: "rfqs",
column: "RequisitionId");
migrationBuilder.CreateIndex(
name: "IX_users_Username",
table: "users",
column: "Username",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_vendor_quotation_lines_ItemId",
table: "vendor_quotation_lines",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_vendor_quotation_lines_QuotationId",
table: "vendor_quotation_lines",
column: "QuotationId");
migrationBuilder.CreateIndex(
name: "IX_vendor_quotations_RfqId_VendorId",
table: "vendor_quotations",
columns: new[] { "RfqId", "VendorId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_vendor_quotations_VendorId",
table: "vendor_quotations",
column: "VendorId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "number_sequences");
migrationBuilder.DropTable(
name: "po_lines");
migrationBuilder.DropTable(
name: "requisition_lines");
migrationBuilder.DropTable(
name: "rfq_lines");
migrationBuilder.DropTable(
name: "vendor_quotation_lines");
migrationBuilder.DropTable(
name: "purchase_orders");
migrationBuilder.DropTable(
name: "vendor_quotations");
migrationBuilder.DropTable(
name: "rfqs");
migrationBuilder.DropTable(
name: "requisitions");
migrationBuilder.DropTable(
name: "users");
}
}
}
File diff suppressed because it is too large Load Diff
@@ -1,434 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace ERPCore.Infra.Persistence.Migrations
{
/// <inheritdoc />
public partial class AddStockAndGrn : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "batches",
columns: table => new
{
BatchId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ItemId = table.Column<long>(type: "bigint", nullable: false),
BatchNo = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
ExpiryDate = table.Column<DateOnly>(type: "date", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_batches", x => x.BatchId);
table.ForeignKey(
name: "FK_batches_items_ItemId",
column: x => x.ItemId,
principalTable: "items",
principalColumn: "ItemId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "grns",
columns: table => new
{
GrnId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
DocNo = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
PoId = table.Column<long>(type: "bigint", nullable: true),
VendorId = table.Column<long>(type: "bigint", nullable: false),
WarehouseId = table.Column<long>(type: "bigint", nullable: false),
Status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
CreatedBy = table.Column<long>(type: "bigint", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
PostedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
xmin = table.Column<uint>(type: "xid", rowVersion: true, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_grns", x => x.GrnId);
table.ForeignKey(
name: "FK_grns_purchase_orders_PoId",
column: x => x.PoId,
principalTable: "purchase_orders",
principalColumn: "PoId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_grns_users_CreatedBy",
column: x => x.CreatedBy,
principalTable: "users",
principalColumn: "UserId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_grns_vendors_VendorId",
column: x => x.VendorId,
principalTable: "vendors",
principalColumn: "VendorId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_grns_warehouses_WarehouseId",
column: x => x.WarehouseId,
principalTable: "warehouses",
principalColumn: "WarehouseId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "serials",
columns: table => new
{
SerialId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ItemId = table.Column<long>(type: "bigint", nullable: false),
SerialNo = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
Status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_serials", x => x.SerialId);
table.ForeignKey(
name: "FK_serials_items_ItemId",
column: x => x.ItemId,
principalTable: "items",
principalColumn: "ItemId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "grn_lines",
columns: table => new
{
GrnLineId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
GrnId = table.Column<long>(type: "bigint", nullable: false),
PoLineId = table.Column<long>(type: "bigint", nullable: true),
ItemId = table.Column<long>(type: "bigint", nullable: false),
UomId = table.Column<long>(type: "bigint", nullable: false),
BinId = table.Column<long>(type: "bigint", nullable: true),
BatchId = table.Column<long>(type: "bigint", nullable: true),
Qty = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false),
UnitCost = table.Column<decimal>(type: "numeric(18,6)", precision: 18, scale: 6, nullable: false),
ReceivedValue = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false),
HoldStatus = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_grn_lines", x => x.GrnLineId);
table.ForeignKey(
name: "FK_grn_lines_batches_BatchId",
column: x => x.BatchId,
principalTable: "batches",
principalColumn: "BatchId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_grn_lines_bins_BinId",
column: x => x.BinId,
principalTable: "bins",
principalColumn: "BinId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_grn_lines_grns_GrnId",
column: x => x.GrnId,
principalTable: "grns",
principalColumn: "GrnId",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_grn_lines_items_ItemId",
column: x => x.ItemId,
principalTable: "items",
principalColumn: "ItemId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_grn_lines_po_lines_PoLineId",
column: x => x.PoLineId,
principalTable: "po_lines",
principalColumn: "PoLineId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_grn_lines_uoms_UomId",
column: x => x.UomId,
principalTable: "uoms",
principalColumn: "UomId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "stock_ledger",
columns: table => new
{
LedgerId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ItemId = table.Column<long>(type: "bigint", nullable: false),
WarehouseId = table.Column<long>(type: "bigint", nullable: false),
BinId = table.Column<long>(type: "bigint", nullable: true),
BatchId = table.Column<long>(type: "bigint", nullable: true),
SerialId = table.Column<long>(type: "bigint", nullable: true),
UserId = table.Column<long>(type: "bigint", nullable: false),
Direction = table.Column<string>(type: "character varying(5)", maxLength: 5, nullable: false),
QtyBase = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false),
UnitCost = table.Column<decimal>(type: "numeric(18,6)", precision: 18, scale: 6, nullable: false),
Value = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false),
RunningBalance = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false),
SourceDocType = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false),
SourceDocId = table.Column<long>(type: "bigint", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_stock_ledger", x => x.LedgerId);
table.ForeignKey(
name: "FK_stock_ledger_batches_BatchId",
column: x => x.BatchId,
principalTable: "batches",
principalColumn: "BatchId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_ledger_bins_BinId",
column: x => x.BinId,
principalTable: "bins",
principalColumn: "BinId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_ledger_items_ItemId",
column: x => x.ItemId,
principalTable: "items",
principalColumn: "ItemId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_ledger_serials_SerialId",
column: x => x.SerialId,
principalTable: "serials",
principalColumn: "SerialId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_ledger_users_UserId",
column: x => x.UserId,
principalTable: "users",
principalColumn: "UserId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_ledger_warehouses_WarehouseId",
column: x => x.WarehouseId,
principalTable: "warehouses",
principalColumn: "WarehouseId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "stock_layers",
columns: table => new
{
LayerId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ItemId = table.Column<long>(type: "bigint", nullable: false),
WarehouseId = table.Column<long>(type: "bigint", nullable: false),
BatchId = table.Column<long>(type: "bigint", nullable: true),
SerialId = table.Column<long>(type: "bigint", nullable: true),
GrnLineId = table.Column<long>(type: "bigint", nullable: true),
QtyReceived = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false),
QtyRemaining = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false),
UnitCost = table.Column<decimal>(type: "numeric(18,6)", precision: 18, scale: 6, nullable: false),
ReceiptDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_stock_layers", x => x.LayerId);
table.ForeignKey(
name: "FK_stock_layers_batches_BatchId",
column: x => x.BatchId,
principalTable: "batches",
principalColumn: "BatchId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_layers_grn_lines_GrnLineId",
column: x => x.GrnLineId,
principalTable: "grn_lines",
principalColumn: "GrnLineId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_layers_items_ItemId",
column: x => x.ItemId,
principalTable: "items",
principalColumn: "ItemId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_layers_serials_SerialId",
column: x => x.SerialId,
principalTable: "serials",
principalColumn: "SerialId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_layers_warehouses_WarehouseId",
column: x => x.WarehouseId,
principalTable: "warehouses",
principalColumn: "WarehouseId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_batches_ItemId_BatchNo",
table: "batches",
columns: new[] { "ItemId", "BatchNo" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_grn_lines_BatchId",
table: "grn_lines",
column: "BatchId");
migrationBuilder.CreateIndex(
name: "IX_grn_lines_BinId",
table: "grn_lines",
column: "BinId");
migrationBuilder.CreateIndex(
name: "IX_grn_lines_GrnId",
table: "grn_lines",
column: "GrnId");
migrationBuilder.CreateIndex(
name: "IX_grn_lines_ItemId",
table: "grn_lines",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_grn_lines_PoLineId",
table: "grn_lines",
column: "PoLineId");
migrationBuilder.CreateIndex(
name: "IX_grn_lines_UomId",
table: "grn_lines",
column: "UomId");
migrationBuilder.CreateIndex(
name: "IX_grns_CreatedBy",
table: "grns",
column: "CreatedBy");
migrationBuilder.CreateIndex(
name: "IX_grns_DocNo",
table: "grns",
column: "DocNo",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_grns_PoId",
table: "grns",
column: "PoId");
migrationBuilder.CreateIndex(
name: "IX_grns_Status",
table: "grns",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_grns_VendorId",
table: "grns",
column: "VendorId");
migrationBuilder.CreateIndex(
name: "IX_grns_WarehouseId",
table: "grns",
column: "WarehouseId");
migrationBuilder.CreateIndex(
name: "IX_serials_ItemId_SerialNo",
table: "serials",
columns: new[] { "ItemId", "SerialNo" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_stock_layers_BatchId",
table: "stock_layers",
column: "BatchId");
migrationBuilder.CreateIndex(
name: "IX_stock_layers_GrnLineId",
table: "stock_layers",
column: "GrnLineId");
migrationBuilder.CreateIndex(
name: "IX_stock_layers_ItemId_WarehouseId_ReceiptDate_LayerId",
table: "stock_layers",
columns: new[] { "ItemId", "WarehouseId", "ReceiptDate", "LayerId" });
migrationBuilder.CreateIndex(
name: "IX_stock_layers_SerialId",
table: "stock_layers",
column: "SerialId");
migrationBuilder.CreateIndex(
name: "IX_stock_layers_WarehouseId",
table: "stock_layers",
column: "WarehouseId");
migrationBuilder.CreateIndex(
name: "IX_stock_ledger_BatchId",
table: "stock_ledger",
column: "BatchId");
migrationBuilder.CreateIndex(
name: "IX_stock_ledger_BinId",
table: "stock_ledger",
column: "BinId");
migrationBuilder.CreateIndex(
name: "IX_stock_ledger_ItemId_WarehouseId_CreatedAt",
table: "stock_ledger",
columns: new[] { "ItemId", "WarehouseId", "CreatedAt" });
migrationBuilder.CreateIndex(
name: "IX_stock_ledger_ItemId_WarehouseId_LedgerId",
table: "stock_ledger",
columns: new[] { "ItemId", "WarehouseId", "LedgerId" });
migrationBuilder.CreateIndex(
name: "IX_stock_ledger_SerialId",
table: "stock_ledger",
column: "SerialId");
migrationBuilder.CreateIndex(
name: "IX_stock_ledger_SourceDocType_SourceDocId",
table: "stock_ledger",
columns: new[] { "SourceDocType", "SourceDocId" });
migrationBuilder.CreateIndex(
name: "IX_stock_ledger_UserId",
table: "stock_ledger",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_stock_ledger_WarehouseId",
table: "stock_ledger",
column: "WarehouseId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "stock_layers");
migrationBuilder.DropTable(
name: "stock_ledger");
migrationBuilder.DropTable(
name: "grn_lines");
migrationBuilder.DropTable(
name: "serials");
migrationBuilder.DropTable(
name: "batches");
migrationBuilder.DropTable(
name: "grns");
}
}
}
File diff suppressed because it is too large Load Diff
@@ -1,337 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace ERPCore.Infra.Persistence.Migrations
{
/// <inheritdoc />
public partial class AddStockTransactions : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "reason_codes",
columns: table => new
{
ReasonCodeId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Code = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
Description = table.Column<string>(type: "character varying(200)", maxLength: 200, nullable: false),
Context = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_reason_codes", x => x.ReasonCodeId);
});
migrationBuilder.CreateTable(
name: "stock_transfers",
columns: table => new
{
TransferId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
DocNo = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
SrcWarehouseId = table.Column<long>(type: "bigint", nullable: false),
DestWarehouseId = table.Column<long>(type: "bigint", nullable: false),
Status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
CreatedBy = table.Column<long>(type: "bigint", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
xmin = table.Column<uint>(type: "xid", rowVersion: true, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_stock_transfers", x => x.TransferId);
table.ForeignKey(
name: "FK_stock_transfers_users_CreatedBy",
column: x => x.CreatedBy,
principalTable: "users",
principalColumn: "UserId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_transfers_warehouses_DestWarehouseId",
column: x => x.DestWarehouseId,
principalTable: "warehouses",
principalColumn: "WarehouseId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_transfers_warehouses_SrcWarehouseId",
column: x => x.SrcWarehouseId,
principalTable: "warehouses",
principalColumn: "WarehouseId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "stock_adjustments",
columns: table => new
{
AdjustmentId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
DocNo = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
WarehouseId = table.Column<long>(type: "bigint", nullable: false),
ReasonCodeId = table.Column<long>(type: "bigint", nullable: false),
Status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
CreatedBy = table.Column<long>(type: "bigint", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
xmin = table.Column<uint>(type: "xid", rowVersion: true, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_stock_adjustments", x => x.AdjustmentId);
table.ForeignKey(
name: "FK_stock_adjustments_reason_codes_ReasonCodeId",
column: x => x.ReasonCodeId,
principalTable: "reason_codes",
principalColumn: "ReasonCodeId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_adjustments_users_CreatedBy",
column: x => x.CreatedBy,
principalTable: "users",
principalColumn: "UserId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_adjustments_warehouses_WarehouseId",
column: x => x.WarehouseId,
principalTable: "warehouses",
principalColumn: "WarehouseId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "stock_transfer_lines",
columns: table => new
{
TransferLineId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
TransferId = table.Column<long>(type: "bigint", nullable: false),
ItemId = table.Column<long>(type: "bigint", nullable: false),
SrcBinId = table.Column<long>(type: "bigint", nullable: true),
DestBinId = table.Column<long>(type: "bigint", nullable: true),
BatchId = table.Column<long>(type: "bigint", nullable: true),
SerialId = table.Column<long>(type: "bigint", nullable: true),
Qty = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false),
UnitCost = table.Column<decimal>(type: "numeric(18,6)", precision: 18, scale: 6, nullable: true),
QtyReceived = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_stock_transfer_lines", x => x.TransferLineId);
table.ForeignKey(
name: "FK_stock_transfer_lines_batches_BatchId",
column: x => x.BatchId,
principalTable: "batches",
principalColumn: "BatchId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_transfer_lines_bins_DestBinId",
column: x => x.DestBinId,
principalTable: "bins",
principalColumn: "BinId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_transfer_lines_bins_SrcBinId",
column: x => x.SrcBinId,
principalTable: "bins",
principalColumn: "BinId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_transfer_lines_items_ItemId",
column: x => x.ItemId,
principalTable: "items",
principalColumn: "ItemId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_transfer_lines_serials_SerialId",
column: x => x.SerialId,
principalTable: "serials",
principalColumn: "SerialId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_transfer_lines_stock_transfers_TransferId",
column: x => x.TransferId,
principalTable: "stock_transfers",
principalColumn: "TransferId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "stock_adjustment_lines",
columns: table => new
{
AdjLineId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
AdjustmentId = table.Column<long>(type: "bigint", nullable: false),
ItemId = table.Column<long>(type: "bigint", nullable: false),
BinId = table.Column<long>(type: "bigint", nullable: true),
BatchId = table.Column<long>(type: "bigint", nullable: true),
SerialId = table.Column<long>(type: "bigint", nullable: true),
QtyDelta = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_stock_adjustment_lines", x => x.AdjLineId);
table.ForeignKey(
name: "FK_stock_adjustment_lines_batches_BatchId",
column: x => x.BatchId,
principalTable: "batches",
principalColumn: "BatchId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_adjustment_lines_bins_BinId",
column: x => x.BinId,
principalTable: "bins",
principalColumn: "BinId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_adjustment_lines_items_ItemId",
column: x => x.ItemId,
principalTable: "items",
principalColumn: "ItemId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_adjustment_lines_serials_SerialId",
column: x => x.SerialId,
principalTable: "serials",
principalColumn: "SerialId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_adjustment_lines_stock_adjustments_AdjustmentId",
column: x => x.AdjustmentId,
principalTable: "stock_adjustments",
principalColumn: "AdjustmentId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_reason_codes_Context_Code",
table: "reason_codes",
columns: new[] { "Context", "Code" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_stock_adjustment_lines_AdjustmentId",
table: "stock_adjustment_lines",
column: "AdjustmentId");
migrationBuilder.CreateIndex(
name: "IX_stock_adjustment_lines_BatchId",
table: "stock_adjustment_lines",
column: "BatchId");
migrationBuilder.CreateIndex(
name: "IX_stock_adjustment_lines_BinId",
table: "stock_adjustment_lines",
column: "BinId");
migrationBuilder.CreateIndex(
name: "IX_stock_adjustment_lines_ItemId",
table: "stock_adjustment_lines",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_stock_adjustment_lines_SerialId",
table: "stock_adjustment_lines",
column: "SerialId");
migrationBuilder.CreateIndex(
name: "IX_stock_adjustments_CreatedBy",
table: "stock_adjustments",
column: "CreatedBy");
migrationBuilder.CreateIndex(
name: "IX_stock_adjustments_DocNo",
table: "stock_adjustments",
column: "DocNo",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_stock_adjustments_ReasonCodeId",
table: "stock_adjustments",
column: "ReasonCodeId");
migrationBuilder.CreateIndex(
name: "IX_stock_adjustments_WarehouseId",
table: "stock_adjustments",
column: "WarehouseId");
migrationBuilder.CreateIndex(
name: "IX_stock_transfer_lines_BatchId",
table: "stock_transfer_lines",
column: "BatchId");
migrationBuilder.CreateIndex(
name: "IX_stock_transfer_lines_DestBinId",
table: "stock_transfer_lines",
column: "DestBinId");
migrationBuilder.CreateIndex(
name: "IX_stock_transfer_lines_ItemId",
table: "stock_transfer_lines",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_stock_transfer_lines_SerialId",
table: "stock_transfer_lines",
column: "SerialId");
migrationBuilder.CreateIndex(
name: "IX_stock_transfer_lines_SrcBinId",
table: "stock_transfer_lines",
column: "SrcBinId");
migrationBuilder.CreateIndex(
name: "IX_stock_transfer_lines_TransferId",
table: "stock_transfer_lines",
column: "TransferId");
migrationBuilder.CreateIndex(
name: "IX_stock_transfers_CreatedBy",
table: "stock_transfers",
column: "CreatedBy");
migrationBuilder.CreateIndex(
name: "IX_stock_transfers_DestWarehouseId",
table: "stock_transfers",
column: "DestWarehouseId");
migrationBuilder.CreateIndex(
name: "IX_stock_transfers_DocNo",
table: "stock_transfers",
column: "DocNo",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_stock_transfers_SrcWarehouseId",
table: "stock_transfers",
column: "SrcWarehouseId");
migrationBuilder.CreateIndex(
name: "IX_stock_transfers_Status",
table: "stock_transfers",
column: "Status");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "stock_adjustment_lines");
migrationBuilder.DropTable(
name: "stock_transfer_lines");
migrationBuilder.DropTable(
name: "stock_adjustments");
migrationBuilder.DropTable(
name: "stock_transfers");
migrationBuilder.DropTable(
name: "reason_codes");
}
}
}
File diff suppressed because it is too large Load Diff
@@ -1,253 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace ERPCore.Infra.Persistence.Migrations
{
/// <inheritdoc />
public partial class AddCountsAndReturns : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "purchase_returns",
columns: table => new
{
ReturnId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
DocNo = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
VendorId = table.Column<long>(type: "bigint", nullable: false),
WarehouseId = table.Column<long>(type: "bigint", nullable: false),
ReasonCodeId = table.Column<long>(type: "bigint", nullable: false),
Status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
CreatedBy = table.Column<long>(type: "bigint", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_purchase_returns", x => x.ReturnId);
table.ForeignKey(
name: "FK_purchase_returns_reason_codes_ReasonCodeId",
column: x => x.ReasonCodeId,
principalTable: "reason_codes",
principalColumn: "ReasonCodeId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_purchase_returns_users_CreatedBy",
column: x => x.CreatedBy,
principalTable: "users",
principalColumn: "UserId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_purchase_returns_vendors_VendorId",
column: x => x.VendorId,
principalTable: "vendors",
principalColumn: "VendorId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_purchase_returns_warehouses_WarehouseId",
column: x => x.WarehouseId,
principalTable: "warehouses",
principalColumn: "WarehouseId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "stock_counts",
columns: table => new
{
CountId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
DocNo = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
WarehouseId = table.Column<long>(type: "bigint", nullable: false),
CountType = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
Status = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
CreatedBy = table.Column<long>(type: "bigint", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
xmin = table.Column<uint>(type: "xid", rowVersion: true, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_stock_counts", x => x.CountId);
table.ForeignKey(
name: "FK_stock_counts_users_CreatedBy",
column: x => x.CreatedBy,
principalTable: "users",
principalColumn: "UserId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_counts_warehouses_WarehouseId",
column: x => x.WarehouseId,
principalTable: "warehouses",
principalColumn: "WarehouseId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "purchase_return_lines",
columns: table => new
{
ReturnLineId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ReturnId = table.Column<long>(type: "bigint", nullable: false),
GrnLineId = table.Column<long>(type: "bigint", nullable: true),
ItemId = table.Column<long>(type: "bigint", nullable: false),
Qty = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_purchase_return_lines", x => x.ReturnLineId);
table.ForeignKey(
name: "FK_purchase_return_lines_grn_lines_GrnLineId",
column: x => x.GrnLineId,
principalTable: "grn_lines",
principalColumn: "GrnLineId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_purchase_return_lines_items_ItemId",
column: x => x.ItemId,
principalTable: "items",
principalColumn: "ItemId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_purchase_return_lines_purchase_returns_ReturnId",
column: x => x.ReturnId,
principalTable: "purchase_returns",
principalColumn: "ReturnId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "stock_count_lines",
columns: table => new
{
CountLineId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
CountId = table.Column<long>(type: "bigint", nullable: false),
ItemId = table.Column<long>(type: "bigint", nullable: false),
BinId = table.Column<long>(type: "bigint", nullable: true),
SystemQty = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false),
CountedQty = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: true),
Variance = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_stock_count_lines", x => x.CountLineId);
table.ForeignKey(
name: "FK_stock_count_lines_bins_BinId",
column: x => x.BinId,
principalTable: "bins",
principalColumn: "BinId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_count_lines_items_ItemId",
column: x => x.ItemId,
principalTable: "items",
principalColumn: "ItemId",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_stock_count_lines_stock_counts_CountId",
column: x => x.CountId,
principalTable: "stock_counts",
principalColumn: "CountId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_purchase_return_lines_GrnLineId",
table: "purchase_return_lines",
column: "GrnLineId");
migrationBuilder.CreateIndex(
name: "IX_purchase_return_lines_ItemId",
table: "purchase_return_lines",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_purchase_return_lines_ReturnId",
table: "purchase_return_lines",
column: "ReturnId");
migrationBuilder.CreateIndex(
name: "IX_purchase_returns_CreatedBy",
table: "purchase_returns",
column: "CreatedBy");
migrationBuilder.CreateIndex(
name: "IX_purchase_returns_DocNo",
table: "purchase_returns",
column: "DocNo",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_purchase_returns_ReasonCodeId",
table: "purchase_returns",
column: "ReasonCodeId");
migrationBuilder.CreateIndex(
name: "IX_purchase_returns_VendorId",
table: "purchase_returns",
column: "VendorId");
migrationBuilder.CreateIndex(
name: "IX_purchase_returns_WarehouseId",
table: "purchase_returns",
column: "WarehouseId");
migrationBuilder.CreateIndex(
name: "IX_stock_count_lines_BinId",
table: "stock_count_lines",
column: "BinId");
migrationBuilder.CreateIndex(
name: "IX_stock_count_lines_CountId",
table: "stock_count_lines",
column: "CountId");
migrationBuilder.CreateIndex(
name: "IX_stock_count_lines_ItemId",
table: "stock_count_lines",
column: "ItemId");
migrationBuilder.CreateIndex(
name: "IX_stock_counts_CreatedBy",
table: "stock_counts",
column: "CreatedBy");
migrationBuilder.CreateIndex(
name: "IX_stock_counts_DocNo",
table: "stock_counts",
column: "DocNo",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_stock_counts_Status",
table: "stock_counts",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_stock_counts_WarehouseId",
table: "stock_counts",
column: "WarehouseId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "purchase_return_lines");
migrationBuilder.DropTable(
name: "stock_count_lines");
migrationBuilder.DropTable(
name: "purchase_returns");
migrationBuilder.DropTable(
name: "stock_counts");
}
}
}
File diff suppressed because it is too large Load Diff
@@ -1,87 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace ERPCore.Infra.Persistence.Migrations
{
/// <inheritdoc />
public partial class AddAuditAndJournal : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "audit_logs",
columns: table => new
{
AuditId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
UserId = table.Column<long>(type: "bigint", nullable: false),
EntityType = table.Column<string>(type: "character varying(80)", maxLength: 80, nullable: false),
EntityId = table.Column<long>(type: "bigint", nullable: false),
Action = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false),
ChangeSet = table.Column<string>(type: "jsonb", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_audit_logs", x => x.AuditId);
table.ForeignKey(
name: "FK_audit_logs_users_UserId",
column: x => x.UserId,
principalTable: "users",
principalColumn: "UserId",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "journal_entry_stubs",
columns: table => new
{
JournalId = table.Column<long>(type: "bigint", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
SourceDocType = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false),
SourceDocId = table.Column<long>(type: "bigint", nullable: false),
DebitAccount = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
CreditAccount = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
Amount = table.Column<decimal>(type: "numeric(18,4)", precision: 18, scale: 4, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_journal_entry_stubs", x => x.JournalId);
});
migrationBuilder.CreateIndex(
name: "IX_audit_logs_CreatedAt",
table: "audit_logs",
column: "CreatedAt");
migrationBuilder.CreateIndex(
name: "IX_audit_logs_EntityType_EntityId",
table: "audit_logs",
columns: new[] { "EntityType", "EntityId" });
migrationBuilder.CreateIndex(
name: "IX_audit_logs_UserId",
table: "audit_logs",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_journal_entry_stubs_SourceDocType_SourceDocId",
table: "journal_entry_stubs",
columns: new[] { "SourceDocType", "SourceDocId" });
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "audit_logs");
migrationBuilder.DropTable(
name: "journal_entry_stubs");
}
}
}
@@ -1,46 +0,0 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ERPCore.Infra.Persistence.Migrations
{
/// <inheritdoc />
public partial class AddAuthUserId : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "auth_user_id",
table: "users",
type: "uuid",
nullable: true);
migrationBuilder.UpdateData(
table: "users",
keyColumn: "UserId",
keyValue: 1L,
column: "auth_user_id",
value: null);
migrationBuilder.CreateIndex(
name: "IX_users_auth_user_id",
table: "users",
column: "auth_user_id",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropIndex(
name: "IX_users_auth_user_id",
table: "users");
migrationBuilder.DropColumn(
name: "auth_user_id",
table: "users");
}
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff