|
|
@@ -1,9 +1,11 @@
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
+using Quadarax.Foundation.Core.Data.Domain;
|
|
|
+using System.Reflection.Emit;
|
|
|
|
|
|
namespace qdr.app.bundleboiler.data.Model
|
|
|
{
|
|
|
- public class BoilerDbContext : DbContext
|
|
|
+ public class BoilerDbContext : DataDomain
|
|
|
{
|
|
|
public BoilerDbContext(DbContextOptions<BoilerDbContext> options) : base(options)
|
|
|
{
|
|
|
@@ -30,10 +32,14 @@ namespace qdr.app.bundleboiler.data.Model
|
|
|
modelBuilder.Entity<Attachment>(BuildAttachment);
|
|
|
modelBuilder.Entity<AttributeCategory>(BuildAttributeCategory);
|
|
|
modelBuilder.Entity<Bundle>(BuildBundle);
|
|
|
+ modelBuilder.Entity<BundleForkHash>(BuildBundleForkHash);
|
|
|
+ modelBuilder.Entity<BundleEnvironmentHash>(BuildBundleEnvironmentHash);
|
|
|
modelBuilder.Entity<BundleAttribute>(BuildBundleAttribute);
|
|
|
modelBuilder.Entity<Enumeration>(BuildEnumeration);
|
|
|
modelBuilder.Entity<Project>(BuildProject);
|
|
|
modelBuilder.Entity<Realization>(BuildRealization);
|
|
|
+ modelBuilder.Entity<RealizationForkHash>(BuildRealizationForkHash);
|
|
|
+ modelBuilder.Entity<RealizationEnvironmentHash>(BuildRealizationEnvironmentHash);
|
|
|
}
|
|
|
|
|
|
private void BuildActivity(EntityTypeBuilder<Activity> builder)
|
|
|
@@ -54,7 +60,7 @@ namespace qdr.app.bundleboiler.data.Model
|
|
|
builder.Property(x => x.VersionCode).IsRequired().HasMaxLength(20);
|
|
|
builder.Property(x => x.Description).HasMaxLength(500);
|
|
|
builder.Property(x => x.OrderNo).IsRequired();
|
|
|
- builder.HasOne(x => x.Type).WithMany().IsRequired();
|
|
|
+ builder.HasOne(x => x.Type).WithMany().IsRequired().OnDelete(DeleteBehavior.NoAction);
|
|
|
builder.HasOne(x => x.Parent)
|
|
|
.WithMany(x => x.Artifacts)
|
|
|
.IsRequired();
|
|
|
@@ -104,34 +110,66 @@ namespace qdr.app.bundleboiler.data.Model
|
|
|
builder.Property(x => x.VersionMajor).IsRequired();
|
|
|
builder.Property(x => x.VersionMinor).IsRequired();
|
|
|
builder.Property(x => x.VersionRevision).IsRequired();
|
|
|
-
|
|
|
+
|
|
|
builder.HasOne(x => x.BundleType)
|
|
|
.WithMany()
|
|
|
- .IsRequired();
|
|
|
-
|
|
|
+ .IsRequired().OnDelete(DeleteBehavior.NoAction);
|
|
|
+
|
|
|
builder.HasMany(x => x.Artifacts)
|
|
|
.WithOne(x => x.Parent)
|
|
|
.IsRequired();
|
|
|
-
|
|
|
+
|
|
|
builder.HasMany(x => x.Attributes)
|
|
|
.WithOne(x => x.Owner)
|
|
|
.IsRequired();
|
|
|
-
|
|
|
+
|
|
|
builder.HasMany(x => x.Realizations)
|
|
|
.WithOne(x => x.Parent)
|
|
|
.IsRequired();
|
|
|
-
|
|
|
+
|
|
|
+ builder.HasMany(r => r.Forks)
|
|
|
+ .WithMany()
|
|
|
+ .UsingEntity<BundleForkHash>();
|
|
|
+
|
|
|
builder.HasMany(x => x.Environments)
|
|
|
- .WithMany();
|
|
|
-
|
|
|
- builder.HasMany(x => x.Forks)
|
|
|
- .WithMany();
|
|
|
-
|
|
|
+ .WithMany()
|
|
|
+ .UsingEntity<BundleEnvironmentHash>();
|
|
|
+
|
|
|
builder.HasOne(x => x.Follows)
|
|
|
.WithMany(x => x.Covers)
|
|
|
.IsRequired(false);
|
|
|
}
|
|
|
|
|
|
+ private void BuildBundleForkHash(EntityTypeBuilder<BundleForkHash> builder)
|
|
|
+ {
|
|
|
+ builder.HasKey(rf => new { rf.BundleId, rf.EnumerationId });
|
|
|
+
|
|
|
+ builder.HasOne(rf => rf.Bundle)
|
|
|
+ .WithMany()
|
|
|
+ .HasForeignKey(rf => rf.BundleId)
|
|
|
+ .OnDelete(DeleteBehavior.NoAction);
|
|
|
+
|
|
|
+ builder.HasOne(rf => rf.Enumeration)
|
|
|
+ .WithMany()
|
|
|
+ .HasForeignKey(rf => rf.EnumerationId)
|
|
|
+ .OnDelete(DeleteBehavior.NoAction);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void BuildBundleEnvironmentHash(EntityTypeBuilder<BundleEnvironmentHash> builder)
|
|
|
+ {
|
|
|
+ builder.HasKey(rf => new { rf.BundleId, rf.EnumerationId });
|
|
|
+
|
|
|
+ builder.HasOne(rf => rf.Bundle)
|
|
|
+ .WithMany()
|
|
|
+ .HasForeignKey(rf => rf.BundleId)
|
|
|
+ .OnDelete(DeleteBehavior.NoAction);
|
|
|
+
|
|
|
+ builder.HasOne(rf => rf.Enumeration)
|
|
|
+ .WithMany()
|
|
|
+ .HasForeignKey(rf => rf.EnumerationId)
|
|
|
+ .OnDelete(DeleteBehavior.NoAction);
|
|
|
+ }
|
|
|
+
|
|
|
private void BuildBundleAttribute(EntityTypeBuilder<BundleAttribute> builder)
|
|
|
{
|
|
|
builder.HasKey(x => x.Id);
|
|
|
@@ -169,24 +207,56 @@ namespace qdr.app.bundleboiler.data.Model
|
|
|
builder.HasKey(x => x.Id);
|
|
|
builder.Property(x => x.Merged).IsRequired();
|
|
|
builder.Property(x => x.MergedToLinkSCM).HasMaxLength(500);
|
|
|
-
|
|
|
+
|
|
|
builder.HasOne(x => x.Parent)
|
|
|
.WithMany(x => x.Realizations)
|
|
|
.IsRequired();
|
|
|
-
|
|
|
+
|
|
|
builder.HasMany(x => x.Attachments)
|
|
|
.WithOne(x => x.Parent)
|
|
|
- .IsRequired();
|
|
|
-
|
|
|
- builder.HasMany(x => x.Forks)
|
|
|
- .WithMany();
|
|
|
-
|
|
|
+ .IsRequired();
|
|
|
+
|
|
|
+ builder.HasMany(r => r.Forks)
|
|
|
+ .WithMany()
|
|
|
+ .UsingEntity<RealizationForkHash>();
|
|
|
+
|
|
|
builder.HasMany(x => x.Environments)
|
|
|
- .WithMany();
|
|
|
-
|
|
|
+ .WithMany()
|
|
|
+ .UsingEntity<RealizationEnvironmentHash>();
|
|
|
+
|
|
|
builder.HasOne(x => x.BundleType)
|
|
|
.WithMany()
|
|
|
.IsRequired();
|
|
|
}
|
|
|
+
|
|
|
+ private void BuildRealizationForkHash(EntityTypeBuilder<RealizationForkHash> builder)
|
|
|
+ {
|
|
|
+ builder.HasKey(rf => new { rf.RealizationId, rf.EnumerationId });
|
|
|
+
|
|
|
+ builder.HasOne(rf => rf.Realization)
|
|
|
+ .WithMany()
|
|
|
+ .HasForeignKey(rf => rf.RealizationId)
|
|
|
+ .OnDelete(DeleteBehavior.NoAction);
|
|
|
+
|
|
|
+ builder.HasOne(rf => rf.Enumeration)
|
|
|
+ .WithMany()
|
|
|
+ .HasForeignKey(rf => rf.EnumerationId)
|
|
|
+ .OnDelete(DeleteBehavior.NoAction);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void BuildRealizationEnvironmentHash(EntityTypeBuilder<RealizationEnvironmentHash> builder)
|
|
|
+ {
|
|
|
+ builder.HasKey(rf => new { rf.RealizationId, rf.EnumerationId });
|
|
|
+
|
|
|
+ builder.HasOne(rf => rf.Realization)
|
|
|
+ .WithMany()
|
|
|
+ .HasForeignKey(rf => rf.RealizationId)
|
|
|
+ .OnDelete(DeleteBehavior.NoAction);
|
|
|
+
|
|
|
+ builder.HasOne(rf => rf.Enumeration)
|
|
|
+ .WithMany()
|
|
|
+ .HasForeignKey(rf => rf.EnumerationId)
|
|
|
+ .OnDelete(DeleteBehavior.NoAction);
|
|
|
+ }
|
|
|
}
|
|
|
}
|