Skip to content

Commit

Permalink
Squash migrations and move configuration into dedicated entity config…
Browse files Browse the repository at this point in the history
…uration files
  • Loading branch information
rmaffitsancsoft committed Jan 13, 2025
1 parent 849a5b7 commit b954345
Show file tree
Hide file tree
Showing 27 changed files with 142 additions and 13,134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ public override void Configure(EntityTypeBuilder<Project> builder)

builder.HasIndex(t => t.ProjectNumber)
.IsUnique();

builder
.HasIndex(p => new { p.ClientId, p.ProjectManagerId });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@ public override void Configure(EntityTypeBuilder<ProjectStatusReport> builder)
base.Configure(builder);

builder.ToTable("project_status_reports");

builder
.HasIndex(p => new { p.ProjectId, p.StartDate, p.EndDate })
.IsDescending([false, true, true]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ public override void Configure(EntityTypeBuilder<Staff> builder)

builder.ToTable("staff");

builder.HasIndex(t => t.Name)
builder
.HasMany(t => t.Times)
.WithOne(s => s.Staff)
.HasForeignKey(t => t.StaffId);

builder
.HasIndex(t => t.Name)
.IsUnique();
}
}
13 changes: 13 additions & 0 deletions src/dotnet/HQ.Server/Data/Configuration/TimeConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,18 @@ public override void Configure(EntityTypeBuilder<Time> builder)
base.Configure(builder);

builder.ToTable("times");

builder
.HasIndex(t => t.Date)
.IsDescending();

builder
.HasIndex(t => new { t.ChargeCodeId, t.Status, t.Date })
.IsDescending([false, false, true]);

builder
.HasIndex(t => new { t.ChargeCodeId, t.Date })
.IncludeProperties(t => new { t.Hours, t.HoursApproved })
.IsDescending([false, true]);
}
}
7 changes: 0 additions & 7 deletions src/dotnet/HQ.Server/Data/HQDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,7 @@ public HQDbContext(DbContextOptions<HQDbContext> options)

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Staff>().HasMany(t => t.Times).WithOne(s => s.Staff).HasForeignKey(t => t.StaffId);
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetExecutingAssembly());
modelBuilder.Entity<Time>().HasIndex(t => t.Date).HasDatabaseName("idx_time_date");
modelBuilder.Entity<Time>().HasIndex(t => new { t.ChargeCodeId, t.Status, t.Date }).HasDatabaseName("idx_time_chargecodeid_status_date");
modelBuilder.Entity<Time>().HasIndex(t => new { t.ChargeCodeId, t.Date }).IncludeProperties(t => new { t.Hours, t.HoursApproved }).HasDatabaseName("idx_time_chargecodeid__date");

modelBuilder.Entity<ProjectStatusReport>().HasIndex(p => new { p.ProjectId, p.StartDate, p.EndDate }).HasDatabaseName("idx_psr_projectid_startdate_enddate");
modelBuilder.Entity<Project>().HasIndex(p => new { p.ClientId, p.ProjectManagerId }).HasDatabaseName("idx_project_clientid_projectmanagerid");

base.OnModelCreating(modelBuilder);
}
Expand Down
Loading

0 comments on commit b954345

Please sign in to comment.