RobotTaskHistoryConfiguration.cs
3.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Rcs.Domain.Entities;
namespace Rcs.Infrastructure.DB.Configuration.Domain;
/// <summary>
/// RobotTaskHistory 实体 EF Core 配置
/// </summary>
public class RobotTaskHistoryConfiguration : IEntityTypeConfiguration<RobotTaskHistory>
{
public void Configure(EntityTypeBuilder<RobotTaskHistory> builder)
{
builder.ToTable("robot_task_histories");
builder.HasKey(e => e.TaskId);
builder.Property(e => e.TaskId)
.HasColumnName("task_id")
.ValueGeneratedNever();
builder.Property(e => e.TaskCode)
.HasColumnName("task_code")
.HasMaxLength(50)
.IsRequired();
builder.Property(e => e.TaskName)
.HasColumnName("task_name")
.HasMaxLength(100);
builder.Property(e => e.RobotCode)
.HasColumnName("robot_code")
.HasMaxLength(50);
builder.Property(e => e.TaskTemplateCode)
.HasColumnName("task_template_code")
.HasMaxLength(50);
builder.Property(e => e.BeginLocationCode)
.HasColumnName("begin_location_code")
.HasMaxLength(50);
builder.Property(e => e.EndLocationCode)
.HasColumnName("end_location_code")
.HasMaxLength(50);
builder.Property(e => e.Status)
.HasColumnName("status")
.IsRequired();
builder.Property(e => e.Pause)
.HasColumnName("pause")
.HasDefaultValue(false);
builder.Property(e => e.Priority)
.HasColumnName("priority")
.HasDefaultValue(99);
builder.Property(e => e.Source)
.HasColumnName("source")
.HasMaxLength(300);
builder.Property(e => e.Relation)
.HasColumnName("relation")
.HasMaxLength(300);
builder.Property(e => e.ShelfCode)
.HasColumnName("shelf_code")
.HasMaxLength(50);
builder.Property(e => e.ContainerID)
.HasColumnName("container_id")
.HasMaxLength(50);
builder.Property(e => e.ErrorInfo)
.HasColumnName("error_info")
.HasColumnType("text");
builder.Property(e => e.CreatedAt)
.HasColumnName("created_at")
.HasColumnType("timestamp without time zone")
.IsRequired();
builder.Property(e => e.UpdatedAt)
.HasColumnName("updated_at")
.HasColumnType("timestamp without time zone");
builder.Property(e => e.ArchivedAt)
.HasColumnName("archived_at")
.HasColumnType("timestamp without time zone")
.IsRequired();
builder.HasAlternateKey(e => e.TaskCode)
.HasName("ak_task_history_task_code");
builder.HasIndex(e => e.TaskCode)
.HasDatabaseName("idx_task_history_task_code");
builder.HasIndex(e => e.Status)
.HasDatabaseName("idx_task_history_status");
builder.HasIndex(e => e.RobotCode)
.HasDatabaseName("idx_task_history_robot_code");
builder.HasIndex(e => e.BeginLocationCode)
.HasDatabaseName("idx_task_history_begin_location_code");
builder.HasIndex(e => e.EndLocationCode)
.HasDatabaseName("idx_task_history_end_location_code");
builder.HasIndex(e => e.ArchivedAt)
.HasDatabaseName("idx_task_history_archived_at");
builder.HasMany(e => e.SubTaskHistories)
.WithOne(e => e.TaskHistory)
.HasForeignKey(e => e.TaskCode)
.HasPrincipalKey(e => e.TaskCode)
.OnDelete(DeleteBehavior.Cascade);
}
}