Files
Migu2.0/MiGu.DB/Migrations/Sqlite/20260727011546_InitialPlatform.cs
T
wei.wu 51c3fc1994 持久层重构为独立 MiGu.DB 工程并优化集成
- 新增 MiGu.DB 项目,迁移所有领域实体与枚举,统一模型约定
- 实现 Entity/Repository/UoW/Provider/Exception 等接口与实现
- 支持数据修补机制,完善 Sqlite 初始迁移与数据库管理
- Server 侧移除 EF Core 相关,依赖 MiGu.DB,PlatformPersistence 适配
- 业务服务注入 UoW/Repository,状态字段统一用 enum 及辅助类
- 统一异常处理,Controller 映射 HTTP 状态码
- 配置项与文档补充数据库启动、SchemaMode、迁移说明
- 新增 GlobalUsings.Db.cs、WmsStatusAliases.cs 简化类型引用
- 新增 HttpActorContextMiddleware 支持操作者上下文一致性
- 新增 MiGuDbContextModelSnapshot 追踪数据库结构
- 优化代码结构,解耦领域与持久层,提升扩展性与安全性
2026-07-27 14:26:04 +08:00

755 lines
44 KiB
C#

using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace MiGu.DB.Migrations.Sqlite
{
/// <summary>
/// Sqlite 初始 Schema(平台库全量表)。旧 EnsureCreated 库启动时会先基线本迁移名,再应用后续增量。
/// </summary>
public partial class InitialPlatform : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "simple_fields",
columns: table => new
{
id = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
car_type = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
field_type = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
key = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
value = table.Column<string>(type: "TEXT", nullable: false),
data_type = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
chinese = table.Column<string>(type: "TEXT", maxLength: 256, nullable: true),
english = table.Column<string>(type: "TEXT", maxLength: 256, nullable: true),
other = table.Column<string>(type: "TEXT", maxLength: 512, nullable: false),
is_default = table.Column<bool>(type: "INTEGER", nullable: false),
create_time = table.Column<string>(type: "TEXT", maxLength: 19, nullable: false),
update_time = table.Column<string>(type: "TEXT", maxLength: 19, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_simple_fields", x => x.id);
});
migrationBuilder.CreateTable(
name: "user_dashboard_shortcuts",
columns: table => new
{
user_id = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
scope = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
keys_json = table.Column<string>(type: "text", nullable: false),
updated_at = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_user_dashboard_shortcuts", x => new { x.user_id, x.scope });
});
migrationBuilder.CreateTable(
name: "wms_areas",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
WarehouseId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
Code = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
Name = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Type = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
LayoutMode = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
State = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
Enabled = table.Column<bool>(type: "INTEGER", nullable: false),
SortOrder = table.Column<int>(type: "INTEGER", nullable: false),
CreatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
UpdatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
CreatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
UpdatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false),
DeletedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: true),
DeletedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Version = table.Column<long>(type: "INTEGER", nullable: false),
IsLock = table.Column<bool>(type: "INTEGER", nullable: false),
Remark = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: false),
Extend = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_wms_areas", x => x.Id);
});
migrationBuilder.CreateTable(
name: "wms_container_location_history",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
FromLocationType = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
FromLocationId = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
ToLocationType = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
ToLocationId = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
RelationId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: true),
EventType = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
BeforeJson = table.Column<string>(type: "text", nullable: false),
AfterJson = table.Column<string>(type: "text", nullable: false),
ContainerId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: true),
Operator = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
OperatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
Source = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
Reason = table.Column<string>(type: "TEXT", maxLength: 500, nullable: false),
Remark = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: false),
Extend = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_wms_container_location_history", x => x.Id);
});
migrationBuilder.CreateTable(
name: "wms_container_locations",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
ContainerId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
LocationType = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
LocationId = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
StorageId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: true),
LocationCode = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
LocationName = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Status = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
EnteredAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
CreatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
UpdatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
CreatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
UpdatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false),
DeletedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: true),
DeletedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Version = table.Column<long>(type: "INTEGER", nullable: false),
IsLock = table.Column<bool>(type: "INTEGER", nullable: false),
Remark = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: false),
Extend = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_wms_container_locations", x => x.Id);
});
migrationBuilder.CreateTable(
name: "wms_container_material_history",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
MaterialId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: true),
QuantityDelta = table.Column<decimal>(type: "TEXT", precision: 18, scale: 4, nullable: false),
RelationId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: true),
EventType = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
BeforeJson = table.Column<string>(type: "text", nullable: false),
AfterJson = table.Column<string>(type: "text", nullable: false),
ContainerId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: true),
Operator = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
OperatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
Source = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
Reason = table.Column<string>(type: "TEXT", maxLength: 500, nullable: false),
Remark = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: false),
Extend = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_wms_container_material_history", x => x.Id);
});
migrationBuilder.CreateTable(
name: "wms_container_materials",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
ContainerId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
MaterialId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
Quantity = table.Column<decimal>(type: "TEXT", precision: 18, scale: 4, nullable: false),
BatchNo = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
SerialNo = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
Status = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
BoundAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
LoadedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
UnloadedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: true),
CreatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
UpdatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
CreatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
UpdatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false),
DeletedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: true),
DeletedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Version = table.Column<long>(type: "INTEGER", nullable: false),
IsLock = table.Column<bool>(type: "INTEGER", nullable: false),
Remark = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: false),
Extend = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_wms_container_materials", x => x.Id);
});
migrationBuilder.CreateTable(
name: "wms_containers",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
AreaId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: true),
Code = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
Name = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
ContainerType = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
Status = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
Barcode = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Length = table.Column<double>(type: "REAL", nullable: false),
Width = table.Column<double>(type: "REAL", nullable: false),
Height = table.Column<double>(type: "REAL", nullable: false),
Enabled = table.Column<bool>(type: "INTEGER", nullable: false),
CreatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
UpdatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
CreatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
UpdatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false),
DeletedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: true),
DeletedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Version = table.Column<long>(type: "INTEGER", nullable: false),
IsLock = table.Column<bool>(type: "INTEGER", nullable: false),
Remark = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: false),
Extend = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_wms_containers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "wms_material_types",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
Code = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
Name = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Spec = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Unit = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
Category = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
BarcodePrefix = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
Enabled = table.Column<bool>(type: "INTEGER", nullable: false),
CreatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
UpdatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
CreatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
UpdatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false),
DeletedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: true),
DeletedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Version = table.Column<long>(type: "INTEGER", nullable: false),
IsLock = table.Column<bool>(type: "INTEGER", nullable: false),
Remark = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: false),
Extend = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_wms_material_types", x => x.Id);
});
migrationBuilder.CreateTable(
name: "wms_materials",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
Code = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
Name = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
TypeCode = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
Barcode = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Spec = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Unit = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
Category = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
LifecycleStatus = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
UnboundAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: true),
Enabled = table.Column<bool>(type: "INTEGER", nullable: false),
CreatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
UpdatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
CreatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
UpdatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false),
DeletedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: true),
DeletedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Version = table.Column<long>(type: "INTEGER", nullable: false),
IsLock = table.Column<bool>(type: "INTEGER", nullable: false),
Remark = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: false),
Extend = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_wms_materials", x => x.Id);
});
migrationBuilder.CreateTable(
name: "wms_stock_events",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
EventType = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
MaterialId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: true),
MaterialCode = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
MaterialName = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
MaterialBarcode = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
MaterialTypeCode = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
ContainerId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: true),
ContainerCode = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
ContainerName = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
StorageId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: true),
StorageCode = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
StorageName = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
AreaCode = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
FromStorageId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: true),
FromStorageCode = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
FromStorageName = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
ToStorageId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: true),
ToStorageCode = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
ToStorageName = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
RefType = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
RefId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: true),
RefCode = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
Operator = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
OperatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
Reason = table.Column<string>(type: "TEXT", maxLength: 500, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_wms_stock_events", x => x.Id);
});
migrationBuilder.CreateTable(
name: "wms_storages",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
AreaId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
Code = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
Name = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
StorageType = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
LocationKind = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
ColumnNo = table.Column<int>(type: "INTEGER", nullable: false),
LevelNo = table.Column<int>(type: "INTEGER", nullable: false),
DepthNo = table.Column<int>(type: "INTEGER", nullable: false),
SiteId = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
SiteCode = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
Barcode = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Capacity = table.Column<int>(type: "INTEGER", nullable: false),
Status = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
Usage = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
Priority = table.Column<int>(type: "INTEGER", nullable: false),
ZoneCode = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
AllowInbound = table.Column<bool>(type: "INTEGER", nullable: false),
AllowOutbound = table.Column<bool>(type: "INTEGER", nullable: false),
Enabled = table.Column<bool>(type: "INTEGER", nullable: false),
CreatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
UpdatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
CreatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
UpdatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false),
DeletedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: true),
DeletedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Version = table.Column<long>(type: "INTEGER", nullable: false),
IsLock = table.Column<bool>(type: "INTEGER", nullable: false),
Remark = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: false),
Extend = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_wms_storages", x => x.Id);
});
migrationBuilder.CreateTable(
name: "wms_transport_reservations",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
TaskId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
ContainerId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
SourceStorageId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
TargetStorageId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
Status = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
ExpiresAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: true),
CreatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
UpdatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
CreatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
UpdatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false),
DeletedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: true),
DeletedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Version = table.Column<long>(type: "INTEGER", nullable: false),
IsLock = table.Column<bool>(type: "INTEGER", nullable: false),
Remark = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: false),
Extend = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_wms_transport_reservations", x => x.Id);
});
migrationBuilder.CreateTable(
name: "wms_transport_rules",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
Code = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
Name = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
TriggerType = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
Enabled = table.Column<bool>(type: "INTEGER", nullable: false),
Priority = table.Column<int>(type: "INTEGER", nullable: false),
SourceSelectorJson = table.Column<string>(type: "text", nullable: false),
TargetSelectorJson = table.Column<string>(type: "text", nullable: false),
TaskOptionsJson = table.Column<string>(type: "text", nullable: false),
CreatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
UpdatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
CreatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
UpdatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false),
DeletedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: true),
DeletedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Version = table.Column<long>(type: "INTEGER", nullable: false),
IsLock = table.Column<bool>(type: "INTEGER", nullable: false),
Remark = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: false),
Extend = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_wms_transport_rules", x => x.Id);
});
migrationBuilder.CreateTable(
name: "wms_transport_task_history",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
TaskId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
FromStatus = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
ToStatus = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
Operator = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
OperatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
Reason = table.Column<string>(type: "TEXT", maxLength: 500, nullable: false),
ErrorMessage = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: false),
SnapshotJson = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_wms_transport_task_history", x => x.Id);
});
migrationBuilder.CreateTable(
name: "wms_transport_tasks",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
BusinessType = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
RuleId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: true),
SourceStorageId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
TargetStorageId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
ContainerId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
MaterialId = table.Column<string>(type: "TEXT", maxLength: 36, nullable: true),
Quantity = table.Column<decimal>(type: "TEXT", precision: 18, scale: 4, nullable: true),
Status = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
DispatchMissionId = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
DeliveryId = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
DispatchStatus = table.Column<string>(type: "TEXT", maxLength: 32, nullable: false),
Reason = table.Column<string>(type: "TEXT", maxLength: 500, nullable: false),
SnapshotJson = table.Column<string>(type: "text", nullable: false),
ErrorMessage = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: false),
TaskPriority = table.Column<int>(type: "INTEGER", nullable: false),
CreatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
UpdatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
CreatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
UpdatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false),
DeletedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: true),
DeletedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Version = table.Column<long>(type: "INTEGER", nullable: false),
IsLock = table.Column<bool>(type: "INTEGER", nullable: false),
Remark = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: false),
Extend = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_wms_transport_tasks", x => x.Id);
});
migrationBuilder.CreateTable(
name: "wms_warehouses",
columns: table => new
{
Id = table.Column<string>(type: "TEXT", maxLength: 36, nullable: false),
Code = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
Name = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Type = table.Column<string>(type: "TEXT", maxLength: 64, nullable: false),
Enabled = table.Column<bool>(type: "INTEGER", nullable: false),
SortOrder = table.Column<int>(type: "INTEGER", nullable: false),
CreatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
UpdatedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: false),
CreatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
UpdatedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
IsDeleted = table.Column<bool>(type: "INTEGER", nullable: false),
DeletedAt = table.Column<string>(type: "TEXT", maxLength: 40, nullable: true),
DeletedBy = table.Column<string>(type: "TEXT", maxLength: 128, nullable: false),
Version = table.Column<long>(type: "INTEGER", nullable: false),
IsLock = table.Column<bool>(type: "INTEGER", nullable: false),
Remark = table.Column<string>(type: "TEXT", maxLength: 1000, nullable: false),
Extend = table.Column<string>(type: "text", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_wms_warehouses", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_simple_fields_car_type_field_type_key",
table: "simple_fields",
columns: new[] { "car_type", "field_type", "key" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_wms_areas_Code",
table: "wms_areas",
column: "Code",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_wms_areas_WarehouseId",
table: "wms_areas",
column: "WarehouseId");
migrationBuilder.CreateIndex(
name: "IX_wms_container_location_history_ContainerId",
table: "wms_container_location_history",
column: "ContainerId");
migrationBuilder.CreateIndex(
name: "IX_wms_container_location_history_EventType",
table: "wms_container_location_history",
column: "EventType");
migrationBuilder.CreateIndex(
name: "IX_wms_container_location_history_OperatedAt",
table: "wms_container_location_history",
column: "OperatedAt");
migrationBuilder.CreateIndex(
name: "IX_wms_container_locations_ContainerId",
table: "wms_container_locations",
column: "ContainerId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_wms_container_locations_LocationType_LocationId",
table: "wms_container_locations",
columns: new[] { "LocationType", "LocationId" });
migrationBuilder.CreateIndex(
name: "IX_wms_container_locations_StorageId",
table: "wms_container_locations",
column: "StorageId");
migrationBuilder.CreateIndex(
name: "IX_wms_container_material_history_ContainerId",
table: "wms_container_material_history",
column: "ContainerId");
migrationBuilder.CreateIndex(
name: "IX_wms_container_material_history_EventType",
table: "wms_container_material_history",
column: "EventType");
migrationBuilder.CreateIndex(
name: "IX_wms_container_material_history_OperatedAt",
table: "wms_container_material_history",
column: "OperatedAt");
migrationBuilder.CreateIndex(
name: "IX_wms_container_materials_ContainerId",
table: "wms_container_materials",
column: "ContainerId");
migrationBuilder.CreateIndex(
name: "IX_wms_container_materials_MaterialId",
table: "wms_container_materials",
column: "MaterialId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_wms_containers_Code",
table: "wms_containers",
column: "Code",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_wms_material_types_Code",
table: "wms_material_types",
column: "Code",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_wms_materials_Barcode",
table: "wms_materials",
column: "Barcode");
migrationBuilder.CreateIndex(
name: "IX_wms_materials_Code",
table: "wms_materials",
column: "Code",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_wms_materials_LifecycleStatus_UpdatedAt",
table: "wms_materials",
columns: new[] { "LifecycleStatus", "UpdatedAt" });
migrationBuilder.CreateIndex(
name: "IX_wms_materials_TypeCode",
table: "wms_materials",
column: "TypeCode");
migrationBuilder.CreateIndex(
name: "IX_wms_stock_events_ContainerId",
table: "wms_stock_events",
column: "ContainerId");
migrationBuilder.CreateIndex(
name: "IX_wms_stock_events_EventType",
table: "wms_stock_events",
column: "EventType");
migrationBuilder.CreateIndex(
name: "IX_wms_stock_events_MaterialId",
table: "wms_stock_events",
column: "MaterialId");
migrationBuilder.CreateIndex(
name: "IX_wms_stock_events_OperatedAt",
table: "wms_stock_events",
column: "OperatedAt");
migrationBuilder.CreateIndex(
name: "IX_wms_storages_AreaId",
table: "wms_storages",
column: "AreaId");
migrationBuilder.CreateIndex(
name: "IX_wms_storages_Barcode",
table: "wms_storages",
column: "Barcode");
migrationBuilder.CreateIndex(
name: "IX_wms_storages_Code",
table: "wms_storages",
column: "Code",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_wms_transport_reservations_ContainerId_Status",
table: "wms_transport_reservations",
columns: new[] { "ContainerId", "Status" });
migrationBuilder.CreateIndex(
name: "IX_wms_transport_reservations_TargetStorageId_Status",
table: "wms_transport_reservations",
columns: new[] { "TargetStorageId", "Status" });
migrationBuilder.CreateIndex(
name: "IX_wms_transport_rules_Code",
table: "wms_transport_rules",
column: "Code",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_wms_transport_rules_TriggerType_Enabled_Priority",
table: "wms_transport_rules",
columns: new[] { "TriggerType", "Enabled", "Priority" });
migrationBuilder.CreateIndex(
name: "IX_wms_transport_task_history_OperatedAt",
table: "wms_transport_task_history",
column: "OperatedAt");
migrationBuilder.CreateIndex(
name: "IX_wms_transport_task_history_TaskId",
table: "wms_transport_task_history",
column: "TaskId");
migrationBuilder.CreateIndex(
name: "IX_wms_transport_tasks_ContainerId",
table: "wms_transport_tasks",
column: "ContainerId");
migrationBuilder.CreateIndex(
name: "IX_wms_transport_tasks_Status",
table: "wms_transport_tasks",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_wms_transport_tasks_TargetStorageId",
table: "wms_transport_tasks",
column: "TargetStorageId");
migrationBuilder.CreateIndex(
name: "IX_wms_warehouses_Code",
table: "wms_warehouses",
column: "Code",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "simple_fields");
migrationBuilder.DropTable(
name: "user_dashboard_shortcuts");
migrationBuilder.DropTable(
name: "wms_areas");
migrationBuilder.DropTable(
name: "wms_container_location_history");
migrationBuilder.DropTable(
name: "wms_container_locations");
migrationBuilder.DropTable(
name: "wms_container_material_history");
migrationBuilder.DropTable(
name: "wms_container_materials");
migrationBuilder.DropTable(
name: "wms_containers");
migrationBuilder.DropTable(
name: "wms_material_types");
migrationBuilder.DropTable(
name: "wms_materials");
migrationBuilder.DropTable(
name: "wms_stock_events");
migrationBuilder.DropTable(
name: "wms_storages");
migrationBuilder.DropTable(
name: "wms_transport_reservations");
migrationBuilder.DropTable(
name: "wms_transport_rules");
migrationBuilder.DropTable(
name: "wms_transport_task_history");
migrationBuilder.DropTable(
name: "wms_transport_tasks");
migrationBuilder.DropTable(
name: "wms_warehouses");
}
}
}