Added milestone entity
This commit is contained in:
@@ -0,0 +1,37 @@
|
|||||||
|
namespace PostFundManagement.Domain.Configuration;
|
||||||
|
|
||||||
|
public sealed class Milestone : IEntityTypeConfiguration<Entities.Milestone>
|
||||||
|
{
|
||||||
|
public void Configure(EntityTypeBuilder<Entities.Milestone> builder)
|
||||||
|
{
|
||||||
|
builder.ToTable(nameof(Entities.Milestone).Pluralize());
|
||||||
|
|
||||||
|
builder.HasKey(pk => pk.Id);
|
||||||
|
builder.Property(f => f.ProjectId).IsRequired();
|
||||||
|
builder.Property(f => f.CreatedBy).IsRequired();
|
||||||
|
builder.Property(f => f.UpdatedBy).IsRequired(false);
|
||||||
|
builder.Property(f => f.CreatedAt).IsRequired().HasDefaultValueSql("now()");
|
||||||
|
builder.Property(f => f.UpdatedAt).IsRequired(false);
|
||||||
|
builder.Property(f => f.DueAt).IsRequired();
|
||||||
|
builder.Property(f => f.Name).IsRequired().HasMaxLength(256);
|
||||||
|
builder.Property(f => f.Status).HasDefaultValue(ApprovalStatus.Pending);
|
||||||
|
|
||||||
|
builder.HasOne(f => f.Project)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(fk => fk.ProjectId)
|
||||||
|
.IsRequired()
|
||||||
|
.OnDelete(DeleteBehavior.Restrict);
|
||||||
|
|
||||||
|
builder.HasOne(f => f.Creator)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(fk => fk.CreatedBy)
|
||||||
|
.IsRequired()
|
||||||
|
.OnDelete(DeleteBehavior.NoAction);
|
||||||
|
|
||||||
|
builder.HasOne(f => f.Updator)
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey(fk => fk.UpdatedBy)
|
||||||
|
.IsRequired(false)
|
||||||
|
.OnDelete(DeleteBehavior.NoAction);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace PostFundManagement.Domain.Entities;
|
||||||
|
|
||||||
|
[EntityTypeConfiguration<Configuration.Milestone, Milestone>]
|
||||||
|
public class Milestone : Models.Milestone
|
||||||
|
{
|
||||||
|
public virtual Project? Project { get; set; }
|
||||||
|
|
||||||
|
public virtual User? Creator { get; set; }
|
||||||
|
|
||||||
|
public virtual User? Updator { get; set; }
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@ namespace PostFundManagement.Infrastructure.Database;
|
|||||||
|
|
||||||
public sealed class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : DbContext(options)
|
public sealed class ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : DbContext(options)
|
||||||
{
|
{
|
||||||
|
public DbSet<Milestone> Milestones => Set<Milestone>();
|
||||||
|
|
||||||
public DbSet<Budget> Budgets => Set<Budget>();
|
public DbSet<Budget> Budgets => Set<Budget>();
|
||||||
|
|
||||||
public DbSet<Contract> Contracts => Set<Contract>();
|
public DbSet<Contract> Contracts => Set<Contract>();
|
||||||
|
|||||||
Reference in New Issue
Block a user