diff --git a/Hippo.Core/Data/AppDbContext.cs b/Hippo.Core/Data/AppDbContext.cs index 45b8fd25..fd61e893 100644 --- a/Hippo.Core/Data/AppDbContext.cs +++ b/Hippo.Core/Data/AppDbContext.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -41,6 +41,12 @@ protected AppDbContext(DbContextOptions options) : base(options) public virtual DbSet TempKerberos { get; set; } public virtual DbSet QueuedEvents { get; set; } public virtual DbSet AccessTypes { get; set; } + public virtual DbSet FinancialDetails { get; set; } + public virtual DbSet Products { get; set; } + public virtual DbSet Orders { get; set; } + public virtual DbSet Billings { get; set; } + public virtual DbSet MetaData { get; set; } + public virtual DbSet Payments { get; set; } protected override void OnModelCreating(ModelBuilder builder) { @@ -57,6 +63,11 @@ protected override void OnModelCreating(ModelBuilder builder) Domain.GroupMemberAccount.OnModelCreating(builder); QueuedEvent.OnModelCreating(builder, this); AccessType.OnModelCreating(builder); + FinancialDetail.OnModelCreating(builder); + Product.OnModelCreating(builder); + OrderMetaData.OnModelCreating(builder); + Order.OnModelCreating(builder); + Payment.OnModelCreating(builder); TempGroup.OnModelCreating(builder); Domain.TempKerberos.OnModelCreating(builder); } diff --git a/Hippo.Core/Domain/Account.cs b/Hippo.Core/Domain/Account.cs index 2d27ef0d..72b6fbbe 100644 --- a/Hippo.Core/Domain/Account.cs +++ b/Hippo.Core/Domain/Account.cs @@ -60,7 +60,10 @@ public Account() [JsonIgnore] public List AccessTypes { get; set; } = new(); - + + [JsonIgnore] + public List Orders { get; set; } = new(); + internal static void OnModelCreating(ModelBuilder modelBuilder, DbContext dbContext) { modelBuilder.Entity().HasQueryFilter(a => a.Cluster.IsActive); diff --git a/Hippo.Core/Domain/Billing.cs b/Hippo.Core/Domain/Billing.cs new file mode 100644 index 00000000..dd6c71e1 --- /dev/null +++ b/Hippo.Core/Domain/Billing.cs @@ -0,0 +1,20 @@ +using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; + +namespace Hippo.Core.Domain +{ + public class Billing + { + [Key] + public int Id { get; set; } + [Required] + [MaxLength(128)] + public string ChartString { get; set; } + public decimal Percentage { get; set; } = 100; + [Required] + public int OrderId { get; set; } + [JsonIgnore] + public Order Order { get; set; } + public DateTime Updated { get; set; } = DateTime.UtcNow; + } +} diff --git a/Hippo.Core/Domain/Cluster.cs b/Hippo.Core/Domain/Cluster.cs index bb0770b1..4a2bd858 100644 --- a/Hippo.Core/Domain/Cluster.cs +++ b/Hippo.Core/Domain/Cluster.cs @@ -44,6 +44,15 @@ public class Cluster [MinLength(1)] public List AccessTypes { get; set; } = new(); + [JsonIgnore] + public FinancialDetail FinancialDetail { get; set; } + + [JsonIgnore] + public List Products { get; set; } = new(); + + [JsonIgnore] + public List Orders { get; set; } = new(); + internal static void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity().HasQueryFilter(a => a.IsActive); @@ -67,6 +76,24 @@ internal static void OnModelCreating(ModelBuilder modelBuilder) .WithMany() .HasForeignKey(p => p.ClusterId) .OnDelete(DeleteBehavior.Restrict); + + // Cluster has a one to one relationship with FinancialDetail where the financial detail is nullable + modelBuilder.Entity() + .HasOne(c => c.FinancialDetail) + .WithOne(c => c.Cluster) + .HasForeignKey(fd => fd.ClusterId) + .OnDelete(DeleteBehavior.Restrict); + + modelBuilder.Entity() + .HasOne(p => p.Cluster) + .WithMany(c => c.Products) + .HasForeignKey(p => p.ClusterId) + .OnDelete(DeleteBehavior.Restrict); + modelBuilder.Entity() + .HasOne(o => o.Cluster) + .WithMany(c => c.Orders) + .HasForeignKey(o => o.ClusterId) + .OnDelete(DeleteBehavior.Restrict); } } } diff --git a/Hippo.Core/Domain/FinancialDetail.cs b/Hippo.Core/Domain/FinancialDetail.cs new file mode 100644 index 00000000..0ff23595 --- /dev/null +++ b/Hippo.Core/Domain/FinancialDetail.cs @@ -0,0 +1,27 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; + +namespace Hippo.Core.Domain +{ + public class FinancialDetail + { + [Key] + public int Id { get; set; } + [MaxLength(200)] + public string SecretAccessKey { get; set; } //Used to get the FinancialSystemApiKey from the secret service + [Required] + [MaxLength(50)] + public string FinancialSystemApiSource { get; set; } + [MaxLength(128)] + public string ChartString { get; set; } + public bool AutoApprove { get; set; } + [Required] + public int ClusterId { get; set; } + public Cluster Cluster { get; set; } + + internal static void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().Property(a => a.AutoApprove).HasDefaultValue(true); + } + } +} diff --git a/Hippo.Core/Domain/History.cs b/Hippo.Core/Domain/History.cs index 1918f7cf..b637dbb5 100644 --- a/Hippo.Core/Domain/History.cs +++ b/Hippo.Core/Domain/History.cs @@ -32,17 +32,26 @@ public History() public int? ClusterId { get; set; } //When we have a cluster identifier public Cluster Cluster { get; set; } + public int? OrderId { get; set; } + public Order Order { get; set; } + [MaxLength(50)] public string Status { get; set; } + [MaxLength(50)] + public string Type { get; set; } = HistoryTypes.Detail; + internal static void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity().HasQueryFilter(h => h.Cluster == null || h.Cluster.IsActive); modelBuilder.Entity().HasIndex(h => h.ActedDate); modelBuilder.Entity().HasIndex(h => h.Action); modelBuilder.Entity().HasIndex(h => h.ClusterId); + modelBuilder.Entity().HasIndex(h => h.Type); + modelBuilder.Entity().HasIndex(h => h.OrderId); modelBuilder.Entity().HasOne(h => h.ActedBy).WithMany().HasForeignKey(a => a.ActedById).OnDelete(DeleteBehavior.Restrict); modelBuilder.Entity().HasOne(h => h.Cluster).WithMany().HasForeignKey(a => a.ClusterId).OnDelete(DeleteBehavior.Restrict); + modelBuilder.Entity().HasOne(h => h.Order).WithMany(o => o.History).HasForeignKey(a => a.OrderId).OnDelete(DeleteBehavior.Restrict); } public class Actions @@ -75,5 +84,47 @@ public class Actions }.ToList(); } + + public class OrderActions + { + public const string Created = "Created"; + public const string Updated = "Updated"; + public const string Submitted = "Submitted"; + public const string Processing = "Processing"; + public const string Cancelled = "Cancelled"; + public const string Active = "Active"; + public const string Rejected = "Rejected"; + public const string Completed = "Completed"; + public const string AdhocPayment = "Adhoc Payment"; + public const string ChartStringUpdated = "Chart String Updated"; + public const string PaymentFailed = "Payment Failed"; + + public static List OrderActionList = new List + { + Created, + Updated, + Submitted, + Processing, + Cancelled, + Active, + Rejected, + Completed, + AdhocPayment, + ChartStringUpdated, + PaymentFailed + }.ToList(); + } + + public class HistoryTypes + { + public const string Primary = "Primary"; + public const string Detail = "Detail"; + + public static List TypeList = new List + { + Primary, + Detail + }.ToList(); + } } } diff --git a/Hippo.Core/Domain/Order.cs b/Hippo.Core/Domain/Order.cs new file mode 100644 index 00000000..147bd0d5 --- /dev/null +++ b/Hippo.Core/Domain/Order.cs @@ -0,0 +1,111 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; +using static Hippo.Core.Domain.Product; + +namespace Hippo.Core.Domain +{ + public class Order :ProductBase + { + + [Required] + [MaxLength(50)] + public string ProductName { get; set; } + + [MaxLength(150)] + public string ExternalReference { get; set; } + + [Required] + [Range(0.0001, double.MaxValue)] + public decimal Quantity { get; set; } + + public decimal Adjustment { get; set; } + public string AdjustmentReason { get; set; } + public decimal SubTotal { get; set; } + public decimal Total { get; set; } + public decimal BalanceRemaining { get; set; } //We will also calculate this when we do a payment + public string Notes { get; set; } + public string AdminNotes { get; set; } + [MaxLength(20)] + public string Status { get; set; } + + public DateTime? InstallmentDate { get; set; } + public DateTime? ExpirationDate { get; set; } //This would default to InstallmentDate + LifeCycle Months + + public DateTime? NextPaymentDate { get; set; } //When we start payments, this will be set to trigger the auto creation of a payment. Onetime=tomorrow, Monthly=1st of next month, yearly= jan 1st of next year. + + public DateTime? NextNotificationDate { get; set; } //This will be used to send notification to the sponsor once the ExpirationDate is reached. This will be set to ExpirationDate - 30 days? + + public decimal InstallmentAmount => Math.Round(Total / Installments, 2); + + [Required] + public int ClusterId { get; set; } + [JsonIgnore] + public Cluster Cluster { get; set; } + + + [Required] + public int PrincipalInvestigatorId { get; set; } + public Account PrincipalInvestigator { get; set; } + + public DateTime CreatedOn { get; set; } = DateTime.UtcNow; + + public List Billings { get; set; } = new(); + + public List MetaData { get; set; } = new(); + + public void AddMetaData(string key, string value) + { + MetaData.Add(new OrderMetaData { Name = key, Value = value, Order = this }); + } + [JsonIgnore] + public List Payments { get; set; } = new(); + + [JsonIgnore] + public List History { get; set; } = new(); + + public class Statuses + { + public const string Created = "Created"; + public const string Submitted = "Submitted"; + public const string Processing = "Processing"; + public const string Cancelled = "Cancelled"; + public const string Active = "Active"; + public const string Rejected = "Rejected"; //Not sure if we need this + public const string Completed = "Completed"; + + public static List StatusTypes = new List + { + Created, + Submitted, + Processing, + Cancelled, + Active, + Rejected, + Completed + }; + } + internal static void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasQueryFilter(o => o.Cluster.IsActive); + modelBuilder.Entity().HasIndex(o => o.PrincipalInvestigatorId); + modelBuilder.Entity().HasIndex(o => o.ClusterId); + modelBuilder.Entity().HasIndex(o => o.Status); + modelBuilder.Entity().HasIndex(o => o.ExpirationDate); + modelBuilder.Entity().HasIndex(o => o.NextNotificationDate); + modelBuilder.Entity().HasOne(o => o.Order).WithMany(o => o.Billings).HasForeignKey(o => o.OrderId).OnDelete(DeleteBehavior.Cascade); + modelBuilder.Entity().HasOne(o => o.Order).WithMany(o => o.MetaData).HasForeignKey(o => o.OrderId).OnDelete(DeleteBehavior.Restrict); + modelBuilder.Entity().HasOne(o => o.Order).WithMany(o => o.Payments).HasForeignKey(o => o.OrderId).OnDelete(DeleteBehavior.Restrict); + modelBuilder.Entity() + .HasOne(o => o.PrincipalInvestigator) + .WithMany(u => u.Orders) + .HasForeignKey(o => o.PrincipalInvestigatorId) + .OnDelete(DeleteBehavior.Restrict); + } + } +} diff --git a/Hippo.Core/Domain/OrderMetaData.cs b/Hippo.Core/Domain/OrderMetaData.cs new file mode 100644 index 00000000..9cbd3e27 --- /dev/null +++ b/Hippo.Core/Domain/OrderMetaData.cs @@ -0,0 +1,34 @@ +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace Hippo.Core.Domain +{ + public class OrderMetaData + { + [Key] + public int Id { get; set; } + [Required] + public int OrderId { get; set; } + [JsonIgnore] + public Order Order { get; set; } + [Required] + [MaxLength(128)] + public string Name { get; set; } + + [Required] + [MaxLength(450)] + public string Value { get; set; } + + internal static void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasIndex(a => a.OrderId); + modelBuilder.Entity().HasIndex(a => new {a.OrderId, a.Name, a.Value }); + } + } +} diff --git a/Hippo.Core/Domain/Payment.cs b/Hippo.Core/Domain/Payment.cs new file mode 100644 index 00000000..ae3c5eb1 --- /dev/null +++ b/Hippo.Core/Domain/Payment.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.EntityFrameworkCore; + +namespace Hippo.Core.Domain +{ + public class Payment + { + [Key] + public int Id { get; set; } + [MaxLength(128)] + public string FinancialSystemId { get; set; } //For sloth, this is the transaction ID (guid) + [MaxLength(20)] + public string TrackingNumber { get; set; } // KFS tracking number. So probably only ever 10 characters... + public DateTime CreatedOn { get; set; } = DateTime.UtcNow; + public decimal Amount { get; set; } + [MaxLength(20)] + public string Status { get; set; } + [MaxLength(250)] + public string Details { get; set; } //chart strings, credit/debit, and amounts + + + [Required] + public int OrderId { get; set; } + public Order Order { get; set; } + + //Optional createdBy. If not set, was crated by a job + public int? CreatedById { get; set; } + public User CreatedBy { get; set; } + + public class Statuses + { + public const string Created = "Created"; + public const string Processing = "Processing"; + public const string Cancelled = "Cancelled"; + public const string Completed = "Completed"; + + public static List StatusTypes = new List + { + Created, + Processing, + Cancelled, + Completed + }; + } + + internal static void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().HasIndex(p => p.OrderId); + modelBuilder.Entity().HasIndex(p => p.Status); + //DOn't think I need this one + //modelBuilder.Entity().HasOne(p => p.CreatedBy).WithMany().HasForeignKey(a => a.CreatedById).OnDelete(DeleteBehavior.Restrict); + } + } + + +} diff --git a/Hippo.Core/Domain/Product.cs b/Hippo.Core/Domain/Product.cs new file mode 100644 index 00000000..80ad9a48 --- /dev/null +++ b/Hippo.Core/Domain/Product.cs @@ -0,0 +1,31 @@ +using Microsoft.EntityFrameworkCore; +using System.ComponentModel.DataAnnotations; + +namespace Hippo.Core.Domain +{ + public class Product : ProductBase + { + //Other fields in Product Base + + public bool IsActive { get; set; } + public DateTime LastUpdated { get; set; } = DateTime.UtcNow; + + [Required] + public int ClusterId { get; set; } + public Cluster Cluster { get; set; } + + public class InstallmentTypes + { + public const string Monthly = "Monthly"; + public const string Yearly = "Yearly"; + public const string OneTime = "OneTime"; + public static List Types = new List { Monthly, Yearly, OneTime }; + } + + internal static void OnModelCreating(ModelBuilder modelBuilder) + { + modelBuilder.Entity().Property(a => a.IsActive).HasDefaultValue(true); + modelBuilder.Entity().HasQueryFilter(a => a.IsActive); + } + } +} diff --git a/Hippo.Core/Domain/ProductBase.cs b/Hippo.Core/Domain/ProductBase.cs new file mode 100644 index 00000000..eed524dc --- /dev/null +++ b/Hippo.Core/Domain/ProductBase.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static Hippo.Core.Domain.Product; + +namespace Hippo.Core.Domain +{ + public class ProductBase + { + [Key] + public int Id { get; set; } + + [Required] + public string Category { get; set; } + [Required] + [MaxLength(50)] + public string Name { get; set; } + [MaxLength(250)] + public string Description { get; set; } + [MaxLength(50)] + public string Units { get; set; } //Informational like TB, or fair share points + [Required] + [Range(0.01, double.MaxValue)] + public decimal UnitPrice { get; set; } + //Not sure if we want to do this, but it lets a default number of payment installments to be specified + public int Installments { get; set; } + + public int LifeCycle { get; set; } = 60; //Number of months or years the product is active for + + [Required] + [MaxLength(10)] + public string InstallmentType { get; set; } = InstallmentTypes.Monthly; //Monthly, Yearly, OneTime + + + } +} diff --git a/Hippo.Core/Domain/User.cs b/Hippo.Core/Domain/User.cs index e39e52e7..4525cab4 100644 --- a/Hippo.Core/Domain/User.cs +++ b/Hippo.Core/Domain/User.cs @@ -46,6 +46,7 @@ public class User public List Permissions { get; set; } = new(); + internal static void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity().HasIndex(a => a.Iam).IsUnique(); @@ -62,6 +63,7 @@ internal static void OnModelCreating(ModelBuilder modelBuilder) .WithMany(u => u.Permissions) .HasForeignKey(p => p.UserId) .OnDelete(DeleteBehavior.Restrict); + } } } diff --git a/Hippo.Core/Hippo.Core.csproj b/Hippo.Core/Hippo.Core.csproj index 76ce8035..1d43fcc7 100644 --- a/Hippo.Core/Hippo.Core.csproj +++ b/Hippo.Core/Hippo.Core.csproj @@ -1,4 +1,4 @@ - + net6.0 diff --git a/Hippo.Core/Migrations/SqlServer/20240501195621_Orders20240501.Designer.cs b/Hippo.Core/Migrations/SqlServer/20240501195621_Orders20240501.Designer.cs new file mode 100644 index 00000000..b10e14b4 --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240501195621_Orders20240501.Designer.cs @@ -0,0 +1,1083 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + [DbContext(typeof(AppDbContextSqlServer))] + [Migration("20240501195621_Orders20240501")] + partial class Orders20240501 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.19") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("AccountsId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("ClustersId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("OwnerId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ActedById") + .HasColumnType("int"); + + b.Property("ActedDate") + .HasColumnType("datetime2"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("AdminAction") + .HasColumnType("bit"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("OrderId1") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId1"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Adjustment") + .HasColumnType("decimal(18,2)"); + + b.Property("AdjustmentReason") + .HasColumnType("nvarchar(max)"); + + b.Property("AdminNotes") + .HasColumnType("nvarchar(max)"); + + b.Property("BalanceRemaining") + .HasColumnType("decimal(18,2)"); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Notes") + .HasColumnType("nvarchar(max)"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("decimal(18,2)"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("SubTotal") + .HasColumnType("decimal(18,2)"); + + b.Property("Total") + .HasColumnType("decimal(18,2)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedById") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("FinancialSystemId") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("TrackingNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("RoleId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ActorId") + .HasColumnType("int"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("RequesterId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique() + .HasFilter("[Iam] IS NOT NULL"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Order", null) + .WithMany("History") + .HasForeignKey("OrderId1"); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Orders"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240501195621_Orders20240501.cs b/Hippo.Core/Migrations/SqlServer/20240501195621_Orders20240501.cs new file mode 100644 index 00000000..c7d0b784 --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240501195621_Orders20240501.cs @@ -0,0 +1,305 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + public partial class Orders20240501 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "OrderId", + table: "Histories", + type: "int", + nullable: true); + + migrationBuilder.AddColumn( + name: "OrderId1", + table: "Histories", + type: "int", + nullable: true); + + migrationBuilder.CreateTable( + name: "FinancialDetails", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + AutoApprove = table.Column(type: "bit", nullable: false, defaultValue: true), + ClusterId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_FinancialDetails", x => x.Id); + table.ForeignKey( + name: "FK_FinancialDetails_Clusters_ClusterId", + column: x => x.ClusterId, + principalTable: "Clusters", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Orders", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Category = table.Column(type: "nvarchar(max)", nullable: false), + Name = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Description = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: true), + ExternalReference = table.Column(type: "nvarchar(150)", maxLength: 150, nullable: true), + Units = table.Column(type: "nvarchar(max)", nullable: true), + UnitPrice = table.Column(type: "decimal(18,2)", nullable: false), + Quantity = table.Column(type: "decimal(18,2)", nullable: false), + Installments = table.Column(type: "int", nullable: false), + Adjustment = table.Column(type: "decimal(18,2)", nullable: false), + AdjustmentReason = table.Column(type: "nvarchar(max)", nullable: true), + SubTotal = table.Column(type: "decimal(18,2)", nullable: false), + Total = table.Column(type: "decimal(18,2)", nullable: false), + BalanceRemaining = table.Column(type: "decimal(18,2)", nullable: false), + Notes = table.Column(type: "nvarchar(max)", nullable: true), + AdminNotes = table.Column(type: "nvarchar(max)", nullable: true), + Status = table.Column(type: "nvarchar(max)", nullable: true), + ClusterId = table.Column(type: "int", nullable: false), + PrincipalInvestigatorId = table.Column(type: "int", nullable: false), + CreatedOn = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Orders", x => x.Id); + table.ForeignKey( + name: "FK_Orders_Clusters_ClusterId", + column: x => x.ClusterId, + principalTable: "Clusters", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_Orders_Users_PrincipalInvestigatorId", + column: x => x.PrincipalInvestigatorId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Products", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + IsActive = table.Column(type: "bit", nullable: false, defaultValue: true), + Category = table.Column(type: "nvarchar(max)", nullable: false), + Name = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Description = table.Column(type: "nvarchar(250)", maxLength: 250, nullable: true), + Units = table.Column(type: "nvarchar(max)", nullable: true), + UnitPrice = table.Column(type: "decimal(18,2)", nullable: false), + Installments = table.Column(type: "int", nullable: false), + LastUpdated = table.Column(type: "datetime2", nullable: false), + ClusterId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Products", x => x.Id); + table.ForeignKey( + name: "FK_Products_Clusters_ClusterId", + column: x => x.ClusterId, + principalTable: "Clusters", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Billings", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ChartString = table.Column(type: "nvarchar(max)", nullable: false), + Percentage = table.Column(type: "decimal(18,2)", nullable: false), + OrderId = table.Column(type: "int", nullable: false), + Updated = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Billings", x => x.Id); + table.ForeignKey( + name: "FK_Billings_Orders_OrderId", + column: x => x.OrderId, + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "MetaData", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + OrderId = table.Column(type: "int", nullable: false), + Name = table.Column(type: "nvarchar(128)", maxLength: 128, nullable: false), + Value = table.Column(type: "nvarchar(450)", maxLength: 450, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MetaData", x => x.Id); + table.ForeignKey( + name: "FK_MetaData_Orders_OrderId", + column: x => x.OrderId, + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Payments", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + FinancialSystemId = table.Column(type: "nvarchar(max)", nullable: true), + TrackingNumber = table.Column(type: "nvarchar(max)", nullable: true), + CreatedOn = table.Column(type: "datetime2", nullable: false), + Amount = table.Column(type: "decimal(18,2)", nullable: false), + Status = table.Column(type: "nvarchar(max)", nullable: true), + Details = table.Column(type: "nvarchar(max)", nullable: true), + OrderId = table.Column(type: "int", nullable: false), + CreatedById = table.Column(type: "int", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Payments", x => x.Id); + table.ForeignKey( + name: "FK_Payments_Orders_OrderId", + column: x => x.OrderId, + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Payments_Users_CreatedById", + column: x => x.CreatedById, + principalTable: "Users", + principalColumn: "Id"); + }); + + migrationBuilder.CreateIndex( + name: "IX_Histories_OrderId", + table: "Histories", + column: "OrderId"); + + migrationBuilder.CreateIndex( + name: "IX_Histories_OrderId1", + table: "Histories", + column: "OrderId1"); + + migrationBuilder.CreateIndex( + name: "IX_Billings_OrderId", + table: "Billings", + column: "OrderId"); + + migrationBuilder.CreateIndex( + name: "IX_FinancialDetails_ClusterId", + table: "FinancialDetails", + column: "ClusterId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_MetaData_OrderId", + table: "MetaData", + column: "OrderId"); + + migrationBuilder.CreateIndex( + name: "IX_MetaData_OrderId_Name_Value", + table: "MetaData", + columns: new[] { "OrderId", "Name", "Value" }); + + migrationBuilder.CreateIndex( + name: "IX_Orders_ClusterId", + table: "Orders", + column: "ClusterId"); + + migrationBuilder.CreateIndex( + name: "IX_Orders_PrincipalInvestigatorId", + table: "Orders", + column: "PrincipalInvestigatorId"); + + migrationBuilder.CreateIndex( + name: "IX_Payments_CreatedById", + table: "Payments", + column: "CreatedById"); + + migrationBuilder.CreateIndex( + name: "IX_Payments_OrderId", + table: "Payments", + column: "OrderId"); + + migrationBuilder.CreateIndex( + name: "IX_Products_ClusterId", + table: "Products", + column: "ClusterId"); + + migrationBuilder.AddForeignKey( + name: "FK_Histories_Orders_OrderId", + table: "Histories", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Histories_Orders_OrderId1", + table: "Histories", + column: "OrderId1", + principalTable: "Orders", + principalColumn: "Id"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Histories_Orders_OrderId", + table: "Histories"); + + migrationBuilder.DropForeignKey( + name: "FK_Histories_Orders_OrderId1", + table: "Histories"); + + migrationBuilder.DropTable( + name: "Billings"); + + migrationBuilder.DropTable( + name: "FinancialDetails"); + + migrationBuilder.DropTable( + name: "MetaData"); + + migrationBuilder.DropTable( + name: "Payments"); + + migrationBuilder.DropTable( + name: "Products"); + + migrationBuilder.DropTable( + name: "Orders"); + + migrationBuilder.DropIndex( + name: "IX_Histories_OrderId", + table: "Histories"); + + migrationBuilder.DropIndex( + name: "IX_Histories_OrderId1", + table: "Histories"); + + migrationBuilder.DropColumn( + name: "OrderId", + table: "Histories"); + + migrationBuilder.DropColumn( + name: "OrderId1", + table: "Histories"); + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240501203029_FixFinancialDetail.Designer.cs b/Hippo.Core/Migrations/SqlServer/20240501203029_FixFinancialDetail.Designer.cs new file mode 100644 index 00000000..c080e5cb --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240501203029_FixFinancialDetail.Designer.cs @@ -0,0 +1,1094 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + [DbContext(typeof(AppDbContextSqlServer))] + [Migration("20240501203029_FixFinancialDetail")] + partial class FixFinancialDetail + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.19") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("AccountsId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("ClustersId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("OwnerId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("FinancialSystemApiKey") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("FinancialSystemApiSource") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ActedById") + .HasColumnType("int"); + + b.Property("ActedDate") + .HasColumnType("datetime2"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("AdminAction") + .HasColumnType("bit"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("OrderId1") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId1"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Adjustment") + .HasColumnType("decimal(18,2)"); + + b.Property("AdjustmentReason") + .HasColumnType("nvarchar(max)"); + + b.Property("AdminNotes") + .HasColumnType("nvarchar(max)"); + + b.Property("BalanceRemaining") + .HasColumnType("decimal(18,2)"); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Notes") + .HasColumnType("nvarchar(max)"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("decimal(18,2)"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("SubTotal") + .HasColumnType("decimal(18,2)"); + + b.Property("Total") + .HasColumnType("decimal(18,2)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedById") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("FinancialSystemId") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("TrackingNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("RoleId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ActorId") + .HasColumnType("int"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("RequesterId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique() + .HasFilter("[Iam] IS NOT NULL"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Order", null) + .WithMany("History") + .HasForeignKey("OrderId1"); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Orders"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240501203029_FixFinancialDetail.cs b/Hippo.Core/Migrations/SqlServer/20240501203029_FixFinancialDetail.cs new file mode 100644 index 00000000..3398a912 --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240501203029_FixFinancialDetail.cs @@ -0,0 +1,47 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + public partial class FixFinancialDetail : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ChartString", + table: "FinancialDetails", + type: "nvarchar(max)", + nullable: true); + + migrationBuilder.AddColumn( + name: "FinancialSystemApiKey", + table: "FinancialDetails", + type: "nvarchar(128)", + maxLength: 128, + nullable: true); + + migrationBuilder.AddColumn( + name: "FinancialSystemApiSource", + table: "FinancialDetails", + type: "nvarchar(50)", + maxLength: 50, + nullable: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ChartString", + table: "FinancialDetails"); + + migrationBuilder.DropColumn( + name: "FinancialSystemApiKey", + table: "FinancialDetails"); + + migrationBuilder.DropColumn( + name: "FinancialSystemApiSource", + table: "FinancialDetails"); + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240501223936_useSecretFinancilDetail.Designer.cs b/Hippo.Core/Migrations/SqlServer/20240501223936_useSecretFinancilDetail.Designer.cs new file mode 100644 index 00000000..d632ffb3 --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240501223936_useSecretFinancilDetail.Designer.cs @@ -0,0 +1,1094 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + [DbContext(typeof(AppDbContextSqlServer))] + [Migration("20240501223936_useSecretFinancilDetail")] + partial class useSecretFinancilDetail + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.19") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("AccountsId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("ClustersId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("OwnerId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SecretAccessKey") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ActedById") + .HasColumnType("int"); + + b.Property("ActedDate") + .HasColumnType("datetime2"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("AdminAction") + .HasColumnType("bit"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("OrderId1") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId1"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Adjustment") + .HasColumnType("decimal(18,2)"); + + b.Property("AdjustmentReason") + .HasColumnType("nvarchar(max)"); + + b.Property("AdminNotes") + .HasColumnType("nvarchar(max)"); + + b.Property("BalanceRemaining") + .HasColumnType("decimal(18,2)"); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Notes") + .HasColumnType("nvarchar(max)"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("decimal(18,2)"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("SubTotal") + .HasColumnType("decimal(18,2)"); + + b.Property("Total") + .HasColumnType("decimal(18,2)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedById") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("FinancialSystemId") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("TrackingNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("RoleId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ActorId") + .HasColumnType("int"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("RequesterId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique() + .HasFilter("[Iam] IS NOT NULL"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Order", null) + .WithMany("History") + .HasForeignKey("OrderId1"); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Orders"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240501223936_useSecretFinancilDetail.cs b/Hippo.Core/Migrations/SqlServer/20240501223936_useSecretFinancilDetail.cs new file mode 100644 index 00000000..a708b50b --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240501223936_useSecretFinancilDetail.cs @@ -0,0 +1,60 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + public partial class useSecretFinancilDetail : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "FinancialSystemApiKey", + table: "FinancialDetails"); + + migrationBuilder.AlterColumn( + name: "FinancialSystemApiSource", + table: "FinancialDetails", + type: "nvarchar(50)", + maxLength: 50, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "nvarchar(50)", + oldMaxLength: 50, + oldNullable: true); + + migrationBuilder.AddColumn( + name: "SecretAccessKey", + table: "FinancialDetails", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "SecretAccessKey", + table: "FinancialDetails"); + + migrationBuilder.AlterColumn( + name: "FinancialSystemApiSource", + table: "FinancialDetails", + type: "nvarchar(50)", + maxLength: 50, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(50)", + oldMaxLength: 50); + + migrationBuilder.AddColumn( + name: "FinancialSystemApiKey", + table: "FinancialDetails", + type: "nvarchar(128)", + maxLength: 128, + nullable: true); + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240514163033_FixHistoryRelationship.Designer.cs b/Hippo.Core/Migrations/SqlServer/20240514163033_FixHistoryRelationship.Designer.cs new file mode 100644 index 00000000..bb634341 --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240514163033_FixHistoryRelationship.Designer.cs @@ -0,0 +1,1084 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + [DbContext(typeof(AppDbContextSqlServer))] + [Migration("20240514163033_FixHistoryRelationship")] + partial class FixHistoryRelationship + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.19") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("AccountsId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("ClustersId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("OwnerId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SecretAccessKey") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ActedById") + .HasColumnType("int"); + + b.Property("ActedDate") + .HasColumnType("datetime2"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("AdminAction") + .HasColumnType("bit"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Adjustment") + .HasColumnType("decimal(18,2)"); + + b.Property("AdjustmentReason") + .HasColumnType("nvarchar(max)"); + + b.Property("AdminNotes") + .HasColumnType("nvarchar(max)"); + + b.Property("BalanceRemaining") + .HasColumnType("decimal(18,2)"); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Notes") + .HasColumnType("nvarchar(max)"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("decimal(18,2)"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("SubTotal") + .HasColumnType("decimal(18,2)"); + + b.Property("Total") + .HasColumnType("decimal(18,2)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedById") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("FinancialSystemId") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("TrackingNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("RoleId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ActorId") + .HasColumnType("int"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("RequesterId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique() + .HasFilter("[Iam] IS NOT NULL"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId"); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Orders"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240514163033_FixHistoryRelationship.cs b/Hippo.Core/Migrations/SqlServer/20240514163033_FixHistoryRelationship.cs new file mode 100644 index 00000000..2d03af25 --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240514163033_FixHistoryRelationship.cs @@ -0,0 +1,68 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + public partial class FixHistoryRelationship : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Histories_Orders_OrderId", + table: "Histories"); + + migrationBuilder.DropForeignKey( + name: "FK_Histories_Orders_OrderId1", + table: "Histories"); + + migrationBuilder.DropIndex( + name: "IX_Histories_OrderId1", + table: "Histories"); + + migrationBuilder.DropColumn( + name: "OrderId1", + table: "Histories"); + + migrationBuilder.AddForeignKey( + name: "FK_Histories_Orders_OrderId", + table: "Histories", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Histories_Orders_OrderId", + table: "Histories"); + + migrationBuilder.AddColumn( + name: "OrderId1", + table: "Histories", + type: "int", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_Histories_OrderId1", + table: "Histories", + column: "OrderId1"); + + migrationBuilder.AddForeignKey( + name: "FK_Histories_Orders_OrderId", + table: "Histories", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Histories_Orders_OrderId1", + table: "Histories", + column: "OrderId1", + principalTable: "Orders", + principalColumn: "Id"); + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240515143208_AddHistoryFlag.Designer.cs b/Hippo.Core/Migrations/SqlServer/20240515143208_AddHistoryFlag.Designer.cs new file mode 100644 index 00000000..6d88038c --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240515143208_AddHistoryFlag.Designer.cs @@ -0,0 +1,1087 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + [DbContext(typeof(AppDbContextSqlServer))] + [Migration("20240515143208_AddHistoryFlag")] + partial class AddHistoryFlag + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.19") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("AccountsId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("ClustersId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("OwnerId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SecretAccessKey") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ActedById") + .HasColumnType("int"); + + b.Property("ActedDate") + .HasColumnType("datetime2"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("AdminAction") + .HasColumnType("bit"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("ShowToUser") + .HasColumnType("bit"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Adjustment") + .HasColumnType("decimal(18,2)"); + + b.Property("AdjustmentReason") + .HasColumnType("nvarchar(max)"); + + b.Property("AdminNotes") + .HasColumnType("nvarchar(max)"); + + b.Property("BalanceRemaining") + .HasColumnType("decimal(18,2)"); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Notes") + .HasColumnType("nvarchar(max)"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("decimal(18,2)"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("SubTotal") + .HasColumnType("decimal(18,2)"); + + b.Property("Total") + .HasColumnType("decimal(18,2)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedById") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("FinancialSystemId") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("TrackingNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("RoleId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ActorId") + .HasColumnType("int"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("RequesterId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique() + .HasFilter("[Iam] IS NOT NULL"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId"); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Orders"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240515143208_AddHistoryFlag.cs b/Hippo.Core/Migrations/SqlServer/20240515143208_AddHistoryFlag.cs new file mode 100644 index 00000000..a505a8d7 --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240515143208_AddHistoryFlag.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + public partial class AddHistoryFlag : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ShowToUser", + table: "Histories", + type: "bit", + nullable: false, + defaultValue: false); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ShowToUser", + table: "Histories"); + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240515155511_ReplaceFlagWithType.Designer.cs b/Hippo.Core/Migrations/SqlServer/20240515155511_ReplaceFlagWithType.Designer.cs new file mode 100644 index 00000000..94674ce3 --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240515155511_ReplaceFlagWithType.Designer.cs @@ -0,0 +1,1090 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + [DbContext(typeof(AppDbContextSqlServer))] + [Migration("20240515155511_ReplaceFlagWithType")] + partial class ReplaceFlagWithType + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.19") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("AccountsId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("ClustersId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("OwnerId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SecretAccessKey") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ActedById") + .HasColumnType("int"); + + b.Property("ActedDate") + .HasColumnType("datetime2"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("AdminAction") + .HasColumnType("bit"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Adjustment") + .HasColumnType("decimal(18,2)"); + + b.Property("AdjustmentReason") + .HasColumnType("nvarchar(max)"); + + b.Property("AdminNotes") + .HasColumnType("nvarchar(max)"); + + b.Property("BalanceRemaining") + .HasColumnType("decimal(18,2)"); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Notes") + .HasColumnType("nvarchar(max)"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("int"); + + b.Property("Quantity") + .HasColumnType("decimal(18,2)"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("SubTotal") + .HasColumnType("decimal(18,2)"); + + b.Property("Total") + .HasColumnType("decimal(18,2)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedById") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("FinancialSystemId") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("TrackingNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("RoleId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ActorId") + .HasColumnType("int"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("RequesterId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique() + .HasFilter("[Iam] IS NOT NULL"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId"); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Orders"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240515155511_ReplaceFlagWithType.cs b/Hippo.Core/Migrations/SqlServer/20240515155511_ReplaceFlagWithType.cs new file mode 100644 index 00000000..f7d9c6a2 --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240515155511_ReplaceFlagWithType.cs @@ -0,0 +1,46 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + public partial class ReplaceFlagWithType : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ShowToUser", + table: "Histories"); + + migrationBuilder.AddColumn( + name: "Type", + table: "Histories", + type: "nvarchar(50)", + maxLength: 50, + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_Histories_Type", + table: "Histories", + column: "Type"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_Histories_Type", + table: "Histories"); + + migrationBuilder.DropColumn( + name: "Type", + table: "Histories"); + + migrationBuilder.AddColumn( + name: "ShowToUser", + table: "Histories", + type: "bit", + nullable: false, + defaultValue: false); + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240522172606_AddOrderFields.Designer.cs b/Hippo.Core/Migrations/SqlServer/20240522172606_AddOrderFields.Designer.cs new file mode 100644 index 00000000..3bf86b43 --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240522172606_AddOrderFields.Designer.cs @@ -0,0 +1,1105 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + [DbContext(typeof(AppDbContextSqlServer))] + [Migration("20240522172606_AddOrderFields")] + partial class AddOrderFields + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.19") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("AccountsId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("ClustersId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("OwnerId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SecretAccessKey") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ActedById") + .HasColumnType("int"); + + b.Property("ActedDate") + .HasColumnType("datetime2"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("AdminAction") + .HasColumnType("bit"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Adjustment") + .HasColumnType("decimal(18,2)"); + + b.Property("AdjustmentReason") + .HasColumnType("nvarchar(max)"); + + b.Property("AdminNotes") + .HasColumnType("nvarchar(max)"); + + b.Property("BalanceRemaining") + .HasColumnType("decimal(18,2)"); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Notes") + .HasColumnType("nvarchar(max)"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("int"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Quantity") + .HasColumnType("decimal(18,2)"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("SubTotal") + .HasColumnType("decimal(18,2)"); + + b.Property("Total") + .HasColumnType("decimal(18,2)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedById") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("FinancialSystemId") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("TrackingNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("RoleId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ActorId") + .HasColumnType("int"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("RequesterId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique() + .HasFilter("[Iam] IS NOT NULL"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId"); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Orders"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240522172606_AddOrderFields.cs b/Hippo.Core/Migrations/SqlServer/20240522172606_AddOrderFields.cs new file mode 100644 index 00000000..d3cf50c8 --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240522172606_AddOrderFields.cs @@ -0,0 +1,51 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + public partial class AddOrderFields : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "InstallmentType", + table: "Products", + type: "nvarchar(10)", + maxLength: 10, + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "InstallmentType", + table: "Orders", + type: "nvarchar(10)", + maxLength: 10, + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "ProductName", + table: "Orders", + type: "nvarchar(50)", + maxLength: 50, + nullable: false, + defaultValue: ""); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "InstallmentType", + table: "Products"); + + migrationBuilder.DropColumn( + name: "InstallmentType", + table: "Orders"); + + migrationBuilder.DropColumn( + name: "ProductName", + table: "Orders"); + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240605140340_ChangePiToBeAccount.Designer.cs b/Hippo.Core/Migrations/SqlServer/20240605140340_ChangePiToBeAccount.Designer.cs new file mode 100644 index 00000000..3cf89a3c --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240605140340_ChangePiToBeAccount.Designer.cs @@ -0,0 +1,1108 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + [DbContext(typeof(AppDbContextSqlServer))] + [Migration("20240605140340_ChangePiToBeAccount")] + partial class ChangePiToBeAccount + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.19") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("AccountsId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("ClustersId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("OwnerId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SecretAccessKey") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ActedById") + .HasColumnType("int"); + + b.Property("ActedDate") + .HasColumnType("datetime2"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("AdminAction") + .HasColumnType("bit"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Adjustment") + .HasColumnType("decimal(18,2)"); + + b.Property("AdjustmentReason") + .HasColumnType("nvarchar(max)"); + + b.Property("AdminNotes") + .HasColumnType("nvarchar(max)"); + + b.Property("BalanceRemaining") + .HasColumnType("decimal(18,2)"); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Notes") + .HasColumnType("nvarchar(max)"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("int"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Quantity") + .HasColumnType("decimal(18,2)"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("SubTotal") + .HasColumnType("decimal(18,2)"); + + b.Property("Total") + .HasColumnType("decimal(18,2)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedById") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("FinancialSystemId") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("TrackingNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("RoleId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ActorId") + .HasColumnType("int"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("RequesterId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique() + .HasFilter("[Iam] IS NOT NULL"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId"); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240605140340_ChangePiToBeAccount.cs b/Hippo.Core/Migrations/SqlServer/20240605140340_ChangePiToBeAccount.cs new file mode 100644 index 00000000..1a7175d3 --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240605140340_ChangePiToBeAccount.cs @@ -0,0 +1,39 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + public partial class ChangePiToBeAccount : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Users_PrincipalInvestigatorId", + table: "Orders"); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Accounts_PrincipalInvestigatorId", + table: "Orders", + column: "PrincipalInvestigatorId", + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Accounts_PrincipalInvestigatorId", + table: "Orders"); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Users_PrincipalInvestigatorId", + table: "Orders", + column: "PrincipalInvestigatorId", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240606174435_NewProductAndOrderFields.Designer.cs b/Hippo.Core/Migrations/SqlServer/20240606174435_NewProductAndOrderFields.Designer.cs new file mode 100644 index 00000000..d40e152c --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240606174435_NewProductAndOrderFields.Designer.cs @@ -0,0 +1,1120 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + [DbContext(typeof(AppDbContextSqlServer))] + [Migration("20240606174435_NewProductAndOrderFields")] + partial class NewProductAndOrderFields + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.19") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("AccountsId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("ClustersId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("OwnerId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SecretAccessKey") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ActedById") + .HasColumnType("int"); + + b.Property("ActedDate") + .HasColumnType("datetime2"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("AdminAction") + .HasColumnType("bit"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Adjustment") + .HasColumnType("decimal(18,2)"); + + b.Property("AdjustmentReason") + .HasColumnType("nvarchar(max)"); + + b.Property("AdminNotes") + .HasColumnType("nvarchar(max)"); + + b.Property("BalanceRemaining") + .HasColumnType("decimal(18,2)"); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("ExpirationDate") + .HasColumnType("datetime2"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("InstallmentDate") + .HasColumnType("datetime2"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("LifeCycle") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Notes") + .HasColumnType("nvarchar(max)"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("int"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Quantity") + .HasColumnType("decimal(18,2)"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("SubTotal") + .HasColumnType("decimal(18,2)"); + + b.Property("Total") + .HasColumnType("decimal(18,2)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedById") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("FinancialSystemId") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("TrackingNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("RoleId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("datetime2"); + + b.Property("LifeCycle") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ActorId") + .HasColumnType("int"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("RequesterId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique() + .HasFilter("[Iam] IS NOT NULL"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId"); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240606174435_NewProductAndOrderFields.cs b/Hippo.Core/Migrations/SqlServer/20240606174435_NewProductAndOrderFields.cs new file mode 100644 index 00000000..3250eee6 --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240606174435_NewProductAndOrderFields.cs @@ -0,0 +1,58 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + public partial class NewProductAndOrderFields : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "LifeCycle", + table: "Products", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ExpirationDate", + table: "Orders", + type: "datetime2", + nullable: true); + + migrationBuilder.AddColumn( + name: "InstallmentDate", + table: "Orders", + type: "datetime2", + nullable: true); + + migrationBuilder.AddColumn( + name: "LifeCycle", + table: "Orders", + type: "int", + nullable: false, + defaultValue: 0); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "LifeCycle", + table: "Products"); + + migrationBuilder.DropColumn( + name: "ExpirationDate", + table: "Orders"); + + migrationBuilder.DropColumn( + name: "InstallmentDate", + table: "Orders"); + + migrationBuilder.DropColumn( + name: "LifeCycle", + table: "Orders"); + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240628162105_OrderDates.Designer.cs b/Hippo.Core/Migrations/SqlServer/20240628162105_OrderDates.Designer.cs new file mode 100644 index 00000000..12332dba --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240628162105_OrderDates.Designer.cs @@ -0,0 +1,1126 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + [DbContext(typeof(AppDbContextSqlServer))] + [Migration("20240628162105_OrderDates")] + partial class OrderDates + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.19") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("AccountsId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("ClustersId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("OwnerId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SecretAccessKey") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ActedById") + .HasColumnType("int"); + + b.Property("ActedDate") + .HasColumnType("datetime2"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("AdminAction") + .HasColumnType("bit"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Adjustment") + .HasColumnType("decimal(18,2)"); + + b.Property("AdjustmentReason") + .HasColumnType("nvarchar(max)"); + + b.Property("AdminNotes") + .HasColumnType("nvarchar(max)"); + + b.Property("BalanceRemaining") + .HasColumnType("decimal(18,2)"); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("ExpirationDate") + .HasColumnType("datetime2"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("InstallmentDate") + .HasColumnType("datetime2"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("LifeCycle") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NextNotificationDate") + .HasColumnType("datetime2"); + + b.Property("NextPaymentDate") + .HasColumnType("datetime2"); + + b.Property("Notes") + .HasColumnType("nvarchar(max)"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("int"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Quantity") + .HasColumnType("decimal(18,2)"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("SubTotal") + .HasColumnType("decimal(18,2)"); + + b.Property("Total") + .HasColumnType("decimal(18,2)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedById") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("FinancialSystemId") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("TrackingNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("RoleId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("datetime2"); + + b.Property("LifeCycle") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ActorId") + .HasColumnType("int"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("RequesterId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique() + .HasFilter("[Iam] IS NOT NULL"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId"); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240628162105_OrderDates.cs b/Hippo.Core/Migrations/SqlServer/20240628162105_OrderDates.cs new file mode 100644 index 00000000..5f60d379 --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240628162105_OrderDates.cs @@ -0,0 +1,36 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + public partial class OrderDates : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "NextNotificationDate", + table: "Orders", + type: "datetime2", + nullable: true); + + migrationBuilder.AddColumn( + name: "NextPaymentDate", + table: "Orders", + type: "datetime2", + nullable: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "NextNotificationDate", + table: "Orders"); + + migrationBuilder.DropColumn( + name: "NextPaymentDate", + table: "Orders"); + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240711213919_OrderHistory.Designer.cs b/Hippo.Core/Migrations/SqlServer/20240711213919_OrderHistory.Designer.cs new file mode 100644 index 00000000..cea3ec84 --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240711213919_OrderHistory.Designer.cs @@ -0,0 +1,1127 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + [DbContext(typeof(AppDbContextSqlServer))] + [Migration("20240711213919_OrderHistory")] + partial class OrderHistory + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.19") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("AccountsId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("ClustersId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("OwnerId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SecretAccessKey") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ActedById") + .HasColumnType("int"); + + b.Property("ActedDate") + .HasColumnType("datetime2"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("AdminAction") + .HasColumnType("bit"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Adjustment") + .HasColumnType("decimal(18,2)"); + + b.Property("AdjustmentReason") + .HasColumnType("nvarchar(max)"); + + b.Property("AdminNotes") + .HasColumnType("nvarchar(max)"); + + b.Property("BalanceRemaining") + .HasColumnType("decimal(18,2)"); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("ExpirationDate") + .HasColumnType("datetime2"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("InstallmentDate") + .HasColumnType("datetime2"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("LifeCycle") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NextNotificationDate") + .HasColumnType("datetime2"); + + b.Property("NextPaymentDate") + .HasColumnType("datetime2"); + + b.Property("Notes") + .HasColumnType("nvarchar(max)"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("int"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Quantity") + .HasColumnType("decimal(18,2)"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("SubTotal") + .HasColumnType("decimal(18,2)"); + + b.Property("Total") + .HasColumnType("decimal(18,2)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedById") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("FinancialSystemId") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("nvarchar(max)"); + + b.Property("TrackingNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("RoleId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("datetime2"); + + b.Property("LifeCycle") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ActorId") + .HasColumnType("int"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("RequesterId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique() + .HasFilter("[Iam] IS NOT NULL"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240711213919_OrderHistory.cs b/Hippo.Core/Migrations/SqlServer/20240711213919_OrderHistory.cs new file mode 100644 index 00000000..fb6067c9 --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240711213919_OrderHistory.cs @@ -0,0 +1,134 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + public partial class OrderHistory : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Billings_Orders_OrderId", + table: "Billings"); + + migrationBuilder.DropForeignKey( + name: "FK_Histories_Orders_OrderId", + table: "Histories"); + + migrationBuilder.DropForeignKey( + name: "FK_MetaData_Orders_OrderId", + table: "MetaData"); + + migrationBuilder.DropForeignKey( + name: "FK_Orders_Accounts_PrincipalInvestigatorId", + table: "Orders"); + + migrationBuilder.DropForeignKey( + name: "FK_Payments_Orders_OrderId", + table: "Payments"); + + migrationBuilder.AddForeignKey( + name: "FK_Billings_Orders_OrderId", + table: "Billings", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Histories_Orders_OrderId", + table: "Histories", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_MetaData_Orders_OrderId", + table: "MetaData", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Accounts_PrincipalInvestigatorId", + table: "Orders", + column: "PrincipalInvestigatorId", + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Payments_Orders_OrderId", + table: "Payments", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Billings_Orders_OrderId", + table: "Billings"); + + migrationBuilder.DropForeignKey( + name: "FK_Histories_Orders_OrderId", + table: "Histories"); + + migrationBuilder.DropForeignKey( + name: "FK_MetaData_Orders_OrderId", + table: "MetaData"); + + migrationBuilder.DropForeignKey( + name: "FK_Orders_Accounts_PrincipalInvestigatorId", + table: "Orders"); + + migrationBuilder.DropForeignKey( + name: "FK_Payments_Orders_OrderId", + table: "Payments"); + + migrationBuilder.AddForeignKey( + name: "FK_Billings_Orders_OrderId", + table: "Billings", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Histories_Orders_OrderId", + table: "Histories", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_MetaData_Orders_OrderId", + table: "MetaData", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Accounts_PrincipalInvestigatorId", + table: "Orders", + column: "PrincipalInvestigatorId", + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Payments_Orders_OrderId", + table: "Payments", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240712152154_OrderIndexes.Designer.cs b/Hippo.Core/Migrations/SqlServer/20240712152154_OrderIndexes.Designer.cs new file mode 100644 index 00000000..03df4a8d --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240712152154_OrderIndexes.Designer.cs @@ -0,0 +1,1140 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + [DbContext(typeof(AppDbContextSqlServer))] + [Migration("20240712152154_OrderIndexes")] + partial class OrderIndexes + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.19") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("AccountsId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("ClustersId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("OwnerId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SecretAccessKey") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ActedById") + .HasColumnType("int"); + + b.Property("ActedDate") + .HasColumnType("datetime2"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("AdminAction") + .HasColumnType("bit"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Adjustment") + .HasColumnType("decimal(18,2)"); + + b.Property("AdjustmentReason") + .HasColumnType("nvarchar(max)"); + + b.Property("AdminNotes") + .HasColumnType("nvarchar(max)"); + + b.Property("BalanceRemaining") + .HasColumnType("decimal(18,2)"); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("ExpirationDate") + .HasColumnType("datetime2"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("InstallmentDate") + .HasColumnType("datetime2"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("LifeCycle") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NextNotificationDate") + .HasColumnType("datetime2"); + + b.Property("NextPaymentDate") + .HasColumnType("datetime2"); + + b.Property("Notes") + .HasColumnType("nvarchar(max)"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("int"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Quantity") + .HasColumnType("decimal(18,2)"); + + b.Property("Status") + .HasColumnType("nvarchar(450)"); + + b.Property("SubTotal") + .HasColumnType("decimal(18,2)"); + + b.Property("Total") + .HasColumnType("decimal(18,2)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("ExpirationDate"); + + b.HasIndex("NextNotificationDate"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.HasIndex("Status"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedById") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("FinancialSystemId") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("nvarchar(450)"); + + b.Property("TrackingNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.HasIndex("Status"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("RoleId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("datetime2"); + + b.Property("LifeCycle") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ActorId") + .HasColumnType("int"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("RequesterId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Group") + .HasColumnType("nvarchar(450)"); + + b.HasKey("ClusterId", "Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Kerberos") + .HasColumnType("nvarchar(450)"); + + b.HasKey("ClusterId", "Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique() + .HasFilter("[Iam] IS NOT NULL"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240712152154_OrderIndexes.cs b/Hippo.Core/Migrations/SqlServer/20240712152154_OrderIndexes.cs new file mode 100644 index 00000000..32d28877 --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240712152154_OrderIndexes.cs @@ -0,0 +1,87 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + public partial class OrderIndexes : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Status", + table: "Payments", + type: "nvarchar(450)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Status", + table: "Orders", + type: "nvarchar(450)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.CreateIndex( + name: "IX_Payments_Status", + table: "Payments", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_Orders_ExpirationDate", + table: "Orders", + column: "ExpirationDate"); + + migrationBuilder.CreateIndex( + name: "IX_Orders_NextNotificationDate", + table: "Orders", + column: "NextNotificationDate"); + + migrationBuilder.CreateIndex( + name: "IX_Orders_Status", + table: "Orders", + column: "Status"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_Payments_Status", + table: "Payments"); + + migrationBuilder.DropIndex( + name: "IX_Orders_ExpirationDate", + table: "Orders"); + + migrationBuilder.DropIndex( + name: "IX_Orders_NextNotificationDate", + table: "Orders"); + + migrationBuilder.DropIndex( + name: "IX_Orders_Status", + table: "Orders"); + + migrationBuilder.AlterColumn( + name: "Status", + table: "Payments", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(450)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Status", + table: "Orders", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(450)", + oldNullable: true); + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240716175733_billingOrder.Designer.cs b/Hippo.Core/Migrations/SqlServer/20240716175733_billingOrder.Designer.cs new file mode 100644 index 00000000..3f99cd5b --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240716175733_billingOrder.Designer.cs @@ -0,0 +1,1140 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + [DbContext(typeof(AppDbContextSqlServer))] + [Migration("20240716175733_billingOrder")] + partial class billingOrder + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.19") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("AccountsId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("ClustersId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("OwnerId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SecretAccessKey") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ActedById") + .HasColumnType("int"); + + b.Property("ActedDate") + .HasColumnType("datetime2"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("AdminAction") + .HasColumnType("bit"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Adjustment") + .HasColumnType("decimal(18,2)"); + + b.Property("AdjustmentReason") + .HasColumnType("nvarchar(max)"); + + b.Property("AdminNotes") + .HasColumnType("nvarchar(max)"); + + b.Property("BalanceRemaining") + .HasColumnType("decimal(18,2)"); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("ExpirationDate") + .HasColumnType("datetime2"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("InstallmentDate") + .HasColumnType("datetime2"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("LifeCycle") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NextNotificationDate") + .HasColumnType("datetime2"); + + b.Property("NextPaymentDate") + .HasColumnType("datetime2"); + + b.Property("Notes") + .HasColumnType("nvarchar(max)"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("int"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Quantity") + .HasColumnType("decimal(18,2)"); + + b.Property("Status") + .HasColumnType("nvarchar(450)"); + + b.Property("SubTotal") + .HasColumnType("decimal(18,2)"); + + b.Property("Total") + .HasColumnType("decimal(18,2)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("ExpirationDate"); + + b.HasIndex("NextNotificationDate"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.HasIndex("Status"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedById") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("FinancialSystemId") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("nvarchar(450)"); + + b.Property("TrackingNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.HasIndex("Status"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("RoleId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("datetime2"); + + b.Property("LifeCycle") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ActorId") + .HasColumnType("int"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("RequesterId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Group") + .HasColumnType("nvarchar(450)"); + + b.HasKey("ClusterId", "Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Kerberos") + .HasColumnType("nvarchar(450)"); + + b.HasKey("ClusterId", "Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique() + .HasFilter("[Iam] IS NOT NULL"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240716175733_billingOrder.cs b/Hippo.Core/Migrations/SqlServer/20240716175733_billingOrder.cs new file mode 100644 index 00000000..f99f1366 --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240716175733_billingOrder.cs @@ -0,0 +1,39 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + public partial class billingOrder : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Billings_Orders_OrderId", + table: "Billings"); + + migrationBuilder.AddForeignKey( + name: "FK_Billings_Orders_OrderId", + table: "Billings", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Billings_Orders_OrderId", + table: "Billings"); + + migrationBuilder.AddForeignKey( + name: "FK_Billings_Orders_OrderId", + table: "Billings", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240724154535_financialDetail.Designer.cs b/Hippo.Core/Migrations/SqlServer/20240724154535_financialDetail.Designer.cs new file mode 100644 index 00000000..eac8ced5 --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240724154535_financialDetail.Designer.cs @@ -0,0 +1,1140 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + [DbContext(typeof(AppDbContextSqlServer))] + [Migration("20240724154535_financialDetail")] + partial class financialDetail + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.19") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("AccountsId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("ClustersId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("OwnerId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SecretAccessKey") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ActedById") + .HasColumnType("int"); + + b.Property("ActedDate") + .HasColumnType("datetime2"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("AdminAction") + .HasColumnType("bit"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Adjustment") + .HasColumnType("decimal(18,2)"); + + b.Property("AdjustmentReason") + .HasColumnType("nvarchar(max)"); + + b.Property("AdminNotes") + .HasColumnType("nvarchar(max)"); + + b.Property("BalanceRemaining") + .HasColumnType("decimal(18,2)"); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("ExpirationDate") + .HasColumnType("datetime2"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("InstallmentDate") + .HasColumnType("datetime2"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("LifeCycle") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NextNotificationDate") + .HasColumnType("datetime2"); + + b.Property("NextPaymentDate") + .HasColumnType("datetime2"); + + b.Property("Notes") + .HasColumnType("nvarchar(max)"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("int"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Quantity") + .HasColumnType("decimal(18,2)"); + + b.Property("Status") + .HasColumnType("nvarchar(450)"); + + b.Property("SubTotal") + .HasColumnType("decimal(18,2)"); + + b.Property("Total") + .HasColumnType("decimal(18,2)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("ExpirationDate"); + + b.HasIndex("NextNotificationDate"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.HasIndex("Status"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedById") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("FinancialSystemId") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("nvarchar(450)"); + + b.Property("TrackingNumber") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.HasIndex("Status"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("RoleId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("datetime2"); + + b.Property("LifeCycle") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ActorId") + .HasColumnType("int"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("RequesterId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Group") + .HasColumnType("nvarchar(450)"); + + b.HasKey("ClusterId", "Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Kerberos") + .HasColumnType("nvarchar(450)"); + + b.HasKey("ClusterId", "Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique() + .HasFilter("[Iam] IS NOT NULL"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240724154535_financialDetail.cs b/Hippo.Core/Migrations/SqlServer/20240724154535_financialDetail.cs new file mode 100644 index 00000000..bee02b8d --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240724154535_financialDetail.cs @@ -0,0 +1,34 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + public partial class financialDetail : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "SecretAccessKey", + table: "FinancialDetails", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(Guid), + oldType: "uniqueidentifier"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "SecretAccessKey", + table: "FinancialDetails", + type: "uniqueidentifier", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240725161200_orderFieldLengths.Designer.cs b/Hippo.Core/Migrations/SqlServer/20240725161200_orderFieldLengths.Designer.cs new file mode 100644 index 00000000..7f84b7ca --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240725161200_orderFieldLengths.Designer.cs @@ -0,0 +1,1150 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + [DbContext(typeof(AppDbContextSqlServer))] + [Migration("20240725161200_orderFieldLengths")] + partial class orderFieldLengths + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "6.0.19") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("AccountsId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("int"); + + b.Property("ClustersId") + .HasColumnType("int"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("OwnerId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ChartString") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SecretAccessKey") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("int"); + + b.Property("GroupId") + .HasColumnType("int"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ActedById") + .HasColumnType("int"); + + b.Property("ActedDate") + .HasColumnType("datetime2"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("AdminAction") + .HasColumnType("bit"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Details") + .HasColumnType("nvarchar(max)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Adjustment") + .HasColumnType("decimal(18,2)"); + + b.Property("AdjustmentReason") + .HasColumnType("nvarchar(max)"); + + b.Property("AdminNotes") + .HasColumnType("nvarchar(max)"); + + b.Property("BalanceRemaining") + .HasColumnType("decimal(18,2)"); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("ExpirationDate") + .HasColumnType("datetime2"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("InstallmentDate") + .HasColumnType("datetime2"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("LifeCycle") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NextNotificationDate") + .HasColumnType("datetime2"); + + b.Property("NextPaymentDate") + .HasColumnType("datetime2"); + + b.Property("Notes") + .HasColumnType("nvarchar(max)"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("int"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Quantity") + .HasColumnType("decimal(18,2)"); + + b.Property("Status") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("SubTotal") + .HasColumnType("decimal(18,2)"); + + b.Property("Total") + .HasColumnType("decimal(18,2)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("ExpirationDate"); + + b.HasIndex("NextNotificationDate"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.HasIndex("Status"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedById") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Details") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("FinancialSystemId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("TrackingNumber") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.HasIndex("Status"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("RoleId") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("datetime2"); + + b.Property("LifeCycle") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorMessage") + .HasColumnType("nvarchar(max)"); + + b.Property("RequestId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UpdatedAt") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("ActorId") + .HasColumnType("int"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Data") + .HasColumnType("nvarchar(max)"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("nvarchar(32)"); + + b.Property("RequesterId") + .HasColumnType("int"); + + b.Property("SshKey") + .HasColumnType("nvarchar(max)"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("UpdatedOn") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Group") + .HasColumnType("nvarchar(450)"); + + b.HasKey("ClusterId", "Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Kerberos") + .HasColumnType("nvarchar(450)"); + + b.HasKey("ClusterId", "Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("nvarchar(300)"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique() + .HasFilter("[Iam] IS NOT NULL"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/20240725161200_orderFieldLengths.cs b/Hippo.Core/Migrations/SqlServer/20240725161200_orderFieldLengths.cs new file mode 100644 index 00000000..a05d933b --- /dev/null +++ b/Hippo.Core/Migrations/SqlServer/20240725161200_orderFieldLengths.cs @@ -0,0 +1,213 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.SqlServer +{ + public partial class orderFieldLengths : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Units", + table: "Products", + type: "nvarchar(50)", + maxLength: 50, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TrackingNumber", + table: "Payments", + type: "nvarchar(20)", + maxLength: 20, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Status", + table: "Payments", + type: "nvarchar(20)", + maxLength: 20, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(450)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FinancialSystemId", + table: "Payments", + type: "nvarchar(128)", + maxLength: 128, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Details", + table: "Payments", + type: "nvarchar(250)", + maxLength: 250, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Units", + table: "Orders", + type: "nvarchar(50)", + maxLength: 50, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Status", + table: "Orders", + type: "nvarchar(20)", + maxLength: 20, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(450)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "SecretAccessKey", + table: "FinancialDetails", + type: "nvarchar(200)", + maxLength: 200, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ChartString", + table: "FinancialDetails", + type: "nvarchar(128)", + maxLength: 128, + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ChartString", + table: "Billings", + type: "nvarchar(128)", + maxLength: 128, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Units", + table: "Products", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(50)", + oldMaxLength: 50, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "TrackingNumber", + table: "Payments", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(20)", + oldMaxLength: 20, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Status", + table: "Payments", + type: "nvarchar(450)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(20)", + oldMaxLength: 20, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "FinancialSystemId", + table: "Payments", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(128)", + oldMaxLength: 128, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Details", + table: "Payments", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(250)", + oldMaxLength: 250, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Units", + table: "Orders", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(50)", + oldMaxLength: 50, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "Status", + table: "Orders", + type: "nvarchar(450)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(20)", + oldMaxLength: 20, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "SecretAccessKey", + table: "FinancialDetails", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(200)", + oldMaxLength: 200, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ChartString", + table: "FinancialDetails", + type: "nvarchar(max)", + nullable: true, + oldClrType: typeof(string), + oldType: "nvarchar(128)", + oldMaxLength: 128, + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "ChartString", + table: "Billings", + type: "nvarchar(max)", + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(128)", + oldMaxLength: 128); + } + } +} diff --git a/Hippo.Core/Migrations/SqlServer/AppDbContextSqlServerModelSnapshot.cs b/Hippo.Core/Migrations/SqlServer/AppDbContextSqlServerModelSnapshot.cs index 747c82de..c6df37b3 100644 --- a/Hippo.Core/Migrations/SqlServer/AppDbContextSqlServerModelSnapshot.cs +++ b/Hippo.Core/Migrations/SqlServer/AppDbContextSqlServerModelSnapshot.cs @@ -130,6 +130,35 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Accounts"); }); + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("ChartString") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Updated") + .HasColumnType("datetime2"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => { b.Property("Id") @@ -180,6 +209,43 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Clusters"); }); + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("SecretAccessKey") + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + modelBuilder.Entity("Hippo.Core.Domain.Group", b => { b.Property("Id") @@ -268,10 +334,17 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Details") .HasColumnType("nvarchar(max)"); + b.Property("OrderId") + .HasColumnType("int"); + b.Property("Status") .HasMaxLength(50) .HasColumnType("nvarchar(50)"); + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + b.HasKey("Id"); b.HasIndex("ActedById"); @@ -282,9 +355,202 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("ClusterId"); + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + b.ToTable("Histories"); }); + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Adjustment") + .HasColumnType("decimal(18,2)"); + + b.Property("AdjustmentReason") + .HasColumnType("nvarchar(max)"); + + b.Property("AdminNotes") + .HasColumnType("nvarchar(max)"); + + b.Property("BalanceRemaining") + .HasColumnType("decimal(18,2)"); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("ExpirationDate") + .HasColumnType("datetime2"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.Property("InstallmentDate") + .HasColumnType("datetime2"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("LifeCycle") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("NextNotificationDate") + .HasColumnType("datetime2"); + + b.Property("NextPaymentDate") + .HasColumnType("datetime2"); + + b.Property("Notes") + .HasColumnType("nvarchar(max)"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("int"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Quantity") + .HasColumnType("decimal(18,2)"); + + b.Property("Status") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("SubTotal") + .HasColumnType("decimal(18,2)"); + + b.Property("Total") + .HasColumnType("decimal(18,2)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("ExpirationDate"); + + b.HasIndex("NextNotificationDate"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.HasIndex("Status"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Amount") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedById") + .HasColumnType("int"); + + b.Property("CreatedOn") + .HasColumnType("datetime2"); + + b.Property("Details") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("FinancialSystemId") + .HasMaxLength(128) + .HasColumnType("nvarchar(128)"); + + b.Property("OrderId") + .HasColumnType("int"); + + b.Property("Status") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.Property("TrackingNumber") + .HasMaxLength(20) + .HasColumnType("nvarchar(20)"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.HasIndex("Status"); + + b.ToTable("Payments"); + }); + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => { b.Property("Id") @@ -313,6 +579,63 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Permissions"); }); + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1); + + b.Property("Category") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ClusterId") + .HasColumnType("int"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("nvarchar(250)"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("nvarchar(10)"); + + b.Property("Installments") + .HasColumnType("int"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("datetime2"); + + b.Property("LifeCycle") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("UnitPrice") + .HasColumnType("decimal(18,2)"); + + b.Property("Units") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => { b.Property("Id") @@ -564,6 +887,28 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Owner"); }); + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + modelBuilder.Entity("Hippo.Core.Domain.Group", b => { b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") @@ -625,9 +970,63 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasForeignKey("ClusterId") .OnDelete(DeleteBehavior.Restrict); + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + b.Navigation("ActedBy"); b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); }); modelBuilder.Entity("Hippo.Core.Domain.Permission", b => @@ -656,6 +1055,17 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("User"); }); + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => { b.HasOne("Hippo.Core.Domain.Request", "Request") @@ -692,11 +1102,33 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Requester"); }); + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Navigation("Orders"); + }); + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => { b.Navigation("Accounts"); + b.Navigation("FinancialDetail"); + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); }); modelBuilder.Entity("Hippo.Core.Domain.Request", b => diff --git a/Hippo.Core/Migrations/Sqlite/20240501195617_Orders20240501.Designer.cs b/Hippo.Core/Migrations/Sqlite/20240501195617_Orders20240501.Designer.cs new file mode 100644 index 00000000..6f8edc3d --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240501195617_Orders20240501.Designer.cs @@ -0,0 +1,1045 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + [DbContext(typeof(AppDbContextSqlite))] + [Migration("20240501195617_Orders20240501")] + partial class Orders20240501 + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.19"); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("AccountsId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("ClustersId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("OwnerId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Percentage") + .HasColumnType("TEXT"); + + b.Property("Updated") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ActedById") + .HasColumnType("INTEGER"); + + b.Property("ActedDate") + .HasColumnType("TEXT"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("AdminAction") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("OrderId1") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId1"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Adjustment") + .HasColumnType("TEXT"); + + b.Property("AdjustmentReason") + .HasColumnType("TEXT"); + + b.Property("AdminNotes") + .HasColumnType("TEXT"); + + b.Property("BalanceRemaining") + .HasColumnType("TEXT"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Notes") + .HasColumnType("TEXT"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("SubTotal") + .HasColumnType("TEXT"); + + b.Property("Total") + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Amount") + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("FinancialSystemId") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("TrackingNumber") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("RoleId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("ErrorMessage") + .HasColumnType("TEXT"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ActorId") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("RequesterId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("TEXT"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("TEXT"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique(); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Order", null) + .WithMany("History") + .HasForeignKey("OrderId1"); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Orders"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240501195617_Orders20240501.cs b/Hippo.Core/Migrations/Sqlite/20240501195617_Orders20240501.cs new file mode 100644 index 00000000..061dc061 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240501195617_Orders20240501.cs @@ -0,0 +1,305 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + public partial class Orders20240501 : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "OrderId", + table: "Histories", + type: "INTEGER", + nullable: true); + + migrationBuilder.AddColumn( + name: "OrderId1", + table: "Histories", + type: "INTEGER", + nullable: true); + + migrationBuilder.CreateTable( + name: "FinancialDetails", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + AutoApprove = table.Column(type: "INTEGER", nullable: false, defaultValue: true), + ClusterId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_FinancialDetails", x => x.Id); + table.ForeignKey( + name: "FK_FinancialDetails_Clusters_ClusterId", + column: x => x.ClusterId, + principalTable: "Clusters", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Orders", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + Category = table.Column(type: "TEXT", nullable: false), + Name = table.Column(type: "TEXT", maxLength: 50, nullable: false), + Description = table.Column(type: "TEXT", maxLength: 250, nullable: true), + ExternalReference = table.Column(type: "TEXT", maxLength: 150, nullable: true), + Units = table.Column(type: "TEXT", nullable: true), + UnitPrice = table.Column(type: "TEXT", nullable: false), + Quantity = table.Column(type: "TEXT", nullable: false), + Installments = table.Column(type: "INTEGER", nullable: false), + Adjustment = table.Column(type: "TEXT", nullable: false), + AdjustmentReason = table.Column(type: "TEXT", nullable: true), + SubTotal = table.Column(type: "TEXT", nullable: false), + Total = table.Column(type: "TEXT", nullable: false), + BalanceRemaining = table.Column(type: "TEXT", nullable: false), + Notes = table.Column(type: "TEXT", nullable: true), + AdminNotes = table.Column(type: "TEXT", nullable: true), + Status = table.Column(type: "TEXT", nullable: true), + ClusterId = table.Column(type: "INTEGER", nullable: false), + PrincipalInvestigatorId = table.Column(type: "INTEGER", nullable: false), + CreatedOn = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Orders", x => x.Id); + table.ForeignKey( + name: "FK_Orders_Clusters_ClusterId", + column: x => x.ClusterId, + principalTable: "Clusters", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_Orders_Users_PrincipalInvestigatorId", + column: x => x.PrincipalInvestigatorId, + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Products", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + IsActive = table.Column(type: "INTEGER", nullable: false, defaultValue: true), + Category = table.Column(type: "TEXT", nullable: false), + Name = table.Column(type: "TEXT", maxLength: 50, nullable: false), + Description = table.Column(type: "TEXT", maxLength: 250, nullable: true), + Units = table.Column(type: "TEXT", nullable: true), + UnitPrice = table.Column(type: "TEXT", nullable: false), + Installments = table.Column(type: "INTEGER", nullable: false), + LastUpdated = table.Column(type: "TEXT", nullable: false), + ClusterId = table.Column(type: "INTEGER", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Products", x => x.Id); + table.ForeignKey( + name: "FK_Products_Clusters_ClusterId", + column: x => x.ClusterId, + principalTable: "Clusters", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Billings", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + ChartString = table.Column(type: "TEXT", nullable: false), + Percentage = table.Column(type: "TEXT", nullable: false), + OrderId = table.Column(type: "INTEGER", nullable: false), + Updated = table.Column(type: "TEXT", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Billings", x => x.Id); + table.ForeignKey( + name: "FK_Billings_Orders_OrderId", + column: x => x.OrderId, + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "MetaData", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + OrderId = table.Column(type: "INTEGER", nullable: false), + Name = table.Column(type: "TEXT", maxLength: 128, nullable: false), + Value = table.Column(type: "TEXT", maxLength: 450, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MetaData", x => x.Id); + table.ForeignKey( + name: "FK_MetaData_Orders_OrderId", + column: x => x.OrderId, + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Payments", + columns: table => new + { + Id = table.Column(type: "INTEGER", nullable: false) + .Annotation("Sqlite:Autoincrement", true), + FinancialSystemId = table.Column(type: "TEXT", nullable: true), + TrackingNumber = table.Column(type: "TEXT", nullable: true), + CreatedOn = table.Column(type: "TEXT", nullable: false), + Amount = table.Column(type: "TEXT", nullable: false), + Status = table.Column(type: "TEXT", nullable: true), + Details = table.Column(type: "TEXT", nullable: true), + OrderId = table.Column(type: "INTEGER", nullable: false), + CreatedById = table.Column(type: "INTEGER", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Payments", x => x.Id); + table.ForeignKey( + name: "FK_Payments_Orders_OrderId", + column: x => x.OrderId, + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Payments_Users_CreatedById", + column: x => x.CreatedById, + principalTable: "Users", + principalColumn: "Id"); + }); + + migrationBuilder.CreateIndex( + name: "IX_Histories_OrderId", + table: "Histories", + column: "OrderId"); + + migrationBuilder.CreateIndex( + name: "IX_Histories_OrderId1", + table: "Histories", + column: "OrderId1"); + + migrationBuilder.CreateIndex( + name: "IX_Billings_OrderId", + table: "Billings", + column: "OrderId"); + + migrationBuilder.CreateIndex( + name: "IX_FinancialDetails_ClusterId", + table: "FinancialDetails", + column: "ClusterId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_MetaData_OrderId", + table: "MetaData", + column: "OrderId"); + + migrationBuilder.CreateIndex( + name: "IX_MetaData_OrderId_Name_Value", + table: "MetaData", + columns: new[] { "OrderId", "Name", "Value" }); + + migrationBuilder.CreateIndex( + name: "IX_Orders_ClusterId", + table: "Orders", + column: "ClusterId"); + + migrationBuilder.CreateIndex( + name: "IX_Orders_PrincipalInvestigatorId", + table: "Orders", + column: "PrincipalInvestigatorId"); + + migrationBuilder.CreateIndex( + name: "IX_Payments_CreatedById", + table: "Payments", + column: "CreatedById"); + + migrationBuilder.CreateIndex( + name: "IX_Payments_OrderId", + table: "Payments", + column: "OrderId"); + + migrationBuilder.CreateIndex( + name: "IX_Products_ClusterId", + table: "Products", + column: "ClusterId"); + + migrationBuilder.AddForeignKey( + name: "FK_Histories_Orders_OrderId", + table: "Histories", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Histories_Orders_OrderId1", + table: "Histories", + column: "OrderId1", + principalTable: "Orders", + principalColumn: "Id"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Histories_Orders_OrderId", + table: "Histories"); + + migrationBuilder.DropForeignKey( + name: "FK_Histories_Orders_OrderId1", + table: "Histories"); + + migrationBuilder.DropTable( + name: "Billings"); + + migrationBuilder.DropTable( + name: "FinancialDetails"); + + migrationBuilder.DropTable( + name: "MetaData"); + + migrationBuilder.DropTable( + name: "Payments"); + + migrationBuilder.DropTable( + name: "Products"); + + migrationBuilder.DropTable( + name: "Orders"); + + migrationBuilder.DropIndex( + name: "IX_Histories_OrderId", + table: "Histories"); + + migrationBuilder.DropIndex( + name: "IX_Histories_OrderId1", + table: "Histories"); + + migrationBuilder.DropColumn( + name: "OrderId", + table: "Histories"); + + migrationBuilder.DropColumn( + name: "OrderId1", + table: "Histories"); + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240501203025_FixFinancialDetail.Designer.cs b/Hippo.Core/Migrations/Sqlite/20240501203025_FixFinancialDetail.Designer.cs new file mode 100644 index 00000000..2395bbd3 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240501203025_FixFinancialDetail.Designer.cs @@ -0,0 +1,1056 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + [DbContext(typeof(AppDbContextSqlite))] + [Migration("20240501203025_FixFinancialDetail")] + partial class FixFinancialDetail + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.19"); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("AccountsId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("ClustersId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("OwnerId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Percentage") + .HasColumnType("TEXT"); + + b.Property("Updated") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("FinancialSystemApiKey") + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("FinancialSystemApiSource") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ActedById") + .HasColumnType("INTEGER"); + + b.Property("ActedDate") + .HasColumnType("TEXT"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("AdminAction") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("OrderId1") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId1"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Adjustment") + .HasColumnType("TEXT"); + + b.Property("AdjustmentReason") + .HasColumnType("TEXT"); + + b.Property("AdminNotes") + .HasColumnType("TEXT"); + + b.Property("BalanceRemaining") + .HasColumnType("TEXT"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Notes") + .HasColumnType("TEXT"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("SubTotal") + .HasColumnType("TEXT"); + + b.Property("Total") + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Amount") + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("FinancialSystemId") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("TrackingNumber") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("RoleId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("ErrorMessage") + .HasColumnType("TEXT"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ActorId") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("RequesterId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("TEXT"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("TEXT"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique(); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Order", null) + .WithMany("History") + .HasForeignKey("OrderId1"); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Orders"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240501203025_FixFinancialDetail.cs b/Hippo.Core/Migrations/Sqlite/20240501203025_FixFinancialDetail.cs new file mode 100644 index 00000000..42133b26 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240501203025_FixFinancialDetail.cs @@ -0,0 +1,47 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + public partial class FixFinancialDetail : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ChartString", + table: "FinancialDetails", + type: "TEXT", + nullable: true); + + migrationBuilder.AddColumn( + name: "FinancialSystemApiKey", + table: "FinancialDetails", + type: "TEXT", + maxLength: 128, + nullable: true); + + migrationBuilder.AddColumn( + name: "FinancialSystemApiSource", + table: "FinancialDetails", + type: "TEXT", + maxLength: 50, + nullable: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ChartString", + table: "FinancialDetails"); + + migrationBuilder.DropColumn( + name: "FinancialSystemApiKey", + table: "FinancialDetails"); + + migrationBuilder.DropColumn( + name: "FinancialSystemApiSource", + table: "FinancialDetails"); + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240501223931_useSecretFinancilDetail.Designer.cs b/Hippo.Core/Migrations/Sqlite/20240501223931_useSecretFinancilDetail.Designer.cs new file mode 100644 index 00000000..cb9e99d9 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240501223931_useSecretFinancilDetail.Designer.cs @@ -0,0 +1,1056 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + [DbContext(typeof(AppDbContextSqlite))] + [Migration("20240501223931_useSecretFinancilDetail")] + partial class useSecretFinancilDetail + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.19"); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("AccountsId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("ClustersId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("OwnerId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Percentage") + .HasColumnType("TEXT"); + + b.Property("Updated") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SecretAccessKey") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ActedById") + .HasColumnType("INTEGER"); + + b.Property("ActedDate") + .HasColumnType("TEXT"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("AdminAction") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("OrderId1") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId1"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Adjustment") + .HasColumnType("TEXT"); + + b.Property("AdjustmentReason") + .HasColumnType("TEXT"); + + b.Property("AdminNotes") + .HasColumnType("TEXT"); + + b.Property("BalanceRemaining") + .HasColumnType("TEXT"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Notes") + .HasColumnType("TEXT"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("SubTotal") + .HasColumnType("TEXT"); + + b.Property("Total") + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Amount") + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("FinancialSystemId") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("TrackingNumber") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("RoleId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("ErrorMessage") + .HasColumnType("TEXT"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ActorId") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("RequesterId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("TEXT"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("TEXT"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique(); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany() + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Order", null) + .WithMany("History") + .HasForeignKey("OrderId1"); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Orders"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240501223931_useSecretFinancilDetail.cs b/Hippo.Core/Migrations/Sqlite/20240501223931_useSecretFinancilDetail.cs new file mode 100644 index 00000000..5fc498d9 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240501223931_useSecretFinancilDetail.cs @@ -0,0 +1,60 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + public partial class useSecretFinancilDetail : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "FinancialSystemApiKey", + table: "FinancialDetails"); + + migrationBuilder.AlterColumn( + name: "FinancialSystemApiSource", + table: "FinancialDetails", + type: "TEXT", + maxLength: 50, + nullable: false, + defaultValue: "", + oldClrType: typeof(string), + oldType: "TEXT", + oldMaxLength: 50, + oldNullable: true); + + migrationBuilder.AddColumn( + name: "SecretAccessKey", + table: "FinancialDetails", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000")); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "SecretAccessKey", + table: "FinancialDetails"); + + migrationBuilder.AlterColumn( + name: "FinancialSystemApiSource", + table: "FinancialDetails", + type: "TEXT", + maxLength: 50, + nullable: true, + oldClrType: typeof(string), + oldType: "TEXT", + oldMaxLength: 50); + + migrationBuilder.AddColumn( + name: "FinancialSystemApiKey", + table: "FinancialDetails", + type: "TEXT", + maxLength: 128, + nullable: true); + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240514163029_FixHistoryRelationship.Designer.cs b/Hippo.Core/Migrations/Sqlite/20240514163029_FixHistoryRelationship.Designer.cs new file mode 100644 index 00000000..07666d04 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240514163029_FixHistoryRelationship.Designer.cs @@ -0,0 +1,1046 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + [DbContext(typeof(AppDbContextSqlite))] + [Migration("20240514163029_FixHistoryRelationship")] + partial class FixHistoryRelationship + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.19"); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("AccountsId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("ClustersId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("OwnerId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Percentage") + .HasColumnType("TEXT"); + + b.Property("Updated") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SecretAccessKey") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ActedById") + .HasColumnType("INTEGER"); + + b.Property("ActedDate") + .HasColumnType("TEXT"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("AdminAction") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Adjustment") + .HasColumnType("TEXT"); + + b.Property("AdjustmentReason") + .HasColumnType("TEXT"); + + b.Property("AdminNotes") + .HasColumnType("TEXT"); + + b.Property("BalanceRemaining") + .HasColumnType("TEXT"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Notes") + .HasColumnType("TEXT"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("SubTotal") + .HasColumnType("TEXT"); + + b.Property("Total") + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Amount") + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("FinancialSystemId") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("TrackingNumber") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("RoleId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("ErrorMessage") + .HasColumnType("TEXT"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ActorId") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("RequesterId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("TEXT"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("TEXT"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique(); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId"); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Orders"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240514163029_FixHistoryRelationship.cs b/Hippo.Core/Migrations/Sqlite/20240514163029_FixHistoryRelationship.cs new file mode 100644 index 00000000..f0b10848 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240514163029_FixHistoryRelationship.cs @@ -0,0 +1,68 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + public partial class FixHistoryRelationship : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Histories_Orders_OrderId", + table: "Histories"); + + migrationBuilder.DropForeignKey( + name: "FK_Histories_Orders_OrderId1", + table: "Histories"); + + migrationBuilder.DropIndex( + name: "IX_Histories_OrderId1", + table: "Histories"); + + migrationBuilder.DropColumn( + name: "OrderId1", + table: "Histories"); + + migrationBuilder.AddForeignKey( + name: "FK_Histories_Orders_OrderId", + table: "Histories", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Histories_Orders_OrderId", + table: "Histories"); + + migrationBuilder.AddColumn( + name: "OrderId1", + table: "Histories", + type: "INTEGER", + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_Histories_OrderId1", + table: "Histories", + column: "OrderId1"); + + migrationBuilder.AddForeignKey( + name: "FK_Histories_Orders_OrderId", + table: "Histories", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Histories_Orders_OrderId1", + table: "Histories", + column: "OrderId1", + principalTable: "Orders", + principalColumn: "Id"); + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240515143203_AddHistoryFlag.Designer.cs b/Hippo.Core/Migrations/Sqlite/20240515143203_AddHistoryFlag.Designer.cs new file mode 100644 index 00000000..95ddf6a5 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240515143203_AddHistoryFlag.Designer.cs @@ -0,0 +1,1049 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + [DbContext(typeof(AppDbContextSqlite))] + [Migration("20240515143203_AddHistoryFlag")] + partial class AddHistoryFlag + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.19"); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("AccountsId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("ClustersId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("OwnerId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Percentage") + .HasColumnType("TEXT"); + + b.Property("Updated") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SecretAccessKey") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ActedById") + .HasColumnType("INTEGER"); + + b.Property("ActedDate") + .HasColumnType("TEXT"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("AdminAction") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("ShowToUser") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Adjustment") + .HasColumnType("TEXT"); + + b.Property("AdjustmentReason") + .HasColumnType("TEXT"); + + b.Property("AdminNotes") + .HasColumnType("TEXT"); + + b.Property("BalanceRemaining") + .HasColumnType("TEXT"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Notes") + .HasColumnType("TEXT"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("SubTotal") + .HasColumnType("TEXT"); + + b.Property("Total") + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Amount") + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("FinancialSystemId") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("TrackingNumber") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("RoleId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("ErrorMessage") + .HasColumnType("TEXT"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ActorId") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("RequesterId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("TEXT"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("TEXT"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique(); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId"); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Orders"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240515143203_AddHistoryFlag.cs b/Hippo.Core/Migrations/Sqlite/20240515143203_AddHistoryFlag.cs new file mode 100644 index 00000000..673e4cc8 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240515143203_AddHistoryFlag.cs @@ -0,0 +1,26 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + public partial class AddHistoryFlag : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "ShowToUser", + table: "Histories", + type: "INTEGER", + nullable: false, + defaultValue: false); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ShowToUser", + table: "Histories"); + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240515155507_ReplaceFlagWithType.Designer.cs b/Hippo.Core/Migrations/Sqlite/20240515155507_ReplaceFlagWithType.Designer.cs new file mode 100644 index 00000000..d900f913 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240515155507_ReplaceFlagWithType.Designer.cs @@ -0,0 +1,1052 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + [DbContext(typeof(AppDbContextSqlite))] + [Migration("20240515155507_ReplaceFlagWithType")] + partial class ReplaceFlagWithType + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.19"); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("AccountsId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("ClustersId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("OwnerId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Percentage") + .HasColumnType("TEXT"); + + b.Property("Updated") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SecretAccessKey") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ActedById") + .HasColumnType("INTEGER"); + + b.Property("ActedDate") + .HasColumnType("TEXT"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("AdminAction") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Adjustment") + .HasColumnType("TEXT"); + + b.Property("AdjustmentReason") + .HasColumnType("TEXT"); + + b.Property("AdminNotes") + .HasColumnType("TEXT"); + + b.Property("BalanceRemaining") + .HasColumnType("TEXT"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Notes") + .HasColumnType("TEXT"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("INTEGER"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("SubTotal") + .HasColumnType("TEXT"); + + b.Property("Total") + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Amount") + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("FinancialSystemId") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("TrackingNumber") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("RoleId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("ErrorMessage") + .HasColumnType("TEXT"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ActorId") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("RequesterId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("TEXT"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("TEXT"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique(); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId"); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Orders"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240515155507_ReplaceFlagWithType.cs b/Hippo.Core/Migrations/Sqlite/20240515155507_ReplaceFlagWithType.cs new file mode 100644 index 00000000..141b542d --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240515155507_ReplaceFlagWithType.cs @@ -0,0 +1,46 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + public partial class ReplaceFlagWithType : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "ShowToUser", + table: "Histories"); + + migrationBuilder.AddColumn( + name: "Type", + table: "Histories", + type: "TEXT", + maxLength: 50, + nullable: true); + + migrationBuilder.CreateIndex( + name: "IX_Histories_Type", + table: "Histories", + column: "Type"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_Histories_Type", + table: "Histories"); + + migrationBuilder.DropColumn( + name: "Type", + table: "Histories"); + + migrationBuilder.AddColumn( + name: "ShowToUser", + table: "Histories", + type: "INTEGER", + nullable: false, + defaultValue: false); + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240522172601_AddOrderFields.Designer.cs b/Hippo.Core/Migrations/Sqlite/20240522172601_AddOrderFields.Designer.cs new file mode 100644 index 00000000..ec8c73e0 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240522172601_AddOrderFields.Designer.cs @@ -0,0 +1,1067 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + [DbContext(typeof(AppDbContextSqlite))] + [Migration("20240522172601_AddOrderFields")] + partial class AddOrderFields + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.19"); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("AccountsId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("ClustersId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("OwnerId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Percentage") + .HasColumnType("TEXT"); + + b.Property("Updated") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SecretAccessKey") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ActedById") + .HasColumnType("INTEGER"); + + b.Property("ActedDate") + .HasColumnType("TEXT"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("AdminAction") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Adjustment") + .HasColumnType("TEXT"); + + b.Property("AdjustmentReason") + .HasColumnType("TEXT"); + + b.Property("AdminNotes") + .HasColumnType("TEXT"); + + b.Property("BalanceRemaining") + .HasColumnType("TEXT"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("TEXT"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Notes") + .HasColumnType("TEXT"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("INTEGER"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("SubTotal") + .HasColumnType("TEXT"); + + b.Property("Total") + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Amount") + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("FinancialSystemId") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("TrackingNumber") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("RoleId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("ErrorMessage") + .HasColumnType("TEXT"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ActorId") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("RequesterId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("TEXT"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("TEXT"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique(); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId"); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Orders"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240522172601_AddOrderFields.cs b/Hippo.Core/Migrations/Sqlite/20240522172601_AddOrderFields.cs new file mode 100644 index 00000000..de57f1b7 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240522172601_AddOrderFields.cs @@ -0,0 +1,51 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + public partial class AddOrderFields : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "InstallmentType", + table: "Products", + type: "TEXT", + maxLength: 10, + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "InstallmentType", + table: "Orders", + type: "TEXT", + maxLength: 10, + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "ProductName", + table: "Orders", + type: "TEXT", + maxLength: 50, + nullable: false, + defaultValue: ""); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "InstallmentType", + table: "Products"); + + migrationBuilder.DropColumn( + name: "InstallmentType", + table: "Orders"); + + migrationBuilder.DropColumn( + name: "ProductName", + table: "Orders"); + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240605140335_ChangePiToBeAccount.Designer.cs b/Hippo.Core/Migrations/Sqlite/20240605140335_ChangePiToBeAccount.Designer.cs new file mode 100644 index 00000000..e7c3b706 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240605140335_ChangePiToBeAccount.Designer.cs @@ -0,0 +1,1070 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + [DbContext(typeof(AppDbContextSqlite))] + [Migration("20240605140335_ChangePiToBeAccount")] + partial class ChangePiToBeAccount + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.19"); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("AccountsId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("ClustersId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("OwnerId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Percentage") + .HasColumnType("TEXT"); + + b.Property("Updated") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SecretAccessKey") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ActedById") + .HasColumnType("INTEGER"); + + b.Property("ActedDate") + .HasColumnType("TEXT"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("AdminAction") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Adjustment") + .HasColumnType("TEXT"); + + b.Property("AdjustmentReason") + .HasColumnType("TEXT"); + + b.Property("AdminNotes") + .HasColumnType("TEXT"); + + b.Property("BalanceRemaining") + .HasColumnType("TEXT"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("TEXT"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Notes") + .HasColumnType("TEXT"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("INTEGER"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("SubTotal") + .HasColumnType("TEXT"); + + b.Property("Total") + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Amount") + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("FinancialSystemId") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("TrackingNumber") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("RoleId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("ErrorMessage") + .HasColumnType("TEXT"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ActorId") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("RequesterId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("TEXT"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("TEXT"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique(); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId"); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240605140335_ChangePiToBeAccount.cs b/Hippo.Core/Migrations/Sqlite/20240605140335_ChangePiToBeAccount.cs new file mode 100644 index 00000000..8040af4f --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240605140335_ChangePiToBeAccount.cs @@ -0,0 +1,39 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + public partial class ChangePiToBeAccount : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Users_PrincipalInvestigatorId", + table: "Orders"); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Accounts_PrincipalInvestigatorId", + table: "Orders", + column: "PrincipalInvestigatorId", + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Accounts_PrincipalInvestigatorId", + table: "Orders"); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Users_PrincipalInvestigatorId", + table: "Orders", + column: "PrincipalInvestigatorId", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240606174430_NewProductAndOrderFields.Designer.cs b/Hippo.Core/Migrations/Sqlite/20240606174430_NewProductAndOrderFields.Designer.cs new file mode 100644 index 00000000..8db568f5 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240606174430_NewProductAndOrderFields.Designer.cs @@ -0,0 +1,1082 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + [DbContext(typeof(AppDbContextSqlite))] + [Migration("20240606174430_NewProductAndOrderFields")] + partial class NewProductAndOrderFields + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.19"); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("AccountsId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("ClustersId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("OwnerId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Percentage") + .HasColumnType("TEXT"); + + b.Property("Updated") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SecretAccessKey") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ActedById") + .HasColumnType("INTEGER"); + + b.Property("ActedDate") + .HasColumnType("TEXT"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("AdminAction") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Adjustment") + .HasColumnType("TEXT"); + + b.Property("AdjustmentReason") + .HasColumnType("TEXT"); + + b.Property("AdminNotes") + .HasColumnType("TEXT"); + + b.Property("BalanceRemaining") + .HasColumnType("TEXT"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("ExpirationDate") + .HasColumnType("TEXT"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("TEXT"); + + b.Property("InstallmentDate") + .HasColumnType("TEXT"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("LifeCycle") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Notes") + .HasColumnType("TEXT"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("INTEGER"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("SubTotal") + .HasColumnType("TEXT"); + + b.Property("Total") + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Amount") + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("FinancialSystemId") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("TrackingNumber") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("RoleId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("TEXT"); + + b.Property("LifeCycle") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("ErrorMessage") + .HasColumnType("TEXT"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ActorId") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("RequesterId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("TEXT"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("TEXT"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique(); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId"); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240606174430_NewProductAndOrderFields.cs b/Hippo.Core/Migrations/Sqlite/20240606174430_NewProductAndOrderFields.cs new file mode 100644 index 00000000..79c49bd7 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240606174430_NewProductAndOrderFields.cs @@ -0,0 +1,58 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + public partial class NewProductAndOrderFields : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "LifeCycle", + table: "Products", + type: "INTEGER", + nullable: false, + defaultValue: 0); + + migrationBuilder.AddColumn( + name: "ExpirationDate", + table: "Orders", + type: "TEXT", + nullable: true); + + migrationBuilder.AddColumn( + name: "InstallmentDate", + table: "Orders", + type: "TEXT", + nullable: true); + + migrationBuilder.AddColumn( + name: "LifeCycle", + table: "Orders", + type: "INTEGER", + nullable: false, + defaultValue: 0); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "LifeCycle", + table: "Products"); + + migrationBuilder.DropColumn( + name: "ExpirationDate", + table: "Orders"); + + migrationBuilder.DropColumn( + name: "InstallmentDate", + table: "Orders"); + + migrationBuilder.DropColumn( + name: "LifeCycle", + table: "Orders"); + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240628162059_OrderDates.Designer.cs b/Hippo.Core/Migrations/Sqlite/20240628162059_OrderDates.Designer.cs new file mode 100644 index 00000000..6df66eaa --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240628162059_OrderDates.Designer.cs @@ -0,0 +1,1088 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + [DbContext(typeof(AppDbContextSqlite))] + [Migration("20240628162059_OrderDates")] + partial class OrderDates + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.19"); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("AccountsId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("ClustersId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("OwnerId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Percentage") + .HasColumnType("TEXT"); + + b.Property("Updated") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SecretAccessKey") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ActedById") + .HasColumnType("INTEGER"); + + b.Property("ActedDate") + .HasColumnType("TEXT"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("AdminAction") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Adjustment") + .HasColumnType("TEXT"); + + b.Property("AdjustmentReason") + .HasColumnType("TEXT"); + + b.Property("AdminNotes") + .HasColumnType("TEXT"); + + b.Property("BalanceRemaining") + .HasColumnType("TEXT"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("ExpirationDate") + .HasColumnType("TEXT"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("TEXT"); + + b.Property("InstallmentDate") + .HasColumnType("TEXT"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("LifeCycle") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("NextNotificationDate") + .HasColumnType("TEXT"); + + b.Property("NextPaymentDate") + .HasColumnType("TEXT"); + + b.Property("Notes") + .HasColumnType("TEXT"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("INTEGER"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("SubTotal") + .HasColumnType("TEXT"); + + b.Property("Total") + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Amount") + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("FinancialSystemId") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("TrackingNumber") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("RoleId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("TEXT"); + + b.Property("LifeCycle") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("ErrorMessage") + .HasColumnType("TEXT"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ActorId") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("RequesterId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("TEXT"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("TEXT"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique(); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId"); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240628162059_OrderDates.cs b/Hippo.Core/Migrations/Sqlite/20240628162059_OrderDates.cs new file mode 100644 index 00000000..e598f79c --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240628162059_OrderDates.cs @@ -0,0 +1,36 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + public partial class OrderDates : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "NextNotificationDate", + table: "Orders", + type: "TEXT", + nullable: true); + + migrationBuilder.AddColumn( + name: "NextPaymentDate", + table: "Orders", + type: "TEXT", + nullable: true); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "NextNotificationDate", + table: "Orders"); + + migrationBuilder.DropColumn( + name: "NextPaymentDate", + table: "Orders"); + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240711213913_OrderHistory.Designer.cs b/Hippo.Core/Migrations/Sqlite/20240711213913_OrderHistory.Designer.cs new file mode 100644 index 00000000..272b8e4c --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240711213913_OrderHistory.Designer.cs @@ -0,0 +1,1089 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + [DbContext(typeof(AppDbContextSqlite))] + [Migration("20240711213913_OrderHistory")] + partial class OrderHistory + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.19"); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("AccountsId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("ClustersId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("OwnerId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Percentage") + .HasColumnType("TEXT"); + + b.Property("Updated") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SecretAccessKey") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ActedById") + .HasColumnType("INTEGER"); + + b.Property("ActedDate") + .HasColumnType("TEXT"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("AdminAction") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Adjustment") + .HasColumnType("TEXT"); + + b.Property("AdjustmentReason") + .HasColumnType("TEXT"); + + b.Property("AdminNotes") + .HasColumnType("TEXT"); + + b.Property("BalanceRemaining") + .HasColumnType("TEXT"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("ExpirationDate") + .HasColumnType("TEXT"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("TEXT"); + + b.Property("InstallmentDate") + .HasColumnType("TEXT"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("LifeCycle") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("NextNotificationDate") + .HasColumnType("TEXT"); + + b.Property("NextPaymentDate") + .HasColumnType("TEXT"); + + b.Property("Notes") + .HasColumnType("TEXT"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("INTEGER"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("SubTotal") + .HasColumnType("TEXT"); + + b.Property("Total") + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Amount") + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("FinancialSystemId") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("TrackingNumber") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("RoleId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("TEXT"); + + b.Property("LifeCycle") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("ErrorMessage") + .HasColumnType("TEXT"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ActorId") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("RequesterId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("Group") + .HasColumnType("TEXT"); + + b.HasKey("Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("Kerberos") + .HasColumnType("TEXT"); + + b.HasKey("Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique(); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240711213913_OrderHistory.cs b/Hippo.Core/Migrations/Sqlite/20240711213913_OrderHistory.cs new file mode 100644 index 00000000..8cbc9dbd --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240711213913_OrderHistory.cs @@ -0,0 +1,134 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + public partial class OrderHistory : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Billings_Orders_OrderId", + table: "Billings"); + + migrationBuilder.DropForeignKey( + name: "FK_Histories_Orders_OrderId", + table: "Histories"); + + migrationBuilder.DropForeignKey( + name: "FK_MetaData_Orders_OrderId", + table: "MetaData"); + + migrationBuilder.DropForeignKey( + name: "FK_Orders_Accounts_PrincipalInvestigatorId", + table: "Orders"); + + migrationBuilder.DropForeignKey( + name: "FK_Payments_Orders_OrderId", + table: "Payments"); + + migrationBuilder.AddForeignKey( + name: "FK_Billings_Orders_OrderId", + table: "Billings", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Histories_Orders_OrderId", + table: "Histories", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_MetaData_Orders_OrderId", + table: "MetaData", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Accounts_PrincipalInvestigatorId", + table: "Orders", + column: "PrincipalInvestigatorId", + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Payments_Orders_OrderId", + table: "Payments", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Billings_Orders_OrderId", + table: "Billings"); + + migrationBuilder.DropForeignKey( + name: "FK_Histories_Orders_OrderId", + table: "Histories"); + + migrationBuilder.DropForeignKey( + name: "FK_MetaData_Orders_OrderId", + table: "MetaData"); + + migrationBuilder.DropForeignKey( + name: "FK_Orders_Accounts_PrincipalInvestigatorId", + table: "Orders"); + + migrationBuilder.DropForeignKey( + name: "FK_Payments_Orders_OrderId", + table: "Payments"); + + migrationBuilder.AddForeignKey( + name: "FK_Billings_Orders_OrderId", + table: "Billings", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Histories_Orders_OrderId", + table: "Histories", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_MetaData_Orders_OrderId", + table: "MetaData", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Accounts_PrincipalInvestigatorId", + table: "Orders", + column: "PrincipalInvestigatorId", + principalTable: "Accounts", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Payments_Orders_OrderId", + table: "Payments", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240712152150_OrderIndexes.Designer.cs b/Hippo.Core/Migrations/Sqlite/20240712152150_OrderIndexes.Designer.cs new file mode 100644 index 00000000..ecdf7eb4 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240712152150_OrderIndexes.Designer.cs @@ -0,0 +1,1102 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + [DbContext(typeof(AppDbContextSqlite))] + [Migration("20240712152150_OrderIndexes")] + partial class OrderIndexes + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.19"); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("AccountsId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("ClustersId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("OwnerId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Percentage") + .HasColumnType("TEXT"); + + b.Property("Updated") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SecretAccessKey") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ActedById") + .HasColumnType("INTEGER"); + + b.Property("ActedDate") + .HasColumnType("TEXT"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("AdminAction") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Adjustment") + .HasColumnType("TEXT"); + + b.Property("AdjustmentReason") + .HasColumnType("TEXT"); + + b.Property("AdminNotes") + .HasColumnType("TEXT"); + + b.Property("BalanceRemaining") + .HasColumnType("TEXT"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("ExpirationDate") + .HasColumnType("TEXT"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("TEXT"); + + b.Property("InstallmentDate") + .HasColumnType("TEXT"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("LifeCycle") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("NextNotificationDate") + .HasColumnType("TEXT"); + + b.Property("NextPaymentDate") + .HasColumnType("TEXT"); + + b.Property("Notes") + .HasColumnType("TEXT"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("INTEGER"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("SubTotal") + .HasColumnType("TEXT"); + + b.Property("Total") + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("ExpirationDate"); + + b.HasIndex("NextNotificationDate"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.HasIndex("Status"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Amount") + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("FinancialSystemId") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("TrackingNumber") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.HasIndex("Status"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("RoleId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("TEXT"); + + b.Property("LifeCycle") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("ErrorMessage") + .HasColumnType("TEXT"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ActorId") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("RequesterId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Group") + .HasColumnType("TEXT"); + + b.HasKey("ClusterId", "Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Kerberos") + .HasColumnType("TEXT"); + + b.HasKey("ClusterId", "Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique(); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240712152150_OrderIndexes.cs b/Hippo.Core/Migrations/Sqlite/20240712152150_OrderIndexes.cs new file mode 100644 index 00000000..58aa9f05 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240712152150_OrderIndexes.cs @@ -0,0 +1,51 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + public partial class OrderIndexes : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateIndex( + name: "IX_Payments_Status", + table: "Payments", + column: "Status"); + + migrationBuilder.CreateIndex( + name: "IX_Orders_ExpirationDate", + table: "Orders", + column: "ExpirationDate"); + + migrationBuilder.CreateIndex( + name: "IX_Orders_NextNotificationDate", + table: "Orders", + column: "NextNotificationDate"); + + migrationBuilder.CreateIndex( + name: "IX_Orders_Status", + table: "Orders", + column: "Status"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "IX_Payments_Status", + table: "Payments"); + + migrationBuilder.DropIndex( + name: "IX_Orders_ExpirationDate", + table: "Orders"); + + migrationBuilder.DropIndex( + name: "IX_Orders_NextNotificationDate", + table: "Orders"); + + migrationBuilder.DropIndex( + name: "IX_Orders_Status", + table: "Orders"); + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240716175727_billingOrder.Designer.cs b/Hippo.Core/Migrations/Sqlite/20240716175727_billingOrder.Designer.cs new file mode 100644 index 00000000..634e1945 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240716175727_billingOrder.Designer.cs @@ -0,0 +1,1102 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + [DbContext(typeof(AppDbContextSqlite))] + [Migration("20240716175727_billingOrder")] + partial class billingOrder + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.19"); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("AccountsId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("ClustersId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("OwnerId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Percentage") + .HasColumnType("TEXT"); + + b.Property("Updated") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SecretAccessKey") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ActedById") + .HasColumnType("INTEGER"); + + b.Property("ActedDate") + .HasColumnType("TEXT"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("AdminAction") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Adjustment") + .HasColumnType("TEXT"); + + b.Property("AdjustmentReason") + .HasColumnType("TEXT"); + + b.Property("AdminNotes") + .HasColumnType("TEXT"); + + b.Property("BalanceRemaining") + .HasColumnType("TEXT"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("ExpirationDate") + .HasColumnType("TEXT"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("TEXT"); + + b.Property("InstallmentDate") + .HasColumnType("TEXT"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("LifeCycle") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("NextNotificationDate") + .HasColumnType("TEXT"); + + b.Property("NextPaymentDate") + .HasColumnType("TEXT"); + + b.Property("Notes") + .HasColumnType("TEXT"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("INTEGER"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("SubTotal") + .HasColumnType("TEXT"); + + b.Property("Total") + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("ExpirationDate"); + + b.HasIndex("NextNotificationDate"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.HasIndex("Status"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Amount") + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("FinancialSystemId") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("TrackingNumber") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.HasIndex("Status"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("RoleId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("TEXT"); + + b.Property("LifeCycle") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("ErrorMessage") + .HasColumnType("TEXT"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ActorId") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("RequesterId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Group") + .HasColumnType("TEXT"); + + b.HasKey("ClusterId", "Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Kerberos") + .HasColumnType("TEXT"); + + b.HasKey("ClusterId", "Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique(); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240716175727_billingOrder.cs b/Hippo.Core/Migrations/Sqlite/20240716175727_billingOrder.cs new file mode 100644 index 00000000..1b47f7f5 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240716175727_billingOrder.cs @@ -0,0 +1,39 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + public partial class billingOrder : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Billings_Orders_OrderId", + table: "Billings"); + + migrationBuilder.AddForeignKey( + name: "FK_Billings_Orders_OrderId", + table: "Billings", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Billings_Orders_OrderId", + table: "Billings"); + + migrationBuilder.AddForeignKey( + name: "FK_Billings_Orders_OrderId", + table: "Billings", + column: "OrderId", + principalTable: "Orders", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240724154529_financialDetail.Designer.cs b/Hippo.Core/Migrations/Sqlite/20240724154529_financialDetail.Designer.cs new file mode 100644 index 00000000..bc1a9785 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240724154529_financialDetail.Designer.cs @@ -0,0 +1,1102 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + [DbContext(typeof(AppDbContextSqlite))] + [Migration("20240724154529_financialDetail")] + partial class financialDetail + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.19"); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("AccountsId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("ClustersId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("OwnerId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChartString") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Percentage") + .HasColumnType("TEXT"); + + b.Property("Updated") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SecretAccessKey") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ActedById") + .HasColumnType("INTEGER"); + + b.Property("ActedDate") + .HasColumnType("TEXT"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("AdminAction") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Adjustment") + .HasColumnType("TEXT"); + + b.Property("AdjustmentReason") + .HasColumnType("TEXT"); + + b.Property("AdminNotes") + .HasColumnType("TEXT"); + + b.Property("BalanceRemaining") + .HasColumnType("TEXT"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("ExpirationDate") + .HasColumnType("TEXT"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("TEXT"); + + b.Property("InstallmentDate") + .HasColumnType("TEXT"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("LifeCycle") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("NextNotificationDate") + .HasColumnType("TEXT"); + + b.Property("NextPaymentDate") + .HasColumnType("TEXT"); + + b.Property("Notes") + .HasColumnType("TEXT"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("INTEGER"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("SubTotal") + .HasColumnType("TEXT"); + + b.Property("Total") + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("ExpirationDate"); + + b.HasIndex("NextNotificationDate"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.HasIndex("Status"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Amount") + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("FinancialSystemId") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasColumnType("TEXT"); + + b.Property("TrackingNumber") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.HasIndex("Status"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("RoleId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("TEXT"); + + b.Property("LifeCycle") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("ErrorMessage") + .HasColumnType("TEXT"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ActorId") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("RequesterId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Group") + .HasColumnType("TEXT"); + + b.HasKey("ClusterId", "Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Kerberos") + .HasColumnType("TEXT"); + + b.HasKey("ClusterId", "Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique(); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240724154529_financialDetail.cs b/Hippo.Core/Migrations/Sqlite/20240724154529_financialDetail.cs new file mode 100644 index 00000000..be538721 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240724154529_financialDetail.cs @@ -0,0 +1,34 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + public partial class financialDetail : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "SecretAccessKey", + table: "FinancialDetails", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "SecretAccessKey", + table: "FinancialDetails", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(string), + oldType: "TEXT", + oldNullable: true); + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240725161155_orderFieldLengths.Designer.cs b/Hippo.Core/Migrations/Sqlite/20240725161155_orderFieldLengths.Designer.cs new file mode 100644 index 00000000..90817506 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240725161155_orderFieldLengths.Designer.cs @@ -0,0 +1,1112 @@ +// +using System; +using Hippo.Core.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + [DbContext(typeof(AppDbContextSqlite))] + [Migration("20240725161155_orderFieldLengths")] + partial class orderFieldLengths + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.19"); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("AccountsId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "AccountsId"); + + b.HasIndex("AccountsId"); + + b.ToTable("AccessTypeAccount"); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.Property("AccessTypesId") + .HasColumnType("INTEGER"); + + b.Property("ClustersId") + .HasColumnType("INTEGER"); + + b.HasKey("AccessTypesId", "ClustersId"); + + b.HasIndex("ClustersId"); + + b.ToTable("AccessTypeCluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.AccessType", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("AccessTypes"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("OwnerId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("CreatedOn"); + + b.HasIndex("Email"); + + b.HasIndex("Kerberos"); + + b.HasIndex("Name"); + + b.HasIndex("OwnerId"); + + b.HasIndex("UpdatedOn"); + + b.ToTable("Accounts"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChartString") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Percentage") + .HasColumnType("TEXT"); + + b.Property("Updated") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Domain") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("Name") + .IsRequired() + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("SshKeyId") + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("SshName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("SshUrl") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name"); + + b.ToTable("Clusters"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SecretAccessKey") + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("DisplayName") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId", "Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupAdminAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.Property("AccountId") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.HasKey("AccountId", "GroupId"); + + b.HasIndex("GroupId"); + + b.ToTable("GroupMemberAccount"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ActedById") + .HasColumnType("INTEGER"); + + b.Property("ActedDate") + .HasColumnType("TEXT"); + + b.Property("Action") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("AdminAction") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Details") + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ActedById"); + + b.HasIndex("ActedDate"); + + b.HasIndex("Action"); + + b.HasIndex("ClusterId"); + + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + + b.ToTable("Histories"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Adjustment") + .HasColumnType("TEXT"); + + b.Property("AdjustmentReason") + .HasColumnType("TEXT"); + + b.Property("AdminNotes") + .HasColumnType("TEXT"); + + b.Property("BalanceRemaining") + .HasColumnType("TEXT"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("ExpirationDate") + .HasColumnType("TEXT"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("TEXT"); + + b.Property("InstallmentDate") + .HasColumnType("TEXT"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("LifeCycle") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("NextNotificationDate") + .HasColumnType("TEXT"); + + b.Property("NextPaymentDate") + .HasColumnType("TEXT"); + + b.Property("Notes") + .HasColumnType("TEXT"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("INTEGER"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("SubTotal") + .HasColumnType("TEXT"); + + b.Property("Total") + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("ExpirationDate"); + + b.HasIndex("NextNotificationDate"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.HasIndex("Status"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Amount") + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Details") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("FinancialSystemId") + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("TrackingNumber") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.HasIndex("Status"); + + b.ToTable("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("RoleId") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("RoleId"); + + b.HasIndex("UserId"); + + b.ToTable("Permissions"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("TEXT"); + + b.Property("LifeCycle") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("ErrorMessage") + .HasColumnType("TEXT"); + + b.Property("RequestId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UpdatedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("CreatedAt"); + + b.HasIndex("RequestId"); + + b.HasIndex("Status"); + + b.HasIndex("UpdatedAt"); + + b.ToTable("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Action") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("ActorId") + .HasColumnType("INTEGER"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Data") + .HasColumnType("TEXT"); + + b.Property("Group") + .HasMaxLength(32) + .HasColumnType("TEXT"); + + b.Property("RequesterId") + .HasColumnType("INTEGER"); + + b.Property("SshKey") + .HasColumnType("TEXT"); + + b.Property("Status") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SupervisingPI") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Action"); + + b.HasIndex("ActorId"); + + b.HasIndex("ClusterId"); + + b.HasIndex("Group"); + + b.HasIndex("RequesterId"); + + b.HasIndex("Status"); + + b.ToTable("Requests"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Role", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Roles"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempGroup", b => + { + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Group") + .HasColumnType("TEXT"); + + b.HasKey("ClusterId", "Group"); + + b.ToTable("TempGroups"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.TempKerberos", b => + { + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Kerberos") + .HasColumnType("TEXT"); + + b.HasKey("ClusterId", "Kerberos"); + + b.ToTable("TempKerberos"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(300) + .HasColumnType("TEXT"); + + b.Property("FirstName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Iam") + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Kerberos") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("LastName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("MothraId") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Email"); + + b.HasIndex("Iam") + .IsUnique(); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("AccessTypeAccount", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", null) + .WithMany() + .HasForeignKey("AccountsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("AccessTypeCluster", b => + { + b.HasOne("Hippo.Core.Domain.AccessType", null) + .WithMany() + .HasForeignKey("AccessTypesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Cluster", null) + .WithMany() + .HasForeignKey("ClustersId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Accounts") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Owner") + .WithMany("Accounts") + .HasForeignKey("OwnerId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Cluster"); + + b.Navigation("Owner"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Group", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Groups") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupAdminAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.GroupMemberAccount", b => + { + b.HasOne("Hippo.Core.Domain.Account", "Account") + .WithMany() + .HasForeignKey("AccountId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Group", "Group") + .WithMany() + .HasForeignKey("GroupId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Account"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.History", b => + { + b.HasOne("Hippo.Core.Domain.User", "ActedBy") + .WithMany() + .HasForeignKey("ActedById") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("ActedBy"); + + b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Role", "Role") + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "User") + .WithMany("Permissions") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("Role"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => + { + b.HasOne("Hippo.Core.Domain.Request", "Request") + .WithMany("QueuedEvents") + .HasForeignKey("RequestId") + .OnDelete(DeleteBehavior.Restrict); + + b.Navigation("Request"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.HasOne("Hippo.Core.Domain.User", "Actor") + .WithMany() + .HasForeignKey("ActorId") + .OnDelete(DeleteBehavior.Restrict); + + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany() + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.User", "Requester") + .WithMany() + .HasForeignKey("RequesterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Actor"); + + b.Navigation("Cluster"); + + b.Navigation("Requester"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => + { + b.Navigation("Accounts"); + + b.Navigation("FinancialDetail"); + + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Request", b => + { + b.Navigation("QueuedEvents"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.User", b => + { + b.Navigation("Accounts"); + + b.Navigation("Permissions"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/20240725161155_orderFieldLengths.cs b/Hippo.Core/Migrations/Sqlite/20240725161155_orderFieldLengths.cs new file mode 100644 index 00000000..08bed6c9 --- /dev/null +++ b/Hippo.Core/Migrations/Sqlite/20240725161155_orderFieldLengths.cs @@ -0,0 +1,19 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Hippo.Core.Migrations.Sqlite +{ + public partial class orderFieldLengths : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/Hippo.Core/Migrations/Sqlite/AppDbContextSqliteModelSnapshot.cs b/Hippo.Core/Migrations/Sqlite/AppDbContextSqliteModelSnapshot.cs index 880f685a..c285cbce 100644 --- a/Hippo.Core/Migrations/Sqlite/AppDbContextSqliteModelSnapshot.cs +++ b/Hippo.Core/Migrations/Sqlite/AppDbContextSqliteModelSnapshot.cs @@ -121,6 +121,33 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Accounts"); }); + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChartString") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Percentage") + .HasColumnType("TEXT"); + + b.Property("Updated") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.ToTable("Billings"); + }); + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => { b.Property("Id") @@ -169,6 +196,41 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Clusters"); }); + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AutoApprove") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("ChartString") + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("FinancialSystemApiSource") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("SecretAccessKey") + .HasMaxLength(200) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId") + .IsUnique(); + + b.ToTable("FinancialDetails"); + }); + modelBuilder.Entity("Hippo.Core.Domain.Group", b => { b.Property("Id") @@ -253,10 +315,17 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Details") .HasColumnType("TEXT"); + b.Property("OrderId") + .HasColumnType("INTEGER"); + b.Property("Status") .HasMaxLength(50) .HasColumnType("TEXT"); + b.Property("Type") + .HasMaxLength(50) + .HasColumnType("TEXT"); + b.HasKey("Id"); b.HasIndex("ActedById"); @@ -267,9 +336,196 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("ClusterId"); + b.HasIndex("OrderId"); + + b.HasIndex("Type"); + b.ToTable("Histories"); }); + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Adjustment") + .HasColumnType("TEXT"); + + b.Property("AdjustmentReason") + .HasColumnType("TEXT"); + + b.Property("AdminNotes") + .HasColumnType("TEXT"); + + b.Property("BalanceRemaining") + .HasColumnType("TEXT"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("ExpirationDate") + .HasColumnType("TEXT"); + + b.Property("ExternalReference") + .HasMaxLength(150) + .HasColumnType("TEXT"); + + b.Property("InstallmentDate") + .HasColumnType("TEXT"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("LifeCycle") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("NextNotificationDate") + .HasColumnType("TEXT"); + + b.Property("NextPaymentDate") + .HasColumnType("TEXT"); + + b.Property("Notes") + .HasColumnType("TEXT"); + + b.Property("PrincipalInvestigatorId") + .HasColumnType("INTEGER"); + + b.Property("ProductName") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("Quantity") + .HasColumnType("TEXT"); + + b.Property("Status") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("SubTotal") + .HasColumnType("TEXT"); + + b.Property("Total") + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.HasIndex("ExpirationDate"); + + b.HasIndex("NextNotificationDate"); + + b.HasIndex("PrincipalInvestigatorId"); + + b.HasIndex("Status"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Value") + .IsRequired() + .HasMaxLength(450) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("OrderId"); + + b.HasIndex("OrderId", "Name", "Value"); + + b.ToTable("MetaData"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Amount") + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("INTEGER"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Details") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("FinancialSystemId") + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("OrderId") + .HasColumnType("INTEGER"); + + b.Property("Status") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.Property("TrackingNumber") + .HasMaxLength(20) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("OrderId"); + + b.HasIndex("Status"); + + b.ToTable("Payments"); + }); + modelBuilder.Entity("Hippo.Core.Domain.Permission", b => { b.Property("Id") @@ -296,6 +552,61 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.ToTable("Permissions"); }); + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Category") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ClusterId") + .HasColumnType("INTEGER"); + + b.Property("Description") + .HasMaxLength(250) + .HasColumnType("TEXT"); + + b.Property("InstallmentType") + .IsRequired() + .HasMaxLength(10) + .HasColumnType("TEXT"); + + b.Property("Installments") + .HasColumnType("INTEGER"); + + b.Property("IsActive") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER") + .HasDefaultValue(true); + + b.Property("LastUpdated") + .HasColumnType("TEXT"); + + b.Property("LifeCycle") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.Property("UnitPrice") + .HasColumnType("TEXT"); + + b.Property("Units") + .HasMaxLength(50) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ClusterId"); + + b.ToTable("Products"); + }); + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => { b.Property("Id") @@ -538,6 +849,28 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Owner"); }); + modelBuilder.Entity("Hippo.Core.Domain.Billing", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Billings") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.FinancialDetail", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithOne("FinancialDetail") + .HasForeignKey("Hippo.Core.Domain.FinancialDetail", "ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + modelBuilder.Entity("Hippo.Core.Domain.Group", b => { b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") @@ -599,9 +932,63 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasForeignKey("ClusterId") .OnDelete(DeleteBehavior.Restrict); + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("History") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict); + b.Navigation("ActedBy"); b.Navigation("Cluster"); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Orders") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Hippo.Core.Domain.Account", "PrincipalInvestigator") + .WithMany("Orders") + .HasForeignKey("PrincipalInvestigatorId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + + b.Navigation("PrincipalInvestigator"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.OrderMetaData", b => + { + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("MetaData") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Order"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Payment", b => + { + b.HasOne("Hippo.Core.Domain.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("Hippo.Core.Domain.Order", "Order") + .WithMany("Payments") + .HasForeignKey("OrderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Order"); }); modelBuilder.Entity("Hippo.Core.Domain.Permission", b => @@ -630,6 +1017,17 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("User"); }); + modelBuilder.Entity("Hippo.Core.Domain.Product", b => + { + b.HasOne("Hippo.Core.Domain.Cluster", "Cluster") + .WithMany("Products") + .HasForeignKey("ClusterId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Cluster"); + }); + modelBuilder.Entity("Hippo.Core.Domain.QueuedEvent", b => { b.HasOne("Hippo.Core.Domain.Request", "Request") @@ -666,11 +1064,33 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Requester"); }); + modelBuilder.Entity("Hippo.Core.Domain.Account", b => + { + b.Navigation("Orders"); + }); + modelBuilder.Entity("Hippo.Core.Domain.Cluster", b => { b.Navigation("Accounts"); + b.Navigation("FinancialDetail"); + b.Navigation("Groups"); + + b.Navigation("Orders"); + + b.Navigation("Products"); + }); + + modelBuilder.Entity("Hippo.Core.Domain.Order", b => + { + b.Navigation("Billings"); + + b.Navigation("History"); + + b.Navigation("MetaData"); + + b.Navigation("Payments"); }); modelBuilder.Entity("Hippo.Core.Domain.Request", b => diff --git a/Hippo.Core/Models/ChartStringValidationModel.cs b/Hippo.Core/Models/ChartStringValidationModel.cs index ba4a24af..c079341f 100644 --- a/Hippo.Core/Models/ChartStringValidationModel.cs +++ b/Hippo.Core/Models/ChartStringValidationModel.cs @@ -16,7 +16,6 @@ public class ChartStringValidationModel public string AccountManagerEmail { get; set; } public string Description { get; set; } //Description of COA - public string DisplayName { get; set; } /// @@ -37,5 +36,20 @@ public string Message } } public List Messages { get; set; } = new List(); + + public string Warning + { + get + { + if (Warnings.Count <= 0) + { + return string.Empty; + } + + //select the warnings into a string of key - Value and return it + return string.Join(" ", Warnings.Select(w => $"{w.Key} - {w.Value}")); + + } + } } } diff --git a/Hippo.Core/Models/ClusterModel.cs b/Hippo.Core/Models/ClusterModel.cs index 034ab561..51173077 100644 --- a/Hippo.Core/Models/ClusterModel.cs +++ b/Hippo.Core/Models/ClusterModel.cs @@ -34,6 +34,8 @@ public class ClusterModel [ListOfStringsOptions(AccessType.Codes.RegexPattern, nonEmpty: true)] public List AccessTypes { get; set; } = new(); + public bool AllowOrders { get; set; } = false; + public ClusterModel() { @@ -69,6 +71,7 @@ public static Expression> Projection IsActive = c.IsActive, Domain = c.Domain, Email = c.Email, + AllowOrders = c.FinancialDetail != null, AccessTypes = c.AccessTypes.Select(at => at.Name).ToList() }; diff --git a/Hippo.Core/Models/OrderModels/FinancialDetailModel.cs b/Hippo.Core/Models/OrderModels/FinancialDetailModel.cs new file mode 100644 index 00000000..d1937795 --- /dev/null +++ b/Hippo.Core/Models/OrderModels/FinancialDetailModel.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Hippo.Core.Models.OrderModels +{ + public class FinancialDetailModel + { + public string FinancialSystemApiKey { get; set; } + [Required] + [MaxLength(50)] + public string FinancialSystemApiSource { get; set; } + public string ChartString { get; set; } + public bool AutoApprove { get; set; } + + public string MaskedApiKey { get; set; } + + public bool IsSlothValid { get; set; } = false; + } +} diff --git a/Hippo.Core/Models/OrderModels/OrderPostModel.cs b/Hippo.Core/Models/OrderModels/OrderPostModel.cs new file mode 100644 index 00000000..2e44846c --- /dev/null +++ b/Hippo.Core/Models/OrderModels/OrderPostModel.cs @@ -0,0 +1,40 @@ +using Hippo.Core.Domain; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static Hippo.Core.Domain.Product; + +namespace Hippo.Core.Models.OrderModels +{ + public class OrderPostModel : ProductBase + { + + [Required] + [MaxLength(50)] + public string ProductName { get; set; } + + [MaxLength(150)] + public string ExternalReference { get; set; } + + [Required] + [Range(0.0001, double.MaxValue)] + public decimal Quantity { get; set; } + + public string? InstallmentDate { get; set; } + public string? ExpirationDate { get; set; } //This would default to InstallmentDate + LifeCycle Months + + public string PILookup { get; set; } + public List MetaData { get; set; } = new(); + + public List Billings { get; set; } = new(); + + public decimal Adjustment { get; set; } + public string AdjustmentReason { get; set; } + public string Notes { get; set; } + public string AdminNotes { get; set; } + + } +} diff --git a/Hippo.Core/Models/Settings/AggieEnterpriseSettings.cs b/Hippo.Core/Models/Settings/AggieEnterpriseSettings.cs index df79337e..0eb5b479 100644 --- a/Hippo.Core/Models/Settings/AggieEnterpriseSettings.cs +++ b/Hippo.Core/Models/Settings/AggieEnterpriseSettings.cs @@ -9,6 +9,7 @@ public class AggieEnterpriseSettings public string ScopeApp { get; set; } public string ScopeEnv { get; set; } - public string NaturalAccount { get; set; } //May not need this + public string DebitNaturalAccount { get; set; } + public string CreditNaturalAccount { get; set; } } } diff --git a/Hippo.Core/Models/Settings/SlothSettings.cs b/Hippo.Core/Models/Settings/SlothSettings.cs new file mode 100644 index 00000000..4db52d89 --- /dev/null +++ b/Hippo.Core/Models/Settings/SlothSettings.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Hippo.Core.Models.Settings +{ + public class SlothSettings + { + public string ApiUrl { get; set; } + public string HippoBaseUrl { get; set; } //Could use the email settingg + + } +} diff --git a/Hippo.Core/Models/SlothModels/SlothResponseModel.cs b/Hippo.Core/Models/SlothModels/SlothResponseModel.cs new file mode 100644 index 00000000..610cfb54 --- /dev/null +++ b/Hippo.Core/Models/SlothModels/SlothResponseModel.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Hippo.Core.Models.SlothModels +{ + public class SlothResponseModel + { + public string Id { get; set; } + public string KfsTrackingNumber { get; set; } + public string Status { get; set; } + } + + public static class SlothStatuses + { + public const string PendingApproval = "PendingApproval"; + public const string Scheduled = "Scheduled"; + public const string Completed = "Completed"; + public const string Cancelled = "Cancelled"; + + //Probably not going to do anything with these, just here for completeness + public const string Processing = "Processing"; + public const string Rejected = "Rejected"; + } +} diff --git a/Hippo.Core/Models/SlothModels/SourceModel.cs b/Hippo.Core/Models/SlothModels/SourceModel.cs new file mode 100644 index 00000000..10c416e8 --- /dev/null +++ b/Hippo.Core/Models/SlothModels/SourceModel.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Hippo.Core.Models.SlothModels +{ + public class SourceModel + { + public string Name { get; set; } + + public string Type { get; set; } + + public string Description { get; set; } + } +} diff --git a/Hippo.Core/Models/SlothModels/TransactionViewModel.cs b/Hippo.Core/Models/SlothModels/TransactionViewModel.cs new file mode 100644 index 00000000..6e9e0a12 --- /dev/null +++ b/Hippo.Core/Models/SlothModels/TransactionViewModel.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Hippo.Core.Models.SlothModels +{ + public class TransactionViewModel + { + public TransactionViewModel() + { + TransactionDate = DateTime.UtcNow; + Transfers = new List(); + AutoApprove = false; + } + public string MerchantTrackingNumber { get; set; } + + public string MerchantTrackingUrl { get; set; } + public bool AutoApprove { get; set; } + + public DateTime TransactionDate { get; set; } + + public string Source { get; set; } = "Get From Database"; + public string SourceType { get; set; } = "Recharge"; + + public string Description { get; set; } //If it isn't set, Sloth with use one of the transfer descriptions... + + public bool ValidateFinancialSegmentStrings { get; set; } = true; + + [MaxLength(128)] + public string ProcessorTrackingNumber { get; set; } + + public IList Metadata { get; set; } = new List(); + + public void AddMetadata(string name, string value) + { + Metadata.Add(new MetadataEntry { Name = name, Value = value }); + } + + public class MetadataEntry + { + public string Name { get; set; } + public string Value { get; set; } + } + + public IList Transfers { get; set; } + } + + public class TransferViewModel + { + public Decimal Amount { get; set; } + [StringLength(1)] + public string Chart { get; set; } + [StringLength(7)] + public string Account { get; set; } + [StringLength(5)] + public string SubAccount { get; set; } + [StringLength(4)] + public string ObjectCode { get; set; } + [StringLength(40)] + public string Description { get; set; } + public string FinancialSegmentString { get; set; } + + public string Direction { get; set; }// Debit or Credit Code associated with the transaction. = ['Credit', 'Debit'], + + public class Directions + { + public const string Debit = "Debit"; + public const string Credit = "Credit"; + } + } +} diff --git a/Hippo.Core/Services/AggieEnterpriseService.cs b/Hippo.Core/Services/AggieEnterpriseService.cs index 32c303e5..8c34623d 100644 --- a/Hippo.Core/Services/AggieEnterpriseService.cs +++ b/Hippo.Core/Services/AggieEnterpriseService.cs @@ -5,12 +5,13 @@ using Hippo.Core.Models.Settings; using Microsoft.Extensions.Options; using Serilog; +using static Hippo.Core.Models.SlothModels.TransferViewModel; namespace Hippo.Core.Services { public interface IAggieEnterpriseService { - Task IsChartStringValid(string chartString, bool validateCVRs = true); + Task IsChartStringValid(string chartString, string direction, bool validateCVRs = true); } public class AggieEnterpriseService : IAggieEnterpriseService { @@ -34,7 +35,7 @@ public AggieEnterpriseService(IOptions aggieEnterpriseS } } - public async Task IsChartStringValid(string chartString, bool validateCVRs = true) + public async Task IsChartStringValid(string chartString, string direction, bool validateCVRs = true) { var rtValue = new ChartStringValidationModel(); rtValue.IsValid = false; @@ -43,10 +44,16 @@ public async Task IsChartStringValid(string chartStr var segmentStringType = FinancialChartValidation.GetFinancialChartStringType(chartString); rtValue.ChartType = segmentStringType; + var naturalAccount = AeSettings.DebitNaturalAccount; + if(direction == Directions.Credit) + { + naturalAccount = AeSettings.CreditNaturalAccount; + } + if (segmentStringType == FinancialChartStringType.Gl) { - chartString = ReplaceNaturalAccount(chartString, AeSettings.NaturalAccount); + chartString = ReplaceNaturalAccount(chartString, naturalAccount, rtValue); rtValue.ChartString = chartString; var result = await _aggieClient.GlValidateChartstring.ExecuteAsync(chartString, validateCVRs); @@ -83,11 +90,11 @@ public async Task IsChartStringValid(string chartStr rtValue.Description = $"{data.GlValidateChartstring.SegmentNames.DepartmentName} - {data.GlValidateChartstring.SegmentNames.FundName}"; - if (!string.IsNullOrWhiteSpace(AeSettings.NaturalAccount)) + if (!string.IsNullOrWhiteSpace(naturalAccount)) { - if (rtValue.GlSegments.Account != AeSettings.NaturalAccount) + if (rtValue.GlSegments.Account != naturalAccount) { - rtValue.Messages.Add($"Natural Account must be {AeSettings.NaturalAccount}"); + rtValue.Messages.Add($"Natural Account must be {naturalAccount}"); rtValue.IsValid = false; } } @@ -97,7 +104,7 @@ public async Task IsChartStringValid(string chartStr if (segmentStringType == FinancialChartStringType.Ppm) { - chartString = ReplaceNaturalAccount(chartString, AeSettings.NaturalAccount); + chartString = ReplaceNaturalAccount(chartString, naturalAccount, rtValue); rtValue.ChartString = chartString; var result = await _aggieClient.PpmSegmentStringValidate.ExecuteAsync(chartString); @@ -131,11 +138,14 @@ public async Task IsChartStringValid(string chartStr await GetPpmAccountManager(rtValue); - - if (rtValue.PpmSegments.ExpenditureType != AeSettings.NaturalAccount) + if (!string.IsNullOrWhiteSpace(naturalAccount)) { - rtValue.Messages.Add($"Expenditure Type must be {AeSettings.NaturalAccount}"); - rtValue.IsValid = false; + + if (rtValue.PpmSegments.ExpenditureType != naturalAccount) + { + rtValue.Messages.Add($"Expenditure Type must be {naturalAccount}"); + rtValue.IsValid = false; + } } return rtValue; @@ -147,7 +157,7 @@ public async Task IsChartStringValid(string chartStr return rtValue; } - public string ReplaceNaturalAccount(string chartString, string naturalAccount) + public string ReplaceNaturalAccount(string chartString, string naturalAccount, ChartStringValidationModel model) { if(string.IsNullOrWhiteSpace(naturalAccount)) { @@ -158,12 +168,20 @@ public string ReplaceNaturalAccount(string chartString, string naturalAccount) if (segmentStringType == FinancialChartStringType.Gl) { var segments = FinancialChartValidation.GetGlSegments(chartString); + if(segments.Account != naturalAccount) + { + model.Warnings.Add(new KeyValuePair("Account", $"Natural Account {segments.Account} will be replaced with {naturalAccount}")); + } segments.Account = naturalAccount; return segments.ToSegmentString(); } if (segmentStringType == FinancialChartStringType.Ppm) { var segments = FinancialChartValidation.GetPpmSegments(chartString); + if (segments.ExpenditureType != naturalAccount) + { + model.Warnings.Add(new KeyValuePair("Expenditure Type", $"Natural Account {segments.ExpenditureType} replaced with {naturalAccount}")); + } segments.ExpenditureType = naturalAccount; return segments.ToSegmentString(); } @@ -180,7 +198,7 @@ private async Task GetPpmAccountManager(ChartStringValidationModel rtValue) { rtValue.AccountManager = data.PpmProjectByNumber.PrimaryProjectManagerName; rtValue.AccountManagerEmail = data.PpmProjectByNumber.PrimaryProjectManagerEmail; - rtValue.Description = data.PpmProjectByNumber.Name; + rtValue.Description = $"{data.PpmProjectByNumber.Name} - {rtValue.AccountManager}"; } return; } diff --git a/Hippo.Core/Services/HistoryService.cs b/Hippo.Core/Services/HistoryService.cs index 116ba81d..ee6a6a0f 100644 --- a/Hippo.Core/Services/HistoryService.cs +++ b/Hippo.Core/Services/HistoryService.cs @@ -205,5 +205,90 @@ public static async Task PuppetDataSynced(this IHistoryService historyService) }; await historyService.AddHistory(history); } + + public static async Task OrderCreated(this IHistoryService historyService, Order order, User actedBy) + { + var history = new History + { + Order = order, + ClusterId = order.Cluster.Id, + Status = order.Status, + ActedBy = actedBy, + AdminAction = actedBy != order.PrincipalInvestigator.Owner, + Action = History.OrderActions.Created, + Type = HistoryTypes.Primary, + Details = $"Order total: {order.Total}" + }; + + await historyService.AddHistory(history); + } + + public static async Task OrderUpdated(this IHistoryService historyService, Order order, User actedBy) + { + var history = new History + { + Order = order, + ClusterId = order.Cluster.Id, + Status = order.Status, + ActedBy = actedBy, + AdminAction = actedBy != order.PrincipalInvestigator.Owner, + Action = History.OrderActions.Updated, + Type = HistoryTypes.Primary, + Details = $"Order total: {order.Total}" + }; + + await historyService.AddHistory(history); + } + + public static async Task OrderUpdated(this IHistoryService historyService, Order order, User actedBy, string details) + { + var history = new History + { + Order = order, + ClusterId = order.Cluster.Id, + Status = order.Status, + ActedBy = actedBy, + AdminAction = actedBy != order.PrincipalInvestigator?.Owner, + Action = History.OrderActions.Updated, + Type = HistoryTypes.Primary, + Details = !string.IsNullOrWhiteSpace(details) ? details : $"Order total: {order.Total}" + }; + + await historyService.AddHistory(history); + } + + public static async Task OrderPaymentFailure(this IHistoryService historyService, Order order, string details) + { + var history = new History + { + Order = order, + ClusterId = order.Cluster.Id, + Status = order.Status, + ActedBy = null, + AdminAction = true, + Action = History.OrderActions.PaymentFailed, + Type = HistoryTypes.Detail, + Details = details + }; + + await historyService.AddHistory(history); + } + + public static async Task OrderSnapshot(this IHistoryService historyService, Order order, User actedBy, string action) + { + var history = new History + { + Order = order, + ClusterId = order.Cluster.Id, + Status = order.Status, + ActedBy = actedBy, + AdminAction = actedBy != order.PrincipalInvestigator?.Owner, + Action = action, + Type = HistoryTypes.Detail, + Details = Serialize(order) + }; + + await historyService.AddHistory(history); + } } } diff --git a/Hippo.Core/Services/PaymentsService.cs b/Hippo.Core/Services/PaymentsService.cs new file mode 100644 index 00000000..0ae22a63 --- /dev/null +++ b/Hippo.Core/Services/PaymentsService.cs @@ -0,0 +1,190 @@ +using Hippo.Core.Data; +using Hippo.Core.Domain; +using Hippo.Core.Extensions; +using Microsoft.EntityFrameworkCore; +using Serilog; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static Hippo.Core.Domain.Product; +using static Hippo.Core.Models.SlothModels.TransferViewModel; + +namespace Hippo.Core.Services +{ + public interface IPaymentsService + { + public Task CreatePayments(); + public Task NotifyAboutFailedPayments(); + } + + public class PaymentsService : IPaymentsService + { + private readonly AppDbContext _dbContext; + private readonly IHistoryService _historyService; + private readonly IAggieEnterpriseService _aggieEnterpriseService; + + public PaymentsService(AppDbContext dbContext, IHistoryService historyService, IAggieEnterpriseService aggieEnterpriseService) + { + _dbContext = dbContext; + _historyService = historyService; + _aggieEnterpriseService = aggieEnterpriseService; + } + public async Task CreatePayments() + { + //Do a check on all active orders that don't have a next payment date and a balance > 0 + var orderCheck = await _dbContext.Orders.Where(a => a.Status == Order.Statuses.Active && a.NextPaymentDate == null && a.BalanceRemaining > 0).ToListAsync(); + foreach (var order in orderCheck) + { + if (order.Payments.Any(a => a.CreatedById == null && (a.Status == Payment.Statuses.Created || a.Status == Payment.Statuses.Processing))) + { + Log.Information("Skipping order {0} because it has a created or processing payment", order.Id); + continue; + } + SetNextPaymentDate(order); + + _dbContext.Orders.Update(order); + await _dbContext.SaveChangesAsync(); + } + + //If I add a history call here, I'll also need to get the cluster .Include(a => a.Cluster) + var orders = await _dbContext.Orders.Include(a => a.Payments).Where(a => a.Status == Order.Statuses.Active && a.NextPaymentDate != null && a.NextPaymentDate.Value.Date <= DateTime.UtcNow.Date).ToListAsync(); + foreach (var order in orders) { + + if (order.Total <= order.Payments.Where(a => a.Status == Payment.Statuses.Completed).Sum(a => a.Amount)) + { + order.Status = Order.Statuses.Completed; + order.NextPaymentDate = null; + //TODO: A notification? This Shold happen when sloth updates, but just in case. + _dbContext.Orders.Update(order); + await _dbContext.SaveChangesAsync(); + continue; + } + + //Need to ignore manual ones... + if (order.Payments.Any(a => a.CreatedById == null && (a.Status == Payment.Statuses.Created || a.Status == Payment.Statuses.Processing))) + { + Log.Information("Skipping order {0} because it has a created or processing payment", order.Id); + continue; + } + + //TODO: Recalculate balance remaining in case DB value is wrong? + var localBalance = Math.Round(order.Total - order.Payments.Where(a => a.Status == Payment.Statuses.Completed || a.Status == Payment.Statuses.Processing).Sum(a => a.Amount), 2); + if (localBalance != order.BalanceRemaining) + { + Log.Information("Order {0} has a balance mismatch. Local: {1} DB: {2}", order.Id, localBalance, order.BalanceRemaining); + order.BalanceRemaining = localBalance; + } + if (order.BalanceRemaining <= 0) + { + Log.Information("Order {0} has a balance of 0. Skipping", order.Id); + continue; + } + + var paymentAmount = order.InstallmentAmount; + if (paymentAmount > Math.Round(order.BalanceRemaining, 2)) + { + paymentAmount = Math.Round(order.BalanceRemaining, 2); + } + var newBalance = Math.Round(order.BalanceRemaining - paymentAmount, 2); + + //Check if we have a small amount remaining, if so just pay it all. + if (newBalance > 0 && newBalance <= 1.0m) + { + paymentAmount = Math.Round(order.BalanceRemaining, 2); + } + + var payment = new Payment + { + Order = order, + Amount = paymentAmount, + Status = Payment.Statuses.Created, + CreatedOn = DateTime.UtcNow + }; + + order.Payments.Add(payment); + order.BalanceRemaining -= paymentAmount; + + SetNextPaymentDate(order); + + _dbContext.Orders.Update(order); + await _dbContext.SaveChangesAsync(); + + } + + + // Create payments + return true; + } + + private void SetNextPaymentDate(Order order) + { + var now = DateTime.UtcNow; + switch (order.InstallmentType) + { + case InstallmentTypes.Monthly: + order.NextPaymentDate = new DateTime(now.Year, now.Month, 1).AddMonths(1).Date.FromPacificTime(); + break; + case InstallmentTypes.Yearly: + order.NextPaymentDate = new DateTime(now.Year, 1, 1).AddYears(1).Date.FromPacificTime(); + break; + case InstallmentTypes.OneTime: + order.NextPaymentDate = now.AddDays(1).ToPacificTime().Date.FromPacificTime(); + break; + } + } + + public async Task NotifyAboutFailedPayments() + { + var yesterday = DateTime.UtcNow.AddDays(-1); //If this was run right after the sloth service, any in created probably failed, but will give it some slack to make sure + //This should be a list of all payments that have a bad chart string, but it is possible there is some other issue, so we will want to validate the chart string before notifying sponsors. + var orderIdsWithFailedPayments = await _dbContext.Payments.Where(a => a.Status == Payment.Statuses.Created && a.CreatedOn <= yesterday).Select(a => a.OrderId).Distinct().ToListAsync(); + + var allOrders = await _dbContext.Orders.Include(a => a.Billings).Include(a => a.PrincipalInvestigator).Where(a => orderIdsWithFailedPayments.Contains(a.Id)).ToListAsync(); + var orderGrouping = allOrders.GroupBy(a => a.ClusterId); + + + foreach (var orderGroup in orderGrouping) + { + var cluster = await _dbContext.Clusters.SingleAsync(a => a.Id == orderGroup.Key); + var invalidOrderIdsInCluster = new List(); + foreach (var order in orderGroup) + { + var invalidChartStrings = false; + //Validate chart string + foreach (var billing in order.Billings) + { + var validation = await _aggieEnterpriseService.IsChartStringValid(billing.ChartString, Directions.Debit); + if (!validation.IsValid) + { + invalidChartStrings = true; + break; + } + } + if (invalidChartStrings) + { + //TODO: Notify the sponsor + //Remember to add notification/email service to job + + + invalidOrderIdsInCluster.Add(order.Id); + } + } + if (invalidOrderIdsInCluster.Count > 0) + { + //Get lists of cluster admins + //Send email to cluster admins with list of orders that have failed payments + //https://localhost:44371/caesfarm/order/details/46 + + var clusterAdmins = await _dbContext.Users.AsNoTracking().Where(u => u.Permissions.Any(p => p.Cluster.Id == orderGroup.Key && p.Role.Name == Role.Codes.ClusterAdmin)).OrderBy(u => u.LastName).ThenBy(u => u.FirstName).ToArrayAsync(); + //TODO: Notify the cluster admins with a single email + + } + + } + + return true; + } + } +} diff --git a/Hippo.Core/Services/SlothService.cs b/Hippo.Core/Services/SlothService.cs new file mode 100644 index 00000000..f72b0db4 --- /dev/null +++ b/Hippo.Core/Services/SlothService.cs @@ -0,0 +1,327 @@ +using AngleSharp.Dom; +using Hippo.Core.Data; +using Hippo.Core.Models.Settings; +using Hippo.Core.Models.SlothModels; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json; +using System.Text.Json.Serialization; +using System.Threading.Tasks; +using System.Net.Http; +using Hippo.Core.Domain; +using Serilog; +using System.Net; + + +namespace Hippo.Core.Services +{ + public interface ISlothService + { + //Move money + //Check Txns + //Test API key + Task TestApiKey(int clusterId); + Task ProcessPayments(); //All clusters? + Task UpdatePayments(); //All clusters? + } + public class SlothService : ISlothService + { + private readonly AppDbContext _dbContext; + private ISecretsService _secretsService; + private readonly SlothSettings _slothSettings; + private readonly IHttpClientFactory _clientFactory; + private readonly IHistoryService _historyService; + private readonly JsonSerializerOptions _serializerOptions; + + public SlothService(AppDbContext dbContext, ISecretsService secretsService, IOptions slothSettings, IHttpClientFactory clientFactory, IHistoryService historyService) + { + _dbContext = dbContext; + _secretsService = secretsService; + _slothSettings = slothSettings.Value; + _clientFactory = clientFactory; + _historyService = historyService; + _serializerOptions = new JsonSerializerOptions + { + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + NumberHandling = JsonNumberHandling.AllowReadingFromString, + AllowTrailingCommas = true, + PropertyNameCaseInsensitive = true, + }; + } + + + + + public async Task TestApiKey(int clusterId) + { + try + { + var financialDetail = await _dbContext.FinancialDetails.SingleAsync(a => a.ClusterId == clusterId); + var apiKey = await _secretsService.GetSecret(financialDetail.SecretAccessKey); + + using var client = _clientFactory.CreateClient(); + client.BaseAddress = new Uri($"{_slothSettings.ApiUrl}Sources/"); + client.DefaultRequestHeaders.Add("X-Auth-Token", apiKey); + var response = await client.GetAsync(""); + + if (response.IsSuccessStatusCode) + { + var content = await response.Content.ReadAsStringAsync(); + var slothResponse = JsonSerializer.Deserialize>(content, _serializerOptions); + if (slothResponse.Any(a => a.Name == financialDetail.FinancialSystemApiSource)) + { + return true; + } + else + { + return false; + } + } + return false; + } + catch (Exception) + { + return false; + } + } + + public async Task ProcessPayments() + { + //Ok, so I want to loop through all the payments that are created and send them to sloth + //I need to group them by clusterId because each cluster will have a team and different API key and source + //If an error happens for a cluster, I want to log it and continue processing the other clusters but I also want to email a notification to the team + // so keep track of them and mail after. The actual errors can be logged. + // if a txn fails continue to the next one, but log it + // if a txn is successful, update the status in the db, and set the kfs tracking number as well as the id from sloth into the payment.FinancialSystemId + // if all txns are successful, return true, else return false + try + { + + var wereThereErrors = false; + var allPayments = await _dbContext.Payments.Include(a => a.Order).ThenInclude(a => a.Cluster).Where(a => a.Status == Payment.Statuses.Created).ToListAsync(); + + var paymentGroups = allPayments.GroupBy(a => a.Order.ClusterId); + + //var paymentGroups = await _dbContext.Payments.Include(a => a.Order).ThenInclude(a => a.Cluster).Where(a => a.Status == Payment.Statuses.Created).GroupBy(a => a.Order.ClusterId).ToListAsync(); + foreach (var group in paymentGroups) + { + var clusterId = group.Key; + var financialDetail = await _dbContext.FinancialDetails.SingleAsync(a => a.ClusterId == clusterId); + var apiKey = await _secretsService.GetSecret(financialDetail.SecretAccessKey); + + using var client = _clientFactory.CreateClient(); + client.BaseAddress = new Uri($"{_slothSettings.ApiUrl}"); + client.DefaultRequestHeaders.Add("X-Auth-Token", apiKey); + foreach (var payment in group) + { + var order = await _dbContext.Orders.Include(a => a.Billings).Include(a => a.MetaData).Include(a => a.Cluster).SingleAsync(a => a.Id == payment.OrderId); + + //TODO: ? Check if the txn is already on sloth? To do this sloth would need to be changed, or I'd need to write the the processor tracking number + + var slothTransaction = CreateTransaction(financialDetail, order, payment); + Log.Information(JsonSerializer.Serialize(slothTransaction, _serializerOptions)); //MAybe don't need? + + var response = await client.PostAsync("Transactions", new StringContent(JsonSerializer.Serialize(slothTransaction, _serializerOptions), Encoding.UTF8, "application/json")); + if (response.IsSuccessStatusCode && response.StatusCode != HttpStatusCode.NoContent) + { + var content = await response.Content.ReadAsStringAsync(); + Log.Information("Sloth Success Response", content); + var slothResponse = JsonSerializer.Deserialize(content, _serializerOptions); + payment.FinancialSystemId = slothResponse.Id; + payment.TrackingNumber = slothResponse.KfsTrackingNumber; + payment.Status = Payment.Statuses.Processing; + + //Do this when the payment has been completed? + //order.BalanceRemaining -= Math.Round(payment.Amount, 2); //Should I update the order here? + + await _historyService.OrderUpdated(order, null, $"Payment sent for processing. Amount: {Math.Round(payment.Amount, 2).ToString("C")}"); + + await _dbContext.SaveChangesAsync(); + + + } + else + { + Log.Error($"Error processing payment: {payment.Id} for Order: {payment.OrderId} Name: {payment.Order.Name}"); + Log.Error($"Error: {response.ReasonPhrase}"); + await _historyService.OrderPaymentFailure(order, $"Error processing payment: {payment.Id} for Order: {payment.OrderId} Error: {response.ReasonPhrase}"); + await _dbContext.SaveChangesAsync(); + wereThereErrors = true; + } + } + + } + + + + return !wereThereErrors; + } + catch (Exception ex) + { + Log.Error(ex, "Error processing payments"); + return false; + } + } + + private TransactionViewModel CreateTransaction(FinancialDetail financialDetail, Order order, Payment payment) + { + var slothTransaction = new TransactionViewModel + { + AutoApprove = financialDetail.AutoApprove, + MerchantTrackingNumber = $"{payment.OrderId}-{payment.Id}", + ProcessorTrackingNumber = $"{payment.OrderId}-{payment.Id}", + ValidateFinancialSegmentStrings = true, + MerchantTrackingUrl = $"{_slothSettings.HippoBaseUrl}{order.Cluster.Name}/order/details/{payment.OrderId}", + Description = $"Order: {payment.OrderId}-{payment.Id} Name: {order.Name}", + Source = financialDetail.FinancialSystemApiSource, + SourceType = "Recharge", + }; + + slothTransaction.AddMetadata("OrderId", payment.OrderId.ToString()); + slothTransaction.AddMetadata("PaymentId", payment.Id.ToString()); + slothTransaction.AddMetadata("Cluster", order.Cluster.Name); + slothTransaction.AddMetadata("Balance Remaining (Including this)", order.BalanceRemaining.ToString("C")); + if (!string.IsNullOrWhiteSpace(order.ExternalReference)) + { + slothTransaction.AddMetadata("ExternalReference", order.ExternalReference); + } + slothTransaction.AddMetadata("OrderName", order.Name); + slothTransaction.AddMetadata("Product", order.ProductName); + slothTransaction.AddMetadata("Category", order.Category); + foreach (var meta in order.MetaData) + { + slothTransaction.AddMetadata(meta.Name, meta.Value); + } + + var transfer = new TransferViewModel + { + Amount = Math.Round(payment.Amount, 2), + Description = $"Order: {payment.OrderId} Name: {order.Name}", + FinancialSegmentString = financialDetail.ChartString, + Direction = TransferViewModel.Directions.Credit, + }; + slothTransaction.Transfers.Add(transfer); + + foreach (var billing in order.Billings) + { + var debitTransfer = new TransferViewModel + { + Amount = Math.Round(payment.Amount * (billing.Percentage / 100m), 2), + Description = $"Order: {payment.OrderId} Name: {order.Name}", + FinancialSegmentString = billing.ChartString, + Direction = TransferViewModel.Directions.Debit, + }; + if (debitTransfer.Amount > 0) + { + slothTransaction.Transfers.Add(debitTransfer); + } + } + + var difference = Math.Round(payment.Amount, 2) - slothTransaction.Transfers.Where(a => a.Direction == TransferViewModel.Directions.Debit).Sum(a => a.Amount); + if (difference != 0) + { + //TODO: Test this + Log.Error($"The total debits do not match the total credit for Order: {payment.OrderId} Name: {order.Name}"); + Log.Error($"Total Credit: {Math.Round(payment.Amount, 2)} Difference: {difference}"); + //Adjust the biggest debit + var biggestDebit = slothTransaction.Transfers.Where(a => a.Direction == TransferViewModel.Directions.Debit).OrderByDescending(a => a.Amount).First(); + biggestDebit.Amount += difference; + } + + return slothTransaction; + } + + public async Task UpdatePayments() + { + var wereThereErrors = false; + + + var allPayments = await _dbContext.Payments.Include(a => a.Order).ThenInclude(a => a.Cluster).Where(a => a.Status == Payment.Statuses.Processing).ToListAsync(); + + var paymentGroups = allPayments.GroupBy(a => a.Order.ClusterId); + + foreach (var group in paymentGroups) + { + var clusterId = group.Key; + var financialDetail = await _dbContext.FinancialDetails.SingleAsync(a => a.ClusterId == clusterId); + var apiKey = await _secretsService.GetSecret(financialDetail.SecretAccessKey); + + using var client = _clientFactory.CreateClient(); + client.BaseAddress = new Uri($"{_slothSettings.ApiUrl}Transactions/"); + client.DefaultRequestHeaders.Add("X-Auth-Token", apiKey); + foreach (var payment in group) + { + if (string.IsNullOrWhiteSpace(payment.FinancialSystemId)) + { + wereThereErrors = true; + Log.Error($"Error processing payment: {payment.Id} for Order: {payment.OrderId} Name: {payment.Order.Name} Error: Missing FinancialSystemId"); + continue; + } + var order = await _dbContext.Orders.Include(a => a.Payments).Include(a => a.Billings).Include(a => a.MetaData).Include(a => a.Cluster).SingleAsync(a => a.Id == payment.OrderId); + + var response = await client.GetAsync(payment.FinancialSystemId); + if (response.IsSuccessStatusCode && response.StatusCode != HttpStatusCode.NoContent) + { + var content = await response.Content.ReadAsStringAsync(); + var slothResponse = JsonSerializer.Deserialize(content, _serializerOptions); + + switch (slothResponse.Status) + { + case SlothStatuses.Completed: + payment.Status = Payment.Statuses.Completed; + await _historyService.OrderUpdated(order, null, $"Payment completed. Amount: {Math.Round(payment.Amount, 2).ToString("C")}"); + //order.BalanceRemaining -= Math.Round(payment.Amount, 2); Don't do this here, this is a ballance that is available to pay, not the total paid + var totalPayments = order.Payments.Where(a => a.Status == Payment.Statuses.Completed).Sum(a => a.Amount); + if (order.Total <= totalPayments) + { + order.Status = Order.Statuses.Completed; + await _historyService.OrderUpdated(order, null, $"Order paid in full."); + order.NextPaymentDate = null; + } + + await _dbContext.SaveChangesAsync(); + break; + case SlothStatuses.Processing: + case SlothStatuses.PendingApproval: + case SlothStatuses.Scheduled: + //Do nothing + break; + case SlothStatuses.Rejected: + // do nothing? Should get fixed in sloth + break; + case SlothStatuses.Cancelled: + //Need to do something here + payment.Status = Payment.Statuses.Cancelled; + order.BalanceRemaining += Math.Round(payment.Amount, 2); //Add the amount back to the balance remaining + await _historyService.OrderUpdated(order, null, $"Payment CANCELLED. Amount: {Math.Round(payment.Amount, 2).ToString("C")}"); + await _dbContext.SaveChangesAsync(); + break; + default: + wereThereErrors = true; + Log.Error($"Error processing payment: {payment.Id} for Order: {payment.OrderId} Name: {payment.Order.Name} Error: {slothResponse.Status}"); + await _historyService.OrderPaymentFailure(order, $"Error processing payment: {payment.Id} for Order: {payment.OrderId} Error: {slothResponse.Status}"); + await _dbContext.SaveChangesAsync(); + break; + } + + } + else + { + wereThereErrors = true; + Log.Error($"Error processing payment: {payment.Id} for Order: {payment.OrderId} Name: {payment.Order.Name}"); + Log.Error($"Error: {response.ReasonPhrase}"); + await _historyService.OrderPaymentFailure(order, $"Error processing payment: {payment.Id} for Order: {payment.OrderId} Error: {response.ReasonPhrase}"); + await _dbContext.SaveChangesAsync(); + } + } + + } + + return !wereThereErrors; + } + } +} diff --git a/Hippo.Jobs.OrderProcess/Hippo.Jobs.OrderProcess.csproj b/Hippo.Jobs.OrderProcess/Hippo.Jobs.OrderProcess.csproj new file mode 100644 index 00000000..3d843969 --- /dev/null +++ b/Hippo.Jobs.OrderProcess/Hippo.Jobs.OrderProcess.csproj @@ -0,0 +1,27 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + + + + PreserveNewest + + + Always + + + Always + + + + diff --git a/Hippo.Jobs.OrderProcess/Program.cs b/Hippo.Jobs.OrderProcess/Program.cs new file mode 100644 index 00000000..728b5e85 --- /dev/null +++ b/Hippo.Jobs.OrderProcess/Program.cs @@ -0,0 +1,137 @@ +using System; +using System.Threading.Tasks; +using Hippo.Core.Data; +using Hippo.Core.Models.Settings; +using Hippo.Core.Services; +using Hippo.Jobs.Core; +using Microsoft.AspNetCore.Http; +using Microsoft.Data.Sqlite; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Serilog; + + +namespace Hippo.Jobs.OrderProcess +{ + + class Program : JobBase + { + static int Main(string[] args) + { + try + { + Configure(jobName: typeof(Program).Assembly.GetName().Name, jobId: Guid.NewGuid()); + var assembyName = typeof(Program).Assembly.GetName(); + + Log.Information("Running {job} build {build}", assembyName.Name, assembyName.Version); + + // setup di + var provider = ConfigureServices(); + + var slothService = provider.GetRequiredService(); + var paymentsService = provider.GetRequiredService(); + + var successCreatePayments = paymentsService.CreatePayments().GetAwaiter().GetResult(); + if(!successCreatePayments) + { + Log.Error("There was one or more problems running the CreatePayments service."); + } + + var successPayments = slothService.ProcessPayments().GetAwaiter().GetResult(); + + var successUpdates = slothService.UpdatePayments().GetAwaiter().GetResult(); + + var successNotify = paymentsService.NotifyAboutFailedPayments().GetAwaiter().GetResult(); + + if (!successPayments) + { + Log.Error("There was one or more problems running the sloth service 1."); + } + if (!successUpdates) + { + Log.Error("There was one or more problems running the sloth service 2."); + } + if(!successNotify) + { + Log.Error("There was one or more problems running the NotifyAboutFailedPayments service."); + } + if (!successPayments || !successUpdates) + { + return 1; + } + + + } + catch (Exception ex) //Maybe have a try catch for each service call? + { + Log.Error(ex, "Unhandled exception"); + return 1; + } + finally + { + Log.CloseAndFlush(); + } + + return 0; + } + + + private static ServiceProvider ConfigureServices() + { + IServiceCollection services = new ServiceCollection(); + services.AddOptions(); + + var efProvider = Configuration.GetValue("Provider", "none"); + if (efProvider == "SqlServer" || (efProvider == "none" && Configuration.GetValue("Dev:UseSql"))) + { + services.AddDbContextPool((serviceProvider, o) => + { + o.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"), + sqlOptions => + { + sqlOptions.MigrationsAssembly("Hippo.Core"); + }); +#if DEBUG + o.EnableSensitiveDataLogging(); + o.LogTo(message => System.Diagnostics.Debug.WriteLine(message)); +#endif + }); + } + else + { + services.AddDbContextPool((serviceProvider, o) => + { + var connection = new SqliteConnection("Data Source=hippo.db"); + o.UseSqlite(connection, sqliteOptions => + { + sqliteOptions.MigrationsAssembly("Hippo.Core"); + }); + +#if DEBUG + o.EnableSensitiveDataLogging(); + o.LogTo(message => System.Diagnostics.Debug.WriteLine(message)); +#endif + }); + } + services.AddMemoryCache(); + + services.Configure(Configuration.GetSection("Authentication")); //Don't know if I need this. Copy Pasta + services.Configure(Configuration.GetSection("Azure")); + services.Configure(Configuration.GetSection("Sloth")); + services.Configure(Configuration.GetSection("AggieEnterprise")); + + services.AddScoped(); + services.AddTransient(); + services.AddSingleton(); + services.AddHttpClient(); + services.AddSingleton(); + services.AddScoped(); + //TODO: This will probably need the notification service as well. + + + return services.BuildServiceProvider(); + } + + } +} \ No newline at end of file diff --git a/Hippo.Jobs.OrderProcess/Properties/launchSettings.json b/Hippo.Jobs.OrderProcess/Properties/launchSettings.json new file mode 100644 index 00000000..8d629001 --- /dev/null +++ b/Hippo.Jobs.OrderProcess/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "Hippo.Jobs.OrderProcess": { + "commandName": "Project", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "development" + } + } + } +} \ No newline at end of file diff --git a/Hippo.Jobs.OrderProcess/appsettings.json b/Hippo.Jobs.OrderProcess/appsettings.json new file mode 100644 index 00000000..a859e825 --- /dev/null +++ b/Hippo.Jobs.OrderProcess/appsettings.json @@ -0,0 +1,36 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "Serilog": { + "AppName": "Hippo.Jobs.OrderProcess", + "Environment": "[External]", + "ElasticUrl": "[External]" + }, + "ElasticApm": { + "Enabled": false, + "SecretToken": "[External]", + "ServerUrls": "[External]", + "ServiceName": "Hippo", + "Environment": "Development" + }, + "Azure": { + "TenantName": "[External]", + "TenantId": "[External]", + "ClientId": "[External]", + "ClientSecret": "[External]", + "KeyVaultUrl": "[External]", + "KeyVaultId": "[External]" + }, + "Sloth": { + "ApiUrl": "https://sloth-api-test.azurewebsites.net/v2/", + "HippoBaseUrl": "https://hippo-test.azurewebsites.net/" + }, + "ConnectionStrings": { + "DefaultConnection": "[External]" + } +} diff --git a/Hippo.Jobs.OrderProcess/run.cmd b/Hippo.Jobs.OrderProcess/run.cmd new file mode 100644 index 00000000..114189e2 --- /dev/null +++ b/Hippo.Jobs.OrderProcess/run.cmd @@ -0,0 +1,3 @@ +@echo off + +dotnet Hippo.Jobs.OrderProcess.dll \ No newline at end of file diff --git a/Hippo.Jobs.OrderProcess/settings.job b/Hippo.Jobs.OrderProcess/settings.job new file mode 100644 index 00000000..6103e1c9 --- /dev/null +++ b/Hippo.Jobs.OrderProcess/settings.job @@ -0,0 +1,3 @@ +{ + "schedule": "0 0 6 * * *" +} diff --git a/Hippo.Web/ClientApp/package-lock.json b/Hippo.Web/ClientApp/package-lock.json index c63d8e39..1727df04 100644 --- a/Hippo.Web/ClientApp/package-lock.json +++ b/Hippo.Web/ClientApp/package-lock.json @@ -17,6 +17,7 @@ "react-bootstrap-typeahead": "^6.3.2", "react-csv": "^2.2.2", "react-dom": "^18.2.0", + "react-hook-form": "^7.51.5", "react-hot-toast": "^2.2.0", "react-innertext": "^1.1.5", "react-modal-hook": "^3.0.2", @@ -16133,6 +16134,21 @@ "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.2.tgz", "integrity": "sha512-nsO+KSNgo1SbJqJEYRE9ERzo7YtYbou/OqjSQKxV7jcKox7+usiUVZOAC+XnDOABXggQTno0Y1CpVnuWEc1boQ==" }, + "node_modules/react-hook-form": { + "version": "7.51.5", + "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.51.5.tgz", + "integrity": "sha512-J2ILT5gWx1XUIJRETiA7M19iXHlG74+6O3KApzvqB/w8S5NQR7AbU8HVZrMALdmDgWpRPYiZJl0zx8Z4L2mP6Q==", + "engines": { + "node": ">=12.22.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/react-hook-form" + }, + "peerDependencies": { + "react": "^16.8.0 || ^17 || ^18" + } + }, "node_modules/react-hot-toast": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/react-hot-toast/-/react-hot-toast-2.4.1.tgz", diff --git a/Hippo.Web/ClientApp/package.json b/Hippo.Web/ClientApp/package.json index b401430f..56aa4d54 100644 --- a/Hippo.Web/ClientApp/package.json +++ b/Hippo.Web/ClientApp/package.json @@ -12,6 +12,7 @@ "react-bootstrap-typeahead": "^6.3.2", "react-csv": "^2.2.2", "react-dom": "^18.2.0", + "react-hook-form": "^7.51.5", "react-hot-toast": "^2.2.0", "react-innertext": "^1.1.5", "react-modal-hook": "^3.0.2", diff --git a/Hippo.Web/ClientApp/src/App.tsx b/Hippo.Web/ClientApp/src/App.tsx index 9a28293a..ac74a9b3 100644 --- a/Hippo.Web/ClientApp/src/App.tsx +++ b/Hippo.Web/ClientApp/src/App.tsx @@ -19,6 +19,13 @@ import { Clusters } from "./components/Account/Clusters"; import { Clusters as AdminClusters } from "./components/ClusterAdmin/Clusters"; import { Groups } from "./components/Admin/Groups"; import { ShowFor } from "./Shared/ShowFor"; +import { FinancialDetail } from "./components/Financial/FinancialDetail"; +import { Products } from "./components/Product/Products"; +import { Orders } from "./components/Order/Orders"; +import { Details } from "./components/Order/Details"; +import { CreateOrder } from "./components/Order/CreateOrder"; +import { EditOrder } from "./components/Order/EditOrder"; +import { UpdateChartStrings } from "./components/Order/UpdateChartStrings"; import { SoftwareRequestForm } from "./components/ClusterAdmin/SoftwareRequestForm"; import NotFound from "./NotFound"; @@ -94,6 +101,80 @@ const App = () => { } /> + }> + + + } + /> + } + > + + + } + /> + } + > + + + } + /> + } + > +
+ + } + /> + } + > + + + } + /> + } + > + + + } + /> + } + > + + + } + /> } /> } /> diff --git a/Hippo.Web/ClientApp/src/AppNav.tsx b/Hippo.Web/ClientApp/src/AppNav.tsx index 7158664d..7febddaf 100644 --- a/Hippo.Web/ClientApp/src/AppNav.tsx +++ b/Hippo.Web/ClientApp/src/AppNav.tsx @@ -94,7 +94,6 @@ export const AppNav = () => { > Groups - { Cluster Admins + + + isActive ? { fontWeight: "bold" } : {} + } + > + Financial + + + + + isActive ? { fontWeight: "bold" } : {} + } + > + Products + + + isActive ? { fontWeight: "bold" } : {} + } + > + My Orders + + + + + isActive ? { fontWeight: "bold" } : {} + } + > + Admin Orders + + diff --git a/Hippo.Web/ClientApp/src/Shared/Form/FormField.tsx b/Hippo.Web/ClientApp/src/Shared/Form/FormField.tsx new file mode 100644 index 00000000..e385560e --- /dev/null +++ b/Hippo.Web/ClientApp/src/Shared/Form/FormField.tsx @@ -0,0 +1,72 @@ +import React from "react"; +import { FormFeedback, FormGroup, Input, Label } from "reactstrap"; +import InputGroupWrapper from "./InputGroupWrapper"; +import { FormFieldProps } from "./formTypes"; + +const FormField = >({ + register, + error, + type = "text", + name, + label, + inputPrepend, + inputAppend, + required = false, + maxLength, + minLength, + max, + min, + readOnly = false, + autoComplete, + children, + disabled, // select out disabled and don't pass it to register or it will set the value to undefined + ...options +}: FormFieldProps) => { + const { ref, ...rest } = register(name, { + required: { + value: required, + message: `${label} is required`, + }, + maxLength: { + value: maxLength, + message: `${label} must be less than ${maxLength} characters`, + }, + minLength: { + value: minLength, + message: `${label} must be at least ${minLength} characters`, + }, + max: { + value: max, + message: `${label} must be less than ${max}`, + }, + min: { + value: min, + message: `${label} must be greater than ${min}`, + }, + ...options, + }); + + return ( + + + + + {children} + + {!!error && {error.message}} + + + ); +}; + +export default FormField; diff --git a/Hippo.Web/ClientApp/src/Shared/Form/FormSubmitButton.tsx b/Hippo.Web/ClientApp/src/Shared/Form/FormSubmitButton.tsx new file mode 100644 index 00000000..8b230efa --- /dev/null +++ b/Hippo.Web/ClientApp/src/Shared/Form/FormSubmitButton.tsx @@ -0,0 +1,35 @@ +import React from "react"; +import { ButtonProps } from "reactstrap"; +import { OrderModel } from "../../types"; +import { useFormContext } from "react-hook-form"; +import HipButton from "../HipButton"; + +interface FormSubmitButtonProps extends ButtonProps {} + +const FormSubmitButton: React.FC = ({ ...props }) => { + const { + formState: { isDirty, isSubmitting, isSubmitSuccessful, errors }, + } = useFormContext(); + + const isValid = Object.keys(errors).length === 0; + + const shouldDisable = + !isDirty || isSubmitting || isSubmitSuccessful || !isValid; + + return ( + <> + + {isSubmitting + ? "Submitting..." + : isSubmitSuccessful + ? "Submitted!" + : "Submit"} + + {errors.root && ( + {errors.root?.message} + )} + + ); +}; + +export default FormSubmitButton; diff --git a/Hippo.Web/ClientApp/src/Shared/Form/InputGroupWrapper.tsx b/Hippo.Web/ClientApp/src/Shared/Form/InputGroupWrapper.tsx new file mode 100644 index 00000000..b0af692c --- /dev/null +++ b/Hippo.Web/ClientApp/src/Shared/Form/InputGroupWrapper.tsx @@ -0,0 +1,28 @@ +import React from "react"; +import { InputGroup, InputGroupProps, InputGroupText } from "reactstrap"; + +interface InputGroupWrapperProps extends InputGroupProps { + children: React.ReactNode; + prepend?: React.ReactNode; + append?: React.ReactNode; +} + +const InputGroupWrapper: React.FC = ({ + children, + prepend, + append, +}) => { + if (!prepend && !append) { + return <>{children}; + } + + return ( + + {!!prepend && {prepend}} + {children} + {!!append && {append}} + + ); +}; + +export default InputGroupWrapper; diff --git a/Hippo.Web/ClientApp/src/Shared/Form/formTypes.ts b/Hippo.Web/ClientApp/src/Shared/Form/formTypes.ts new file mode 100644 index 00000000..5447077c --- /dev/null +++ b/Hippo.Web/ClientApp/src/Shared/Form/formTypes.ts @@ -0,0 +1,32 @@ +import { InputProps } from "react-bootstrap-typeahead/types/types"; +import { + ArrayPath, + Control, + FieldError, + FieldErrors, + FieldPath, + RegisterOptions, + UseFormRegister, +} from "react-hook-form"; +import { InputType } from "reactstrap/types/lib/Input"; + +type FormFieldCommonProps = Omit & + RegisterOptions & { + type?: InputType; + label: string; + inputPrepend?: React.ReactNode; + inputAppend?: React.ReactNode; + register?: UseFormRegister; + }; + +export type FormFieldProps = FormFieldCommonProps & { + error?: FieldError; + name: FieldPath; +}; + +export type FormFieldArrayProps = FormFieldCommonProps & { + arrayName: ArrayPath; + errors: FieldErrors; + register: UseFormRegister; + control: Control; +}; diff --git a/Hippo.Web/ClientApp/src/Shared/HipButton.tsx b/Hippo.Web/ClientApp/src/Shared/HipButton.tsx new file mode 100644 index 00000000..4bb4abee --- /dev/null +++ b/Hippo.Web/ClientApp/src/Shared/HipButton.tsx @@ -0,0 +1,20 @@ +import React from "react"; +import { Button, ButtonProps } from "reactstrap"; + +interface HipButtonProps extends ButtonProps {} + +const HipButton: React.FC = ({ + disabled = false, + type = "button", + color = "primary", + children, + ...props +}) => { + return ( + + ); +}; + +export default HipButton; diff --git a/Hippo.Web/ClientApp/src/Shared/UsePermissions.ts b/Hippo.Web/ClientApp/src/Shared/usePermissions.ts similarity index 80% rename from Hippo.Web/ClientApp/src/Shared/UsePermissions.ts rename to Hippo.Web/ClientApp/src/Shared/usePermissions.ts index d59c7684..832b2db1 100644 --- a/Hippo.Web/ClientApp/src/Shared/UsePermissions.ts +++ b/Hippo.Web/ClientApp/src/Shared/usePermissions.ts @@ -21,5 +21,11 @@ export const usePermissions = () => { return false; }; - return { canViewGroup }; + const isClusterAdminForCluster = () => { + if (!clusterName) return false; + if (isSystemAdmin || isClusterAdmin) return true; + return false; + }; + + return { canViewGroup, isClusterAdminForCluster }; }; diff --git a/Hippo.Web/ClientApp/src/components/ClusterAdmin/Clusters.tsx b/Hippo.Web/ClientApp/src/components/ClusterAdmin/Clusters.tsx index c7557cc4..d1c34e8f 100644 --- a/Hippo.Web/ClientApp/src/components/ClusterAdmin/Clusters.tsx +++ b/Hippo.Web/ClientApp/src/components/ClusterAdmin/Clusters.tsx @@ -22,6 +22,7 @@ const defaultCluster: ClusterModel = { domain: "", email: "", accessTypes: AccessTypes, + allowOrders: false, }; export const Clusters = () => { diff --git a/Hippo.Web/ClientApp/src/components/Financial/FinancialDetail.tsx b/Hippo.Web/ClientApp/src/components/Financial/FinancialDetail.tsx new file mode 100644 index 00000000..3ae81667 --- /dev/null +++ b/Hippo.Web/ClientApp/src/components/Financial/FinancialDetail.tsx @@ -0,0 +1,265 @@ +import React, { useState, useEffect } from "react"; +import { ChartStringValidationModel, FinancialDetailModel } from "../../types"; +import { authenticatedFetch, parseBadRequest } from "../../util/api"; +import { useParams } from "react-router-dom"; +import { usePromiseNotification } from "../../util/Notifications"; +import { Card, CardBody, CardTitle } from "reactstrap"; + +declare const window: Window & + typeof globalThis & { + Finjector: any; + }; + +export const FinancialDetail = () => { + const [financialDetail, setFinancialDetail] = + useState(); + const { cluster: clusterName } = useParams(); + const [notification, setNotification] = usePromiseNotification(); + const [chartStringValidation, setChartStringValidation] = + useState(null); + + useEffect(() => { + // Fetch financial detail data from API or any other data source + // and set it to the state + const fetchFinancialDetail = async () => { + try { + const response = await fetch( + `/api/${clusterName}/admin/FinancialDetails`, + ); // Replace with your API endpoint + const data = await response.json(); + setFinancialDetail(data); + await validateChartString(data.chartString); + } catch (error) { + console.error("Error fetching financial detail:", error); + } + }; + + fetchFinancialDetail(); + }, [clusterName]); + + const handleInputChange = (event: React.ChangeEvent) => { + const { name, value } = event.target; + setFinancialDetail((prevFinancialDetail) => ({ + ...prevFinancialDetail, + [name]: value, + })); + }; + + const handleSubmit = async (event: React.FormEvent) => { + event.preventDefault(); + const request = authenticatedFetch( + `/api/${clusterName}/admin/UpdateFinancialDetails`, + { + method: "POST", + body: JSON.stringify(financialDetail), + }, + ); + setNotification( + request, + "Updating Financial Details", + "Financial Details Updated", + async (r) => { + if (r.status === 400) { + const errors = await parseBadRequest(await request); + return errors; + } else { + return "An error happened, please try again."; + } + }, + ); + if ((await request).ok) { + // refresh the data + const data = await (await request).json(); + setFinancialDetail(data); + await validateChartString(data.chartString); + } + }; + + const lookupChartString = async () => { + const chart = await window.Finjector.findChartSegmentString(); + + if (chart.status === "success") { + financialDetail.chartString = chart.data; + + setFinancialDetail((prevFinancialDetail) => ({ + ...prevFinancialDetail, + chartString: chart.data, + })); + + await validateChartString(chart.data); + } else { + alert("Failed!"); + } + }; + + const validateChartString = async (chartString: string) => { + let response = await authenticatedFetch( + `/api/order/validateChartString/${chartString}/Credit`, + { + method: "GET", + }, + ); + + if (response.ok) { + const result = await response.json(); + setChartStringValidation(result); + if (result.chartString) { + setFinancialDetail((prevFinancialDetail) => ({ + ...prevFinancialDetail, + chartString: result.chartString, + })); + } + } + }; + + if (!financialDetail) { + return
Loading...
; + } + + return ( +
+

Financial Detail

+
+
+
Financial API Key: {financialDetail.maskedApiKey}
+
+
+ + +
+ +
+ + +
+ +
+ + + setFinancialDetail((prevFinancialDetail) => ({ + ...prevFinancialDetail, + autoApprove: e.target.checked, + })) + } + /> +
+
+ {" "} + {financialDetail.chartString && ( + + {financialDetail.chartString} + + )} +
+ { + validateChartString(e.target.value); + }} + required + /> + +
+ {!financialDetail.isSlothValid && ( +
+
+ + +

The Sloth settings are not valid!

+
+ +
+ The Sloth settings are not valid. This could be the API + Source Name is wrong, or it doesn't match the Financial API + Key's team's settings. +
+
+
+
+ )} + {chartStringValidation && ( +
+
+ + +

Chart String Details:

+
+ +
+ Is Valid: {chartStringValidation.isValid ? "Yes" : "No"} +
+
Description: {chartStringValidation.description}
+ {chartStringValidation.accountManager && ( +
+
+ Account Manager: {chartStringValidation.accountManager} +
+
+ Account Manager Email:{" "} + {chartStringValidation.accountManagerEmail} +
+
+ )} + {chartStringValidation.message && ( +
Message: {chartStringValidation.message}
+ )} + + {chartStringValidation.warning && ( +
Warning: {chartStringValidation.warning}
+ )} +
+
+
+ )} +
+
+ +
+
+ ); +}; diff --git a/Hippo.Web/ClientApp/src/components/Group/GroupInfo.tsx b/Hippo.Web/ClientApp/src/components/Group/GroupInfo.tsx index 87452322..b5624626 100644 --- a/Hippo.Web/ClientApp/src/components/Group/GroupInfo.tsx +++ b/Hippo.Web/ClientApp/src/components/Group/GroupInfo.tsx @@ -1,5 +1,5 @@ import { ShowFor } from "../../Shared/ShowFor"; -import { usePermissions } from "../../Shared/UsePermissions"; +import { usePermissions } from "../../Shared/usePermissions"; import { GroupModel } from "../../types"; import { Button, CardSubtitle, CardText } from "reactstrap"; import { MouseEvent } from "react"; diff --git a/Hippo.Web/ClientApp/src/components/Order/BillingsFields.tsx b/Hippo.Web/ClientApp/src/components/Order/BillingsFields.tsx new file mode 100644 index 00000000..6e00038f --- /dev/null +++ b/Hippo.Web/ClientApp/src/components/Order/BillingsFields.tsx @@ -0,0 +1,278 @@ +import React, { useState } from "react"; +import { useFieldArray, useFormContext, useWatch } from "react-hook-form"; +import { OrderModel } from "../../types"; + +import FormField from "../../Shared/Form/FormField"; +import HipButton from "../../Shared/HipButton"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faPlus, faTrash, faSearch } from "@fortawesome/free-solid-svg-icons"; +import { authenticatedFetch } from "../../util/api"; +import ChartStringValidation from "./ChartStringValidation"; +import OrderFormField from "./OrderFormField"; +import { Card, CardBody, CardTitle } from "reactstrap"; + +declare const window: Window & + typeof globalThis & { + Finjector: any; + }; + +type BillingsFieldsProps = { + readOnly: boolean; +}; + +const BillingsFields: React.FC = ({ readOnly }) => { + const { + control, + register, + getValues, + setValue, + formState: { errors }, + } = useFormContext(); + + const { fields, append, remove, update } = useFieldArray({ + control, + name: "billings", + }); + + const addBilling = () => { + const percentTotal = getValues("percentTotal"); + let percentToSet = 100 - percentTotal; + if (percentToSet < 0) { + percentToSet = 0; + } + if (percentToSet > 100) { + percentToSet = 100; + } + + append({ + id: 0, + chartString: "", + percentage: percentToSet.toString(), + chartStringValidation: { + isValid: true, + description: "", + accountManager: "", + accountManagerEmail: "", + message: "", + warning: "", + }, + }); + }; + + const removeBilling = (index: number) => { + remove(index); + }; + + const [notification, setNotification] = useState(""); + const showNotification = (message: string) => { + setNotification(message); + // Optionally, clear the notification after some time + setTimeout(() => setNotification(""), 5000); + }; + + const lookupChartString = async (index: number) => { + const existingBilling = getValues("billings")[index]; + + const chart = await window.Finjector.findChartSegmentString(); + + if (chart.status === "success") { + //add the chart.data chartString input + + const rtValue = await validateChartString(chart.data, index); + + update(index, { + chartString: rtValue.chartString, + id: existingBilling.id, + percentage: existingBilling.percentage, + chartStringValidation: { + isValid: rtValue.isValid, + description: rtValue.description, + accountManager: rtValue.accountManager, + accountManagerEmail: rtValue.accountManagerEmail, + message: rtValue.message, + warning: rtValue.warning, + }, + }); + } else { + alert( + "Unknown error happened. Please try again and let us know if the problem persists.", + ); + } + }; + + const onChartStringBlur = async (index: number, chartString: string) => { + if (!chartString) { + return; + } + + const existingBilling = getValues("billings")[index]; + + const rtValue = await validateChartString(chartString, index); + + update(index, { + chartString: rtValue.chartString, + id: existingBilling.id, + percentage: existingBilling.percentage, + chartStringValidation: { + isValid: rtValue.isValid, + description: rtValue.description, + accountManager: rtValue.accountManager, + accountManagerEmail: rtValue.accountManagerEmail, + message: rtValue.message, + warning: rtValue.warning, + }, + }); + }; + + const validateChartString = async (chartString: string, index: number) => { + let response = await authenticatedFetch( + `/api/order/validateChartString/${chartString}/Debit`, + { + method: "GET", + }, + ); + + if (response.ok) { + const result = await response.json(); + if (chartString !== result.chartString) { + showNotification(result.warning); + } + return result; + } + return { isValid: false, message: "Failed to validate chart string" }; + }; + + const billings = useWatch({ + control, + name: "billings", + }); + + const percentTotal = billings.reduce((acc, billing) => { + const percentage = parseFloat(billing.percentage); + return isNaN(percentage) ? acc : acc + percentage; + }, 0); + + setValue("percentTotal", percentTotal); + + if (readOnly && fields.length === 0) { + return null; + } + + return ( + <> +

Billing Info

+

Chart Strings

+ {notification && ( +
+
+ + +

The Chart String has been updated!

+
+ +
{notification}
+
+
+
+ )} + + + + + + + + + + + {fields.map((field, index) => { + return ( + + + + + {!readOnly && ( + + )} + {readOnly && } + + ); + })} + + + + + + + +
Chart StringPercentChart String Details
+ { + onChartStringBlur(index, e.target.value); + }} + readOnly={readOnly} + /> + + + + + + lookupChartString(index)} + > + + {" "} + removeBilling(index)} + > + + +
Percent Total + +
+ + {!readOnly && ( + + Add Billing + + )} + + ); +}; + +export default BillingsFields; diff --git a/Hippo.Web/ClientApp/src/components/Order/ChartStringValidation.tsx b/Hippo.Web/ClientApp/src/components/Order/ChartStringValidation.tsx new file mode 100644 index 00000000..770da5c5 --- /dev/null +++ b/Hippo.Web/ClientApp/src/components/Order/ChartStringValidation.tsx @@ -0,0 +1,87 @@ +import React from "react"; +import { authenticatedFetch } from "../../util/api"; +import { ChartStringValidationModel } from "../../types"; +import { faCircleNotch } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; + +interface ChartStringValidationProps { + chartString: string; +} + +type ChartStringStatus = "loading" | "error" | "success" | undefined; + +const ChartStringValidation: React.FC = ({ + chartString, +}) => { + const [chartStringValidation, setChartStringValidation] = + React.useState(null); + const [status, setStatus] = React.useState(); + + React.useEffect(() => { + if (!chartString) { + setStatus(undefined); + return; + } + + const validateChartString = async () => { + setStatus("loading"); + try { + let response = await authenticatedFetch( + `/api/order/validateChartString/${chartString}/Debit`, + { + method: "GET", + }, + ); + if (response.ok) { + const result: ChartStringValidationModel = await response.json(); + setChartStringValidation(result); + setStatus("success"); + } else { + setStatus("error"); + } + } catch (error) { + setStatus("error"); + } + }; + + validateChartString(); + }, [chartString]); + + // default to showing loading state on mount + if (status === "loading" || status === undefined) { + return ( + + + + ); + } + + if (status === "error") { + return Error loading chart string validation; + } + + return ( + + {chartStringValidation.isValid ? ( + + {chartStringValidation.description} + + ) : ( + + {chartStringValidation.message} + + )} + {chartStringValidation.warning && ( + <> +
+ + {" "} + {chartStringValidation.warning} + + + )} +
+ ); +}; + +export default ChartStringValidation; diff --git a/Hippo.Web/ClientApp/src/components/Order/CreateOrder.tsx b/Hippo.Web/ClientApp/src/components/Order/CreateOrder.tsx new file mode 100644 index 00000000..001550ff --- /dev/null +++ b/Hippo.Web/ClientApp/src/components/Order/CreateOrder.tsx @@ -0,0 +1,163 @@ +import React, { useEffect, useState } from "react"; +import { OrderModel } from "../../types"; +import { useNavigate, useParams } from "react-router-dom"; +import { usePermissions } from "../../Shared/usePermissions"; +import { usePromiseNotification } from "../../util/Notifications"; +import OrderForm from "./OrderForm"; +import { authenticatedFetch, parseBadRequest } from "../../util/api"; + +const defaultOrder: OrderModel = { + id: 0, + PILookup: "", + category: "", + name: "", + productName: "", + description: "", + notes: "", + units: "", + unitPrice: "", + installments: 5, + installmentType: "Yearly", + quantity: 0, + adjustment: 0, + adjustmentReason: "", + status: "N/A", + createdOn: "", + externalReference: "", + adminNotes: "", + subTotal: "", + total: "", + balanceRemaining: "", + metaData: [], + billings: [], + payments: [], + history: [], + percentTotal: 0, +}; +export const CreateOrder: React.FC = () => { + const { cluster, productId } = useParams(); + const { isClusterAdminForCluster } = usePermissions(); + const [order, setOrder] = useState(null); + const [isClusterAdmin, setIsClusterAdmin] = useState(null); + const [notification, setNotification] = usePromiseNotification(); + const navigate = useNavigate(); + + useEffect(() => { + setIsClusterAdmin(isClusterAdminForCluster()); + }, [isClusterAdmin, isClusterAdminForCluster]); + + useEffect(() => { + if (productId) { + const fetchProductOrder = async () => { + const response = await authenticatedFetch( + `/api/${cluster}/order/GetProduct/${productId}`, + ); + + if (response.ok) { + const data = await response.json(); + setOrder(data); + } else { + alert("Error fetching product for order"); + } + }; + + fetchProductOrder(); + } else { + if (isClusterAdmin === false) { + navigate(`/${cluster}/product/index`); + } else { + setOrder(defaultOrder); + } + } + }, [cluster, isClusterAdmin, navigate, productId]); + + // async function so the form can manage the loading state + const submitOrder = async (updatedOrder: OrderModel) => { + const editedOrder: OrderModel = { + // uneditable fields + id: updatedOrder.id, + status: updatedOrder.status, + createdOn: updatedOrder.createdOn, + total: updatedOrder.total, + subTotal: updatedOrder.subTotal, + balanceRemaining: updatedOrder.balanceRemaining, + payments: updatedOrder.payments, + history: updatedOrder.history, + piUser: updatedOrder.piUser, + percentTotal: updatedOrder.percentTotal, + nextPaymentDate: updatedOrder.nextPaymentDate, + + // editable fields + PILookup: updatedOrder.PILookup, + name: updatedOrder.name, + productName: updatedOrder.productName, + description: updatedOrder.description, + category: updatedOrder.category, + externalReference: updatedOrder.externalReference, + notes: updatedOrder.notes, + units: updatedOrder.units, + unitPrice: updatedOrder.unitPrice, + quantity: updatedOrder.quantity, + installments: updatedOrder.installments, + installmentType: updatedOrder.installmentType, + adjustment: updatedOrder.adjustment, + adjustmentReason: updatedOrder.adjustmentReason, + adminNotes: updatedOrder.adminNotes, + metaData: updatedOrder.metaData, + lifeCycle: updatedOrder.lifeCycle, + expirationDate: updatedOrder.expirationDate, + installmentDate: updatedOrder.installmentDate, + billings: updatedOrder.billings, + }; + + const req = authenticatedFetch(`/api/${cluster}/order/Save`, { + method: "POST", + body: JSON.stringify(editedOrder), + }); + + setNotification(req, "Saving", "Order Saved", async (r) => { + if (r.status === 400) { + const errors = await parseBadRequest(response); + return errors; + } else { + return "An error happened, please try again."; + } + }); + + const response = await req; + + if (response.ok) { + const data = await response.json(); + + navigate(`/${cluster}/order/details/${data.id}`); + } + + setOrder(editedOrder); // should be newOrder once it's pulling from the API + }; + + if (isClusterAdmin === null) { + return
Loading...
; + } + + if (!order) { + return
Loading... {productId}
; + } + + return ( +
+
+

Create Order

+ + + {notification.pending &&
Saving...
} +
+
+ ); +}; diff --git a/Hippo.Web/ClientApp/src/components/Order/Details.tsx b/Hippo.Web/ClientApp/src/components/Order/Details.tsx new file mode 100644 index 00000000..183810bb --- /dev/null +++ b/Hippo.Web/ClientApp/src/components/Order/Details.tsx @@ -0,0 +1,682 @@ +import React, { useCallback, useContext, useEffect, useState } from "react"; +import { Link, useParams } from "react-router-dom"; +import { + HistoryModel, + OrderModel, + PaymentModel, + UpdateOrderStatusModel, +} from "../../types"; +import { authenticatedFetch, parseBadRequest } from "../../util/api"; +import { ReactTable } from "../../Shared/ReactTable"; +import { createColumnHelper } from "@tanstack/react-table"; +import OrderForm from "./OrderForm"; +import { usePermissions } from "../../Shared/usePermissions"; +import { useConfirmationDialog } from "../../Shared/ConfirmationDialog"; +import { usePromiseNotification } from "../../util/Notifications"; +import { notEmptyOrFalsey } from "../../util/ValueChecks"; +import { ShowFor } from "../../Shared/ShowFor"; +import AppContext from "../../Shared/AppContext"; +import { + convertToPacificDate, + convertToPacificTime, +} from "../../util/DateHelper"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faDollarSign } from "@fortawesome/free-solid-svg-icons"; + +export const Details = () => { + const { cluster, orderId } = useParams(); + const [{ user }] = useContext(AppContext); + const [order, setOrder] = useState(null); + const [balanceRemaining, setBalanceRemaining] = useState(0); + const [balancePending, setBalancePending] = useState(0); + const { isClusterAdminForCluster } = usePermissions(); + const [isClusterAdmin, setIsClusterAdmin] = useState(null); + const [notification, setNotification] = usePromiseNotification(); + const [updateStatusModel, setUpdateStatusModel] = + useState(null); + const adminEditableStatuses = ["Processing", "Active"]; + const sponsorEditableStatuses = ["Created"]; + + useEffect(() => { + setIsClusterAdmin(isClusterAdminForCluster()); + }, [isClusterAdmin, isClusterAdminForCluster]); + + const calculateBalanceRemaining = (data: any) => { + const balanceRemaining = parseFloat(data.balanceRemaining); + setBalanceRemaining(balanceRemaining); + const balancePending = data.payments + .filter( + (payment) => + payment.status !== "Completed" && payment.status !== "Cancelled", + ) + .reduce((acc, payment) => acc + parseFloat(payment.amount), 0); + setBalancePending(balancePending); + }; + + useEffect(() => { + const fetchOrder = async () => { + const response = await authenticatedFetch( + `/api/${cluster}/order/get/${orderId}`, + ); + + if (response.ok) { + const data = await response.json(); + + setOrder(data); + calculateBalanceRemaining(data); + } else { + alert("Error fetching order"); + } + }; + + fetchOrder(); + }, [cluster, orderId]); + + useEffect(() => { + if (order) { + // switch statement for data.status + switch (order.status) { + case "Created": + setUpdateStatusModel({ + currentStatus: order.status, + newStatus: "Submitted", + }); + break; + case "Submitted": + setUpdateStatusModel({ + currentStatus: order.status, + newStatus: "Processing", + }); + break; + case "Processing": + setUpdateStatusModel({ + currentStatus: order.status, + newStatus: "Active", + }); + break; + default: + setUpdateStatusModel({ + currentStatus: order.status, + newStatus: order.status, + }); + } + } + }, [order]); + + const historyColumnHelper = createColumnHelper(); + + const historyColumns = [ + historyColumnHelper.accessor("actedDate", { + header: "Date", + id: "actedDate", + cell: (value) => ( + {convertToPacificTime(value.row.original.actedDate)} + ), + }), + historyColumnHelper.accessor("actedBy", { + header: "Actor", + id: "actedBy", + cell: (value) => ( + <> + {value.row.original.actedBy ? ( + <> + {value.row.original.actedBy.name} ( + {value.row.original.actedBy.email}) + + ) : ( + <>System + )} + + ), + }), + historyColumnHelper.accessor("status", { header: "Status", id: "status" }), + historyColumnHelper.accessor("details", { + header: "Details", + id: "details", + }), + ]; + + const paymentColumnHelper = createColumnHelper(); + + const paymentColumns = [ + paymentColumnHelper.accessor("amount", { + header: "Amount", + id: "amount", + cell: (value) => ( + + {" "} + {value.row.original.amount.toFixed(2)} + + ), + }), + paymentColumnHelper.accessor("status", { header: "Status", id: "status" }), + paymentColumnHelper.accessor("createdOn", { + header: "Created On", + id: "createdOn", + cell: (value) => ( + {convertToPacificTime(value.row.original.createdOn)} + ), + }), + paymentColumnHelper.accessor("createdBy", { + header: "Created By", + id: "createdBy", + cell: (value) => ( + <> + {value.row.original.createdBy && ( + <> + {value.row.original.createdBy.firstName}{" "} + {value.row.original.createdBy.lastName} ( + {value.row.original.createdBy.email}) + + )} + {!value.row.original.createdBy && <>System} + + ), + }), + ]; + + // async function so the form can manage the loading state + const submitOrder = async (updatedOrder: OrderModel) => { + const editedOrder: OrderModel = { + // uneditable fields + id: updatedOrder.id, + status: updatedOrder.status, + createdOn: updatedOrder.createdOn, + total: updatedOrder.total, + subTotal: updatedOrder.subTotal, + balanceRemaining: updatedOrder.balanceRemaining, + billings: updatedOrder.billings, + payments: updatedOrder.payments, + history: updatedOrder.history, + piUser: updatedOrder.piUser, + percentTotal: updatedOrder.percentTotal, + nextPaymentDate: updatedOrder.nextPaymentDate, + + // editable fields + PILookup: updatedOrder.PILookup, + name: updatedOrder.name, + productName: updatedOrder.productName, + description: updatedOrder.description, + category: updatedOrder.category, + externalReference: updatedOrder.externalReference, + notes: updatedOrder.notes, + units: updatedOrder.units, + unitPrice: updatedOrder.unitPrice, + quantity: updatedOrder.quantity, + installments: updatedOrder.installments, + installmentType: updatedOrder.installmentType, + adjustment: updatedOrder.adjustment, + adjustmentReason: updatedOrder.adjustmentReason, + adminNotes: updatedOrder.adminNotes, + metaData: updatedOrder.metaData, + lifeCycle: updatedOrder.lifeCycle, + expirationDate: updatedOrder.expirationDate, + installmentDate: updatedOrder.installmentDate, + }; + + // TODO: await API call + // const newOrder = await new Promise((resolve) => setTimeout(resolve, 1000)); + + setOrder(editedOrder); // should be newOrder once it's pulling from the API + }; + + const [editPaymentModel, setEditPaymentModel] = useState({ + id: 0, + amount: 0, + entryAmount: "", + status: "", + createdOn: "", + }); + + const [makePaymentConfirmation] = useConfirmationDialog( + { + title: "Make One Time Payment", + message: (setReturn) => ( + <> +
+ + { + const value = e.target.value; + if (/^\d*\.?\d*$/.test(value) || /^\d*\.$/.test(value)) { + // This regex checks for a valid decimal or integer + const model: PaymentModel = { + ...editPaymentModel, + amount: parseFloat(value), + entryAmount: value, + }; + setEditPaymentModel(model); + setReturn(model); + } + }} + /> +
+ + ), + canConfirm: !notification.pending && editPaymentModel.amount > 0, + }, + [editPaymentModel, notification.pending], + ); + + const makePayment = useCallback(async () => { + const [confirmed, editPaymentModel] = await makePaymentConfirmation(); + + if (!confirmed) { + return; + } + + const req = authenticatedFetch( + `/api/${cluster}/order/makepayment/${orderId}?amount=${editPaymentModel.amount}`, + { + method: "POST", + }, + ); + setNotification(req, "Making Payment", "Payment Made", async (r) => { + if (r.status === 400) { + const errors = await parseBadRequest(response); + return errors; + } else { + return "An error happened, please try again."; + } + }); + + const response = await req; + + if (response.ok) { + const data = await response.json(); + setOrder(data); + setEditPaymentModel({ + id: 0, + amount: 0, + status: "", + createdOn: "", + entryAmount: "", + }); + calculateBalanceRemaining(data); + } + }, [cluster, orderId, makePaymentConfirmation, setNotification]); + + const [approveOrderConfirmation] = + useConfirmationDialog( + { + title: "Update Order Status", + message: (setReturn) => ( + <> +
Current Status: {updateStatusModel.currentStatus}
+
Set Status to: {updateStatusModel.newStatus}
+
+ {updateStatusModel.newStatus === "Submitted" && ( +
+ This will submit the order to the cluster admins for processing. +
+ )} + {updateStatusModel.newStatus === "Processing" && ( +
+ This will indicate that an admin will start working on the + order. +
+ )} + {updateStatusModel.newStatus === "Active" && ( +
+ This will move the order to active and allow manual billing as + well as scheduled billing. +
+ )} + + ), + canConfirm: !notification.pending, + }, + [order, notification.pending, updateStatusModel], + ); + + const updateStatus = useCallback(async () => { + const [confirmed] = await approveOrderConfirmation(); + + if (!confirmed) { + return; + } + + const req = authenticatedFetch( + `/api/${cluster}/order/changeStatus/${orderId}?expectedStatus=${updateStatusModel.newStatus}`, + { + method: "POST", + }, + ); + setNotification(req, "Updating Status", "Status Updated", async (r) => { + if (r.status === 400) { + const errors = await parseBadRequest(response); + return errors; + } else { + return "An error happened, please try again."; + } + }); + + const response = await req; + + if (response.ok) { + const data = await response.json(); + setOrder(data); + } + }, [ + cluster, + orderId, + approveOrderConfirmation, + setNotification, + updateStatusModel, + ]); + + const [cancelOrderConfirmation] = useConfirmationDialog({ + title: "Cancel Order", + message: "Are you sure you want to cancel this order?", + canConfirm: !notification.pending, + }); + + const cancelOrder = async () => { + const [confirmed] = await cancelOrderConfirmation(); + + if (!confirmed) { + return; + } + + const req = authenticatedFetch( + `/api/${cluster}/order/CancelOrder/${orderId}`, + { + method: "POST", + }, + ); + setNotification(req, "Cancelling Order", "Order Cancelled", async (r) => { + if (r.status === 400) { + const errors = await parseBadRequest(response); + return errors; + } else { + return "An error happened, please try again."; + } + }); + + const response = await req; + + if (response.ok) { + const data = await response.json(); + setOrder(data); //Maybe redirect? + } + }; + + const [rejectOrderConfirmation] = useConfirmationDialog({ + title: "Reject Order", + message: (setReturn) => { + return ( +
+
+
+ + + { + setReturn(e.target.value); + }} + > +
+
+
+ ); + }, + canConfirm: (returnValue) => notEmptyOrFalsey(returnValue), + }); + + const rejectOrder = async () => { + const [confirmed, reason] = await rejectOrderConfirmation(); + + if (!confirmed) { + return; + } + + const req = authenticatedFetch( + `/api/${cluster}/order/reject/${orderId}?reason=${reason}`, + { + method: "POST", + }, + ); + setNotification(req, "Rejecting Order", "Order Rejected", async (r) => { + if (r.status === 400) { + const errors = await parseBadRequest(response); + return errors; + } else { + return "An error happened, please try again."; + } + }); + + const response = await req; + + if (response.ok) { + const data = await response.json(); + setOrder(data); + } + }; + + if (!order) { + return
Loading...
; + } + + return ( +
+
+
+

Order Details: Id {order.id}

+

+ {order.piUser?.name} ({order.piUser?.email}) +

+ {order.piUser?.id === user.detail.id && + order.status === "Created" && + order.billings.length <= 0 && ( +

+ This order needs to have billing information added before it can + be submitted (Approve). +

+ )} + + + Edit Order + {" "} + + + + Edit Order + {" "} + + + {" "} + + {/* If you are the sponsor (PI) and it is in the created status, you can move it to submitted if there is billing info */} + 0 + } + > + {" "} + + + {" "} + + + {" "} + + + + Update Chart Strings + {" "} + + 0 + } + > + + + +

History

+ +

Payments

+
+ +
+
+ + + +
+ +
+
+ {balancePending !== 0 && ( +
+ +
+
+ + + +
+ +
+
+ )} + {order.nextPaymentDate && ( + <> +
+ + +
+
+ +
+
+ + + +
+ +
+
+ + )} + {order.payments.length !== 0 && ( + + )} +
+
+
+ ); +}; diff --git a/Hippo.Web/ClientApp/src/components/Order/EditOrder.tsx b/Hippo.Web/ClientApp/src/components/Order/EditOrder.tsx new file mode 100644 index 00000000..551133fc --- /dev/null +++ b/Hippo.Web/ClientApp/src/components/Order/EditOrder.tsx @@ -0,0 +1,129 @@ +import React, { useEffect, useState } from "react"; +import { OrderModel } from "../../types"; +import { useNavigate, useParams } from "react-router-dom"; +import { usePermissions } from "../../Shared/usePermissions"; +import { usePromiseNotification } from "../../util/Notifications"; +import OrderForm from "./OrderForm"; +import { authenticatedFetch, parseBadRequest } from "../../util/api"; + +export const EditOrder: React.FC = () => { + const { cluster, orderId } = useParams(); + const { isClusterAdminForCluster } = usePermissions(); + const [order, setOrder] = useState(null); + const [isClusterAdmin, setIsClusterAdmin] = useState(null); + const [notification, setNotification] = usePromiseNotification(); + const navigate = useNavigate(); + + useEffect(() => { + setIsClusterAdmin(isClusterAdminForCluster()); + }, [isClusterAdmin, isClusterAdminForCluster]); + + useEffect(() => { + const fetchOrder = async () => { + const response = await authenticatedFetch( + `/api/${cluster}/order/get/${orderId}`, + ); + + if (response.ok) { + const data = await response.json(); + setOrder(data); + } else { + alert("Error fetching order"); + } + }; + + fetchOrder(); + }, [cluster, orderId]); + + // async function so the form can manage the loading state + const submitOrder = async (updatedOrder: OrderModel) => { + const editedOrder: OrderModel = { + // uneditable fields + id: updatedOrder.id, + status: updatedOrder.status, + createdOn: updatedOrder.createdOn, + total: updatedOrder.total, + subTotal: updatedOrder.subTotal, + balanceRemaining: updatedOrder.balanceRemaining, + payments: updatedOrder.payments, + history: updatedOrder.history, + piUser: null, + percentTotal: updatedOrder.percentTotal, + nextPaymentDate: updatedOrder.nextPaymentDate, + + // editable fields + PILookup: updatedOrder.PILookup, + name: updatedOrder.name, + productName: updatedOrder.productName, + description: updatedOrder.description, + category: updatedOrder.category, + externalReference: updatedOrder.externalReference, + notes: updatedOrder.notes, + units: updatedOrder.units, + unitPrice: updatedOrder.unitPrice, + quantity: updatedOrder.quantity, + installments: updatedOrder.installments, + installmentType: updatedOrder.installmentType, + adjustment: updatedOrder.adjustment, + adjustmentReason: updatedOrder.adjustmentReason, + adminNotes: updatedOrder.adminNotes, + metaData: updatedOrder.metaData, + lifeCycle: updatedOrder.lifeCycle, + expirationDate: updatedOrder.expirationDate, + installmentDate: updatedOrder.installmentDate, + billings: updatedOrder.billings, + }; + + const req = authenticatedFetch(`/api/${cluster}/order/Save`, { + method: "POST", + body: JSON.stringify(editedOrder), + }); + + setNotification(req, "Saving", "Order Saved", async (r) => { + if (r.status === 400) { + const errors = await parseBadRequest(response); + return errors; + } else { + return "An error happened, please try again."; + } + }); + + const response = await req; + + if (response.ok) { + const data = await response.json(); + + navigate(`/${cluster}/order/details/${data.id}`); + } + + setOrder(editedOrder); // should be newOrder once it's pulling from the API + }; + + if (isClusterAdmin === null) { + return
Loading...
; + } + + if (!order) { + return
Loading... {orderId}
; + } + + return ( +
+ {order && ( +
+

Edit Order

+ + + {notification.pending &&
Saving...
} +
+ )} +
+ ); +}; diff --git a/Hippo.Web/ClientApp/src/components/Order/MetaDataFields.tsx b/Hippo.Web/ClientApp/src/components/Order/MetaDataFields.tsx new file mode 100644 index 00000000..d3c628d9 --- /dev/null +++ b/Hippo.Web/ClientApp/src/components/Order/MetaDataFields.tsx @@ -0,0 +1,94 @@ +import React from "react"; +import { useFieldArray, useFormContext } from "react-hook-form"; +import { OrderModel } from "../../types"; + +import FormField from "../../Shared/Form/FormField"; +import { Row, Col } from "reactstrap"; +import HipButton from "../../Shared/HipButton"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faPlus, faTrash } from "@fortawesome/free-solid-svg-icons"; + +type MetaDataFieldsProps = { + readOnly: boolean; +}; + +const MetaDataFields: React.FC = ({ readOnly }) => { + const { + control, + register, + formState: { errors }, + } = useFormContext(); + + const { fields, append, remove } = useFieldArray({ + control, + name: "metaData", + }); + + const addMetaData = () => { + append({ id: 0, name: "", value: "" }); + }; + + const removeMetaData = (index: number) => { + remove(index); + }; + + if (readOnly && fields.length === 0) { + return null; + } + + return ( + <> +

Metadata

+ {fields.map((field, index) => { + return ( + + + + + + + + {!readOnly && ( + + removeMetaData(index)} + > + + + + )} + + ); + })} + {!readOnly && ( + + Add Metadata + + )} + + ); +}; + +export default MetaDataFields; diff --git a/Hippo.Web/ClientApp/src/components/Order/OrderForm.tsx b/Hippo.Web/ClientApp/src/components/Order/OrderForm.tsx new file mode 100644 index 00000000..6aaf48bd --- /dev/null +++ b/Hippo.Web/ClientApp/src/components/Order/OrderForm.tsx @@ -0,0 +1,343 @@ +import React, { useState } from "react"; +import { FormProvider, useForm, useWatch } from "react-hook-form"; +import { OrderModel } from "../../types"; +import { Form } from "reactstrap"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faDollarSign } from "@fortawesome/free-solid-svg-icons"; +import FormSubmitButton from "../../Shared/Form/FormSubmitButton"; +import MetaDataFields from "./MetaDataFields"; +import OrderFormField from "./OrderFormField"; +import OrderFormTotalFields from "./OrderFormTotalFields"; +import { authenticatedFetch } from "../../util/api"; +import BillingsFields from "./BillingsFields"; +import { ShowFor } from "../../Shared/ShowFor"; + +interface OrderFormProps { + orderProp: OrderModel; + readOnly: boolean; + isAdmin: boolean; + cluster: string; + onlyChartStrings: boolean; + onSubmit: (order: OrderModel) => Promise; +} + +const OrderForm: React.FC = ({ + orderProp, + readOnly, + isAdmin, + cluster, + onlyChartStrings, + onSubmit, +}) => { + const methods = useForm({ + defaultValues: orderProp, + mode: "onBlur", + }); + const { + handleSubmit, + setError, + formState: { isDirty, isSubmitting }, + } = methods; + + const [foundPI, setFoundPI] = useState(null); + const [localInstallmentType, setLocalInstallmentType] = useState( + methods.getValues("installmentType"), + ); + const [limitedEditing, setLimitedEditing] = useState(false); + + React.useEffect(() => { + const newStatus = orderProp.status; + methods.setValue("status", newStatus); + + if ( + newStatus === "Active" || + newStatus === "Rejected" || + newStatus === "Cancelled" || + newStatus === "Completed" + ) { + setLimitedEditing(true); + } else { + setLimitedEditing(false); + } + + const newInstallmentDate = orderProp.installmentDate; + const newExpirationDate = orderProp.expirationDate; + methods.setValue("installmentDate", newInstallmentDate); + methods.setValue("expirationDate", newExpirationDate); + }, [ + methods, + orderProp.expirationDate, + orderProp.installmentDate, + orderProp.status, + ]); + + //lookup pi value + const lookupPI = async (pi: string) => { + if (!pi) { + setFoundPI(""); + return; + } + const response = await authenticatedFetch( + `/api/${cluster}/order/GetClusterUser/${pi}`, + ); + if (response.ok) { + const data = await response.json(); + if (data?.name) { + setFoundPI(`Found User ${data.name} (${data.email})`); + } else { + setFoundPI(`Not Found ${pi}`); + } + } else { + setFoundPI(`Not Found ${pi}`); + } + }; + + const submitForm = async (data: OrderModel) => { + if (!isDirty || isSubmitting) { + // if they've made no changes or we're already submitting, don't submit again + // the button disables itself in this case, but just to be sure + return; + } + try { + await onSubmit(data); + } catch (error) { + // displayed inside FormSubmitButton + setError("root", { + type: "server", + message: "An error occurred submitting your order, please try again.", + }); + } + }; + + const installmentType = useWatch({ + control: methods.control, + name: "installmentType", + }); + const installments = useWatch({ + control: methods.control, + name: "installments", + }); + + if (installmentType !== localInstallmentType) { + setLocalInstallmentType(installmentType); + if (installmentType === "OneTime" && installments !== 1) { + methods.setValue("installments", 1); + } + if ( + installmentType === "Monthly" && + (installments === 1 || installments === 5) + ) { + methods.setValue("installments", 60); + } + if ( + installmentType === "Yearly" && + (installments === 1 || installments === 60) + ) { + methods.setValue("installments", 5); + } + } + + // TODO: rest of input validation? + return ( + +
+ +
+ {onlyChartStrings && } + {!onlyChartStrings && ( + <> + {isAdmin && !readOnly && orderProp.id === 0 && ( + <> + { + lookupPI(e.target.value); + }} + /> + {foundPI && {foundPI}} + + )} + + <> + + + + + + } + valueAsNumber={true} + deps={"total"} + /> + {readOnly && ( + + )} + {!readOnly && ( + + + + + + )} + {installmentType !== "OneTime" && ( + + )} + + + + + + + + + + + + <> + } + valueAsNumber={true} + deps={"total"} + /> + + + + + + {isAdmin && ( + + )} + + <> + +
+ +
+ +
+ + + + )} + + {!readOnly && } + +
+ ); +}; + +export default OrderForm; diff --git a/Hippo.Web/ClientApp/src/components/Order/OrderFormField.tsx b/Hippo.Web/ClientApp/src/components/Order/OrderFormField.tsx new file mode 100644 index 00000000..8e76c03c --- /dev/null +++ b/Hippo.Web/ClientApp/src/components/Order/OrderFormField.tsx @@ -0,0 +1,20 @@ +import React from "react"; +import { OrderModel } from "../../types"; +import FormField from "../../Shared/Form/FormField"; +import { useFormContext } from "react-hook-form"; +import { FormFieldProps } from "../../Shared/Form/formTypes"; + +type OrderFormFieldProps = FormFieldProps & {}; + +const OrderFormField: React.FC = ({ ...props }) => { + const { + register, + formState: { errors }, + } = useFormContext(); + + return ( + + ); +}; + +export default OrderFormField; diff --git a/Hippo.Web/ClientApp/src/components/Order/OrderFormTotalFields.tsx b/Hippo.Web/ClientApp/src/components/Order/OrderFormTotalFields.tsx new file mode 100644 index 00000000..d00d9d07 --- /dev/null +++ b/Hippo.Web/ClientApp/src/components/Order/OrderFormTotalFields.tsx @@ -0,0 +1,56 @@ +import { OrderModel } from "../../types"; +import { useFormContext, useWatch } from "react-hook-form"; +import { faDollarSign } from "@fortawesome/free-solid-svg-icons"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import OrderFormField from "./OrderFormField"; + +type OrderFormTotalFieldsProps = {}; + +const OrderFormTotalFields: React.FC = () => { + const { setValue } = useFormContext(); + + // watch these values and recalculate when they change + // to have changes trigger validation for the total field, + // add it as a dep prop for quanitity, unitPrice, and adjustment fields + const quantity = useWatch({ + name: "quantity", + }); + + const unitPrice = useWatch({ + name: "unitPrice", + }); + + const adjustment = useWatch({ + name: "adjustment", + }); + + const subTotal = quantity * parseFloat(unitPrice); + const total = subTotal + Number(adjustment); + + setValue("subTotal", subTotal.toFixed(2)); + setValue("total", total.toFixed(2)); + + return ( + <> + } + type="number" + /> + } + /> + + ); +}; + +export default OrderFormTotalFields; diff --git a/Hippo.Web/ClientApp/src/components/Order/Orders.tsx b/Hippo.Web/ClientApp/src/components/Order/Orders.tsx new file mode 100644 index 00000000..127c9290 --- /dev/null +++ b/Hippo.Web/ClientApp/src/components/Order/Orders.tsx @@ -0,0 +1,141 @@ +import React, { useEffect, useMemo, useState } from "react"; +import { OrderListModel } from "../../types"; +import { Link, useParams } from "react-router-dom"; +import { authenticatedFetch } from "../../util/api"; + +import { ReactTable } from "../../Shared/ReactTable"; +import { createColumnHelper } from "@tanstack/react-table"; +import { convertToPacificDate } from "../../util/DateHelper"; + +export const Orders = () => { + const [orders, setOrders] = useState(); + const { cluster, orderType } = useParams(); + + useEffect(() => { + const fetchOrders = async () => { + const response = await authenticatedFetch( + `/api/${cluster}/order/${orderType}`, + ); + + if (response.ok) { + const data = await response.json(); + setOrders(data); + } else { + alert("Error fetching orders"); + } + }; + + fetchOrders(); + }, [cluster, orderType]); + + const columnHelper = createColumnHelper(); + + const id = columnHelper.accessor("id", { + header: "ID", + id: "id", + }); + + const status = columnHelper.accessor("status", { + header: "Status", + id: "status", + }); + + const sponsorName = columnHelper.accessor("sponsorName", { + header: "Sponsor", + id: "sponsorName", + }); + + const name = columnHelper.accessor("name", { + header: "Order Name", + id: "name", + }); + + const units = columnHelper.accessor("units", { + header: "Units", + id: "units", + }); + + const quantity = columnHelper.accessor("quantity", { + header: "Quantity", + id: "quantity", + }); + + const total = columnHelper.accessor("total", { + header: "Total", + id: "total", + }); + + const balanceRemaining = columnHelper.accessor("balanceRemaining", { + header: "Balance", + id: "balanceRemaining", + }); + + const createdOn = columnHelper.accessor("createdOn", { + header: "Created On", + id: "createdOn", + cell: (value) => convertToPacificDate(value.row.original.createdOn), + sortingFn: (rowA, rowB) => { + const dateA = new Date(rowA.getValue("createdOn")); + const dateB = new Date(rowB.getValue("createdOn")); + return dateA.getTime() - dateB.getTime(); + }, + }); + + const actions = columnHelper.display({ + header: "Actions", + cell: (value) => ( +
+ + Details + +
+ ), + }); + + let columns = []; + + columns.push(id); + columns.push(status); + if (orderType === "adminorders") { + columns.push(sponsorName); + } + columns.push(name); + columns.push(units); + columns.push(quantity); + columns.push(total); + columns.push(balanceRemaining); + columns.push(createdOn); + columns.push(actions); + + if (orders === undefined) { + return ( +
+
Loading...
+
+ ); + } else { + return ( +
+
+
+ +
+
+
+ ); + } +}; diff --git a/Hippo.Web/ClientApp/src/components/Order/UpdateChartStrings.tsx b/Hippo.Web/ClientApp/src/components/Order/UpdateChartStrings.tsx new file mode 100644 index 00000000..47d8a3fa --- /dev/null +++ b/Hippo.Web/ClientApp/src/components/Order/UpdateChartStrings.tsx @@ -0,0 +1,128 @@ +import React, { useEffect, useState } from "react"; +import { OrderModel } from "../../types"; +import { useNavigate, useParams } from "react-router-dom"; +import { usePermissions } from "../../Shared/usePermissions"; +import { usePromiseNotification } from "../../util/Notifications"; +import OrderForm from "./OrderForm"; +import { authenticatedFetch, parseBadRequest } from "../../util/api"; + +export const UpdateChartStrings: React.FC = () => { + const { cluster, orderId } = useParams(); + const { isClusterAdminForCluster } = usePermissions(); + const [order, setOrder] = useState(null); + const [isClusterAdmin, setIsClusterAdmin] = useState(null); + const [notification, setNotification] = usePromiseNotification(); + const navigate = useNavigate(); + + useEffect(() => { + setIsClusterAdmin(isClusterAdminForCluster()); + }, [isClusterAdmin, isClusterAdminForCluster]); + + useEffect(() => { + const fetchOrder = async () => { + const response = await authenticatedFetch( + `/api/${cluster}/order/get/${orderId}`, + ); + + if (response.ok) { + const data = await response.json(); + setOrder(data); + } else { + alert("Error fetching order"); + } + }; + + fetchOrder(); + }, [cluster, orderId]); + + // async function so the form can manage the loading state + const submitOrder = async (updatedOrder: OrderModel) => { + const editedOrder: OrderModel = { + // uneditable fields + id: updatedOrder.id, + status: updatedOrder.status, + createdOn: updatedOrder.createdOn, + total: updatedOrder.total, + subTotal: updatedOrder.subTotal, + balanceRemaining: updatedOrder.balanceRemaining, + payments: updatedOrder.payments, + history: updatedOrder.history, + piUser: null, + percentTotal: updatedOrder.percentTotal, + nextPaymentDate: updatedOrder.nextPaymentDate, + + // editable fields + PILookup: updatedOrder.PILookup, + name: updatedOrder.name, + productName: updatedOrder.productName, + description: updatedOrder.description, + category: updatedOrder.category, + externalReference: updatedOrder.externalReference, + notes: updatedOrder.notes, + units: updatedOrder.units, + unitPrice: updatedOrder.unitPrice, + quantity: updatedOrder.quantity, + installments: updatedOrder.installments, + installmentType: updatedOrder.installmentType, + adjustment: updatedOrder.adjustment, + adjustmentReason: updatedOrder.adjustmentReason, + adminNotes: updatedOrder.adminNotes, + metaData: updatedOrder.metaData, + lifeCycle: updatedOrder.lifeCycle, + expirationDate: updatedOrder.expirationDate, + installmentDate: updatedOrder.installmentDate, + billings: updatedOrder.billings, + }; + + const req = authenticatedFetch(`/api/${cluster}/order/UpdateBilling`, { + method: "POST", + body: JSON.stringify(editedOrder), + }); + + setNotification(req, "Saving", "Order Saved", async (r) => { + if (r.status === 400) { + const errors = await parseBadRequest(response); + return errors; + } else { + return "An error happened, please try again."; + } + }); + + const response = await req; + + if (response.ok) { + const data = await response.json(); + navigate(`/${cluster}/order/details/${data.id}`); + } + + setOrder(editedOrder); // should be newOrder once it's pulling from the API + }; + + if (isClusterAdmin === null) { + return
Loading...
; + } + + if (!order) { + return
Loading... {orderId}
; + } + + return ( +
+ {order && ( +
+

Update Chart Strings

+ + + {notification.pending &&
Saving...
} +
+ )} +
+ ); +}; diff --git a/Hippo.Web/ClientApp/src/components/Product/Products.tsx b/Hippo.Web/ClientApp/src/components/Product/Products.tsx new file mode 100644 index 00000000..42596f15 --- /dev/null +++ b/Hippo.Web/ClientApp/src/components/Product/Products.tsx @@ -0,0 +1,461 @@ +import { useEffect, useState, useMemo, useCallback } from "react"; +import { Link, useParams } from "react-router-dom"; + +import { ReactTable } from "../../Shared/ReactTable"; +import { createColumnHelper } from "@tanstack/react-table"; +import { ProductModel } from "../../types"; +import { authenticatedFetch, parseBadRequest } from "../../util/api"; +import { ShowFor } from "../../Shared/ShowFor"; +import { usePromiseNotification } from "../../util/Notifications"; +import { useConfirmationDialog } from "../../Shared/ConfirmationDialog"; +import { notEmptyOrFalsey } from "../../util/ValueChecks"; + +const defaultProduct: ProductModel = { + id: 0, + name: "", + category: "Memory", + description: "", + unitPrice: "0.00", + units: "", + installments: 1, + installmentType: "OneTime", + lifeCycle: 60, +}; + +export const Products = () => { + const [notification, setNotification] = usePromiseNotification(); + const [editProductModel, setEditProductModel] = useState({ + ...defaultProduct, + }); + const [editConfirmationTitle, setEditConfirmationTitle] = useState(""); + const [deleteConfirmationTitle, setDeleteConfirmationTitle] = + useState("Delete Product"); + const [products, setProducts] = useState(); + const { cluster } = useParams(); + + useEffect(() => { + const fetchProducts = async () => { + const response = await authenticatedFetch( + `/api/${cluster}/product/index`, + ); + + if (response.ok) { + const data = await response.json(); + setProducts(data); + } else { + alert("Error fetching products"); + } + }; + + fetchProducts(); + }, [cluster]); + + const [getEditConfirmation] = useConfirmationDialog( + { + title: editConfirmationTitle, + message: (setReturn) => ( + <> +
+ + { + const model: ProductModel = { + ...editProductModel, + name: e.target.value, + }; + setEditProductModel(model); + setReturn(model); + }} + /> +
+
+ +