Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions database/data/Scripts/Script.PreDeployment.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/*
Pre-deployment cleanup for objects intentionally removed from the data DACPAC.
*/

-- The segment hierarchy tables were replaced by reading breadcrumbs from
-- ChartSegments. Their rows were seeded copies, so clearing them lets the
-- publish drop the tables without tripping BlockOnPossibleDataLoss.
IF OBJECT_ID(N'[data].[AccountHierarchy]', N'U') IS NOT NULL DELETE FROM [data].[AccountHierarchy];
IF OBJECT_ID(N'[data].[ActivityHierarchy]', N'U') IS NOT NULL DELETE FROM [data].[ActivityHierarchy];
IF OBJECT_ID(N'[data].[DepartmentHierarchy]', N'U') IS NOT NULL DELETE FROM [data].[DepartmentHierarchy];
IF OBJECT_ID(N'[data].[FundHierarchy]', N'U') IS NOT NULL DELETE FROM [data].[FundHierarchy];
IF OBJECT_ID(N'[data].[PurposeHierarchy]', N'U') IS NOT NULL DELETE FROM [data].[PurposeHierarchy];
GO
19 changes: 0 additions & 19 deletions database/data/Tables/AccountHierarchy.sql

This file was deleted.

19 changes: 0 additions & 19 deletions database/data/Tables/ActivityHierarchy.sql

This file was deleted.

21 changes: 0 additions & 21 deletions database/data/Tables/DepartmentHierarchy.sql

This file was deleted.

19 changes: 0 additions & 19 deletions database/data/Tables/FundHierarchy.sql

This file was deleted.

19 changes: 0 additions & 19 deletions database/data/Tables/PurposeHierarchy.sql

This file was deleted.

35 changes: 0 additions & 35 deletions server.core/Data/DataDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ public class DataDbContext(DbContextOptions<DataDbContext> options) : DbContext(
public DbSet<Project> Projects => Set<Project>();
public DbSet<ChartSegment> ChartSegments => Set<ChartSegment>();

public DbSet<DepartmentHierarchy> DepartmentHierarchies => Set<DepartmentHierarchy>();
public DbSet<AccountHierarchy> AccountHierarchies => Set<AccountHierarchy>();
public DbSet<FundHierarchy> FundHierarchies => Set<FundHierarchy>();
public DbSet<ActivityHierarchy> ActivityHierarchies => Set<ActivityHierarchy>();
public DbSet<PurposeHierarchy> PurposeHierarchies => Set<PurposeHierarchy>();

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
Expand Down Expand Up @@ -104,35 +99,5 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.Property(p => p.NifaProjectNumber).HasMaxLength(20);
entity.Property(p => p.ProjectDirector).HasMaxLength(200);
});

ConfigureHierarchy<DepartmentHierarchy>(modelBuilder, "DepartmentHierarchy");
ConfigureHierarchy<AccountHierarchy>(modelBuilder, "AccountHierarchy");
ConfigureHierarchy<FundHierarchy>(modelBuilder, "FundHierarchy");
ConfigureHierarchy<ActivityHierarchy>(modelBuilder, "ActivityHierarchy");
ConfigureHierarchy<PurposeHierarchy>(modelBuilder, "PurposeHierarchy");
}

private static void ConfigureHierarchy<T>(ModelBuilder modelBuilder, string table)
where T : class, ISegmentHierarchy
{
modelBuilder.Entity<T>(entity =>
{
entity.ToTable(table, DataSchema, mapping => mapping.ExcludeFromMigrations());
entity.HasKey(e => e.Code);

foreach (var property in entity.Metadata.GetProperties()
.Where(p => p.ClrType == typeof(string)))
{
var maxLength = property.Name switch
{
// Match SegmentClassification.Code so joins/lookups on Code stay aligned.
nameof(ISegmentHierarchy.Code) => 50,
"Description" => 1000,
_ when property.Name.EndsWith("Name") => 1000,
_ => 20,
};
property.SetMaxLength(maxLength);
}
});
}
}
2 changes: 0 additions & 2 deletions server.core/Data/DbInitializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ public async Task InitializeAsync(bool includeDevSeed, CancellationToken cancell

private async Task SeedDevelopmentAsync(CancellationToken ct)
{
// Hierarchy first: chart-string segments are derived from the hierarchy tables.
await HierarchySeed.EnsureSeededAsync(_dataDb, ct);
await SegmentClassificationSeed.EnsureSeededAsync(_dataDb, ct);
}

Expand Down
128 changes: 0 additions & 128 deletions server.core/Data/HierarchySeed.cs

This file was deleted.

Loading
Loading