feat(data): add ClaudeDoDbContext with Fluent API configurations
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using ClaudeDo.Data.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
||||
|
||||
namespace ClaudeDo.Data.Configuration;
|
||||
|
||||
public class WorktreeEntityConfiguration : IEntityTypeConfiguration<WorktreeEntity>
|
||||
{
|
||||
public void Configure(EntityTypeBuilder<WorktreeEntity> builder)
|
||||
{
|
||||
builder.ToTable("worktrees");
|
||||
|
||||
builder.HasKey(w => w.TaskId);
|
||||
builder.Property(w => w.TaskId).HasColumnName("task_id");
|
||||
builder.Property(w => w.Path).HasColumnName("path").IsRequired();
|
||||
builder.Property(w => w.BranchName).HasColumnName("branch_name").IsRequired();
|
||||
builder.Property(w => w.BaseCommit).HasColumnName("base_commit").IsRequired();
|
||||
builder.Property(w => w.HeadCommit).HasColumnName("head_commit");
|
||||
builder.Property(w => w.DiffStat).HasColumnName("diff_stat");
|
||||
builder.Property(w => w.State).HasColumnName("state").IsRequired()
|
||||
.HasDefaultValue(WorktreeState.Active)
|
||||
.HasConversion(
|
||||
v => v switch
|
||||
{
|
||||
WorktreeState.Active => "active",
|
||||
WorktreeState.Merged => "merged",
|
||||
WorktreeState.Discarded => "discarded",
|
||||
WorktreeState.Kept => "kept",
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
},
|
||||
v => v switch
|
||||
{
|
||||
"active" => WorktreeState.Active,
|
||||
"merged" => WorktreeState.Merged,
|
||||
"discarded" => WorktreeState.Discarded,
|
||||
"kept" => WorktreeState.Kept,
|
||||
_ => throw new ArgumentOutOfRangeException()
|
||||
});
|
||||
builder.Property(w => w.CreatedAt).HasColumnName("created_at").IsRequired();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user