Implement API security baseline (sys_user, JWT, audit fields, transactions, unique constraints) and Web real login with 401 handling. Document setup and development workflows in root, WmsLite.Api, and WmsLite.Web README files. Co-authored-by: Cursor <cursoragent@cursor.com>
69 lines
3.0 KiB
C#
69 lines
3.0 KiB
C#
using FluentMigrator;
|
|
|
|
namespace WmsLite.Api.Database.Migrations;
|
|
|
|
[Migration(14, "Business unique constraints (partial indexes)")]
|
|
public class BusinessUniqueConstraints0014 : Migration
|
|
{
|
|
public override void Up()
|
|
{
|
|
Execute.Sql("""
|
|
CREATE UNIQUE INDEX IF NOT EXISTS uq_warehouse_code
|
|
ON warehouse (tenant_id, owner_code, code) WHERE NOT is_deleted;
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS uq_area_code
|
|
ON area (tenant_id, owner_code, warehouse_code, code) WHERE NOT is_deleted;
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS uq_zone_code
|
|
ON zone (tenant_id, owner_code, warehouse_code, area_code, code) WHERE NOT is_deleted;
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS uq_location_code
|
|
ON location (tenant_id, owner_code, warehouse_code, area_code, zone_code, code) WHERE NOT is_deleted;
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS uq_material_code
|
|
ON material (tenant_id, owner_code, code) WHERE NOT is_deleted;
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS uq_container_code
|
|
ON container (tenant_id, owner_code, code) WHERE NOT is_deleted;
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS uq_inbound_order_no
|
|
ON inbound_order (tenant_id, owner_code, order_no) WHERE NOT is_deleted;
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS uq_outbound_order_no
|
|
ON outbound_order (tenant_id, owner_code, order_no) WHERE NOT is_deleted;
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS uq_transfer_order_no
|
|
ON transfer_order (tenant_id, owner_code, order_no) WHERE NOT is_deleted;
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS uq_stocktake_order_no
|
|
ON stocktake_order (tenant_id, owner_code, order_no) WHERE NOT is_deleted;
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS uq_inventory_material_stock
|
|
ON inventory (tenant_id, owner_code, warehouse_code, area_code, zone_code, location_code, inventory_kind, material_code)
|
|
WHERE NOT is_deleted AND material_code IS NOT NULL;
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS uq_inventory_container_stock
|
|
ON inventory (tenant_id, owner_code, warehouse_code, area_code, zone_code, location_code, inventory_kind, container_code)
|
|
WHERE NOT is_deleted AND container_code IS NOT NULL;
|
|
""");
|
|
}
|
|
|
|
public override void Down()
|
|
{
|
|
Execute.Sql("""
|
|
DROP INDEX IF EXISTS uq_warehouse_code;
|
|
DROP INDEX IF EXISTS uq_area_code;
|
|
DROP INDEX IF EXISTS uq_zone_code;
|
|
DROP INDEX IF EXISTS uq_location_code;
|
|
DROP INDEX IF EXISTS uq_material_code;
|
|
DROP INDEX IF EXISTS uq_container_code;
|
|
DROP INDEX IF EXISTS uq_inbound_order_no;
|
|
DROP INDEX IF EXISTS uq_outbound_order_no;
|
|
DROP INDEX IF EXISTS uq_transfer_order_no;
|
|
DROP INDEX IF EXISTS uq_stocktake_order_no;
|
|
DROP INDEX IF EXISTS uq_inventory_material_stock;
|
|
DROP INDEX IF EXISTS uq_inventory_container_stock;
|
|
""");
|
|
}
|
|
}
|