add test and outbound test

This commit is contained in:
zhougf committed 2026-06-01 23:30:36 +08:00
1 parent 38ecbf82e5
commit 7f621dd553
23 files changed
+1301 -26

No files matched your search

@@ -33,12 +33,16 @@ public class AreaWarehouseHierarchy0011 : Migration
private void SeedAreasAndBackfillZones()
{
if (!Schema.Table("area").Exists() || !Schema.Table("zone").Exists())
if (!Schema.Table("zone").Exists())
{
return;
}
Execute.Sql("""
ALTER TABLE zone ADD COLUMN IF NOT EXISTS area_code varchar(64);
UPDATE zone SET area_code = 'DEFAULT' WHERE area_code IS NULL;
ALTER TABLE zone ALTER COLUMN area_code SET NOT NULL;
WITH d AS (
SELECT DISTINCT tenant_id, owner_code, warehouse_code
FROM zone
@@ -77,10 +81,6 @@ public class AreaWarehouseHierarchy0011 : Migration
WHERE NOT a.is_deleted AND a.tenant_id = d.tenant_id AND a.owner_code = d.owner_code
AND a.warehouse_code = d.warehouse_code AND a.code = 'DEFAULT');
ALTER TABLE zone ADD COLUMN IF NOT EXISTS area_code varchar(64);
UPDATE zone SET area_code = 'DEFAULT' WHERE area_code IS NULL;
ALTER TABLE zone ALTER COLUMN area_code SET NOT NULL;
DO $$ BEGIN
ALTER TABLE zone ADD CONSTRAINT uq_zone_wh_area_code UNIQUE (tenant_id, owner_code, warehouse_code, area_code, code);
EXCEPTION
@@ -0,0 +1,68 @@
using FluentMigrator;
namespace WmsLite.Api.Database.Migrations;
[Migration(15, "Outbound allocation pick tasks")]
public class OutboundAllocationPickTasks0015 : Migration
{
public override void Up()
{
if (!Schema.Table("outbound_pick_task").Exists())
{
Create.Table("outbound_pick_task")
.WithBaseColumns()
.WithColumn("order_id").AsInt64().NotNullable()
.WithColumn("order_line_id").AsInt64().NotNullable()
.WithColumn("task_no").AsString(128).NotNullable()
.WithColumn("inventory_id").AsInt64().NotNullable()
.WithColumn("inventory_kind").AsInt32().NotNullable()
.WithColumn("material_code").AsString(64).Nullable()
.WithColumn("container_code").AsString(64).Nullable()
.WithColumn("warehouse_code").AsString(64).NotNullable()
.WithColumn("area_code").AsString(64).NotNullable()
.WithColumn("zone_code").AsString(64).NotNullable()
.WithColumn("location_code").AsString(64).NotNullable()
.WithColumn("qty").AsDecimal().NotNullable()
.WithColumn("picked_qty").AsDecimal().NotNullable().WithDefaultValue(0)
.WithColumn("unit").AsString(32).NotNullable()
.WithColumn("task_status").AsInt32().NotNullable()
.WithColumn("attrs").AsCustom("jsonb").Nullable();
}
Execute.Sql("""
ALTER TABLE outbound_order_line ALTER COLUMN location_code DROP NOT NULL;
CREATE INDEX IF NOT EXISTS idx_outbound_pick_task_order
ON outbound_pick_task (tenant_id, owner_code, order_id, task_no);
CREATE INDEX IF NOT EXISTS idx_outbound_pick_task_line
ON outbound_pick_task (tenant_id, owner_code, order_line_id);
CREATE INDEX IF NOT EXISTS idx_outbound_pick_task_inventory
ON outbound_pick_task (tenant_id, owner_code, inventory_id);
CREATE UNIQUE INDEX IF NOT EXISTS uq_outbound_pick_task_no
ON outbound_pick_task (tenant_id, owner_code, task_no) WHERE NOT is_deleted;
""");
}
public override void Down()
{
Execute.Sql("""
DROP INDEX IF EXISTS uq_outbound_pick_task_no;
DROP INDEX IF EXISTS idx_outbound_pick_task_inventory;
DROP INDEX IF EXISTS idx_outbound_pick_task_line;
DROP INDEX IF EXISTS idx_outbound_pick_task_order;
""");
if (Schema.Table("outbound_pick_task").Exists())
{
Delete.Table("outbound_pick_task");
}
Execute.Sql("""
UPDATE outbound_order_line SET location_code = 'DEFAULT' WHERE location_code IS NULL;
ALTER TABLE outbound_order_line ALTER COLUMN location_code SET NOT NULL;
""");
}
}