diff --git a/src/Domain/Data/OAuthToken.cs b/src/Domain/Data/OAuthToken.cs index 12a43ad..a6b5911 100644 --- a/src/Domain/Data/OAuthToken.cs +++ b/src/Domain/Data/OAuthToken.cs @@ -19,14 +19,18 @@ public class Configuration : IEntityTypeConfiguration { public void Configure(EntityTypeBuilder builder) { + builder.IsMultiTenant(); + builder.HasKey(k => k.OAuthTokenId); builder.Property(e => e.OAuthProvider).IsRequired(); builder.Property(e => e.AccessToken).IsRequired(); builder.Property(e => e.TokenType).IsRequired(); builder.Property(e => e.UserId).IsRequired(); - builder.HasIndex(e => new { e.OAuthProvider, e.UserId }).IsUnique().HasDatabaseName("AK_OAuthProvider_UserId"); + builder.HasIndex(["OAuthProvider", "UserId", "TenantId"]) + .IsUnique() + .HasDatabaseName("AK_OAuthProvider_UserId"); - builder.ToTable("OAuthToken").IsMultiTenant(); + builder.ToTable("OAuthToken"); } } } diff --git a/src/Domain/Data/ProductImage.cs b/src/Domain/Data/ProductImage.cs index 76938df..7b5a9f9 100644 --- a/src/Domain/Data/ProductImage.cs +++ b/src/Domain/Data/ProductImage.cs @@ -32,9 +32,11 @@ public override void Configure(EntityTypeBuilder builder) { base.Configure(builder); + builder.IsMultiTenant(); + builder.HasKey(k => k.ProductImageId); builder.Property(e => e.StorageId).IsRequired(); - builder.HasIndex(e => e.StorageId).IsUnique().HasDatabaseName("AK_ProductImage_StorageId"); + builder.HasIndex(["StorageId", "TenantId"]).IsUnique().HasDatabaseName("AK_ProductImage_StorageId"); builder.Property(e => e.FileName).IsRequired(); builder.HasOne(b => b.Product) @@ -42,7 +44,7 @@ public override void Configure(EntityTypeBuilder builder) .HasForeignKey(b => b.ProductId) .OnDelete(DeleteBehavior.Cascade); - builder.ToTable("ProductImage").IsMultiTenant(); + builder.ToTable("ProductImage"); } } } diff --git a/src/Migrations/20240825185734_InitialCreate.Designer.cs b/src/Migrations/20240825185734_InitialCreate.Designer.cs new file mode 100644 index 0000000..15726ad --- /dev/null +++ b/src/Migrations/20240825185734_InitialCreate.Designer.cs @@ -0,0 +1,914 @@ +// +using System; +using Elysian.Infrastructure.Context; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Elysian.Migrations +{ + [DbContext(typeof(ElysianContext))] + [Migration("20240825185734_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Elysian.Domain.Data.BillTracking", b => + { + b.Property("BillTrackingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BillTrackingId")); + + b.Property("BillNumber") + .HasColumnType("int"); + + b.Property("BillType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Congress") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("BillTrackingId"); + + b.ToTable("BillTracking", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Budget", b => + { + b.Property("BudgetId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BudgetId")); + + b.Property("EndDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("BudgetId"); + + b.ToTable("Budget", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetAccessItem", b => + { + b.Property("BudgetAccessItemId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BudgetAccessItemId")); + + b.Property("BudgetId") + .HasColumnType("int"); + + b.Property("InstitutionAccessItemId") + .HasColumnType("int"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("BudgetAccessItemId"); + + b.HasIndex("BudgetId"); + + b.HasIndex("InstitutionAccessItemId"); + + b.ToTable("BudgetAccessItem", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetCategory", b => + { + b.Property("BudgetCategoryId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BudgetCategoryId")); + + b.Property("BudgetId") + .HasColumnType("int"); + + b.Property("Estimate") + .HasColumnType("decimal(18,2)"); + + b.Property("FinancialCategoryId") + .HasColumnType("int"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("BudgetCategoryId"); + + b.HasIndex("BudgetId"); + + b.HasIndex("FinancialCategoryId"); + + b.ToTable("BudgetCategory", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetExcludedTransaction", b => + { + b.Property("BudgetExcludedTransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BudgetExcludedTransactionId")); + + b.Property("BudgetId") + .HasColumnType("int"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TransactionId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("BudgetExcludedTransactionId"); + + b.HasIndex("BudgetId"); + + b.ToTable("BudgetExcludedTransaction", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.FinancialCategory", b => + { + b.Property("FinancialCategoryId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FinancialCategoryId")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("FinancialCategoryId"); + + b.ToTable("FinancialCategory", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.InstitutionAccessItem", b => + { + b.Property("InstitutionAccessItemId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("InstitutionAccessItemId")); + + b.Property("AccessToken") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("InstitutionId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("ItemId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("InstitutionAccessItemId"); + + b.HasIndex("InstitutionId", "UserId") + .IsUnique() + .HasDatabaseName("AK_InstitutionAccessItem_InstitutionId_UserId"); + + b.ToTable("InstitutionAccessItem", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Merchant", b => + { + b.Property("MerchantId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsBillable") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MerchantIdentifier") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("MerchantTypeId") + .HasColumnType("int"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SelfBoardingApplication") + .HasColumnType("bit"); + + b.Property("WebsiteUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId"); + + b.HasIndex("MerchantIdentifier") + .IsUnique() + .HasDatabaseName("AK_Merchant_MerchantIdentifier"); + + b.HasIndex("MerchantTypeId"); + + b.ToTable("Merchant", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.MerchantType", b => + { + b.Property("MerchantTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantTypeId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("MerchantTypeId"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("AK_MerchantType_Name"); + + b.ToTable("MerchantType", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.OAuthState", b => + { + b.Property("OAuthStateId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OAuthStateId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("OAuthProvider") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("State") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OAuthStateId"); + + b.ToTable("OAuthState", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.OAuthToken", b => + { + b.Property("OAuthTokenId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OAuthTokenId")); + + b.Property("AccessToken") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("OAuthProvider") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Scope") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TokenType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("OAuthTokenId"); + + b.HasIndex("OAuthProvider", "UserId") + .IsUnique() + .HasDatabaseName("AK_OAuthProvider_UserId"); + + b.ToTable("OAuthToken", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.PriceType", b => + { + b.Property("PriceTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("PriceTypeId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsVariableCost") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("PriceTypeId"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("AK_PriceType_Name"); + + b.ToTable("PriceType", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Product", b => + { + b.Property("ProductId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ProductId")); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Cost") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DefaultTaxRates") + .HasColumnType("bit"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Grade") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsRevenue") + .HasColumnType("bit"); + + b.Property("LookupCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MerchantId") + .HasColumnType("int"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Price") + .HasColumnType("decimal(18,2)"); + + b.Property("PriceTypeId") + .HasColumnType("int"); + + b.Property("ProductTypeId") + .HasColumnType("int"); + + b.Property("SerialNumber") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Sku") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UnitTypeId") + .HasColumnType("int"); + + b.HasKey("ProductId"); + + b.HasIndex("MerchantId"); + + b.HasIndex("PriceTypeId"); + + b.HasIndex("ProductTypeId"); + + b.HasIndex("SerialNumber") + .IsUnique() + .HasDatabaseName("AK_Product_SerialNumber") + .HasFilter("[IsDeleted] = 0"); + + b.HasIndex("UnitTypeId"); + + b.ToTable("Product", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.ProductImage", b => + { + b.Property("ProductImageId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ProductImageId")); + + b.Property("AltText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileSize") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsStorageDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("StorageId") + .HasColumnType("uniqueidentifier"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("ProductImageId"); + + b.HasIndex("ProductId"); + + b.HasIndex("StorageId") + .IsUnique() + .HasDatabaseName("AK_ProductImage_StorageId"); + + b.ToTable("ProductImage", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.ProductType", b => + { + b.Property("ProductTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ProductTypeId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("ProductTypeId"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("AK_ProductType_Name"); + + b.ToTable("ProductType", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.TransactionCategory", b => + { + b.Property("TransactionCategoryId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionCategoryId")); + + b.Property("BudgetId") + .HasColumnType("int"); + + b.Property("FinancialCategoryId") + .HasColumnType("int"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TransactionId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("TransactionCategoryId"); + + b.HasIndex("BudgetId"); + + b.HasIndex("FinancialCategoryId"); + + b.ToTable("TransactionCategory", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.UnitType", b => + { + b.Property("UnitTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("UnitTypeId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("PerUnit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UnitTypeId"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("AK_UnitType_Name"); + + b.ToTable("UnitType", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetAccessItem", b => + { + b.HasOne("Elysian.Domain.Data.Budget", "Budget") + .WithMany() + .HasForeignKey("BudgetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.InstitutionAccessItem", "InstitutionAccessItem") + .WithMany() + .HasForeignKey("InstitutionAccessItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Budget"); + + b.Navigation("InstitutionAccessItem"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetCategory", b => + { + b.HasOne("Elysian.Domain.Data.Budget", "Budget") + .WithMany() + .HasForeignKey("BudgetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.FinancialCategory", "FinancialCategory") + .WithMany() + .HasForeignKey("FinancialCategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Budget"); + + b.Navigation("FinancialCategory"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetExcludedTransaction", b => + { + b.HasOne("Elysian.Domain.Data.Budget", "Budget") + .WithMany() + .HasForeignKey("BudgetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Budget"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Merchant", b => + { + b.HasOne("Elysian.Domain.Data.MerchantType", "MerchantType") + .WithMany() + .HasForeignKey("MerchantTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MerchantType"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Product", b => + { + b.HasOne("Elysian.Domain.Data.Merchant", "Merchant") + .WithMany() + .HasForeignKey("MerchantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.PriceType", "PriceType") + .WithMany() + .HasForeignKey("PriceTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.ProductType", "ProductType") + .WithMany() + .HasForeignKey("ProductTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.UnitType", "UnitType") + .WithMany() + .HasForeignKey("UnitTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Merchant"); + + b.Navigation("PriceType"); + + b.Navigation("ProductType"); + + b.Navigation("UnitType"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.ProductImage", b => + { + b.HasOne("Elysian.Domain.Data.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.TransactionCategory", b => + { + b.HasOne("Elysian.Domain.Data.Budget", "Budget") + .WithMany() + .HasForeignKey("BudgetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.FinancialCategory", "FinancialCategory") + .WithMany() + .HasForeignKey("FinancialCategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Budget"); + + b.Navigation("FinancialCategory"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Migrations/20240825185734_InitialCreate.cs b/src/Migrations/20240825185734_InitialCreate.cs new file mode 100644 index 0000000..710f635 --- /dev/null +++ b/src/Migrations/20240825185734_InitialCreate.cs @@ -0,0 +1,596 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Elysian.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "BillTracking", + columns: table => new + { + BillTrackingId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "nvarchar(max)", nullable: false), + Congress = table.Column(type: "int", nullable: false), + BillType = table.Column(type: "nvarchar(max)", nullable: false), + BillNumber = table.Column(type: "int", nullable: false), + CreatedByUserId = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + ModifiedByUserId = table.Column(type: "nvarchar(max)", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + TenantId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_BillTracking", x => x.BillTrackingId); + }); + + migrationBuilder.CreateTable( + name: "Budget", + columns: table => new + { + BudgetId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false), + StartDate = table.Column(type: "datetime2", nullable: false), + EndDate = table.Column(type: "datetime2", nullable: false), + UserId = table.Column(type: "nvarchar(max)", nullable: false), + TenantId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Budget", x => x.BudgetId); + }); + + migrationBuilder.CreateTable( + name: "FinancialCategory", + columns: table => new + { + FinancialCategoryId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_FinancialCategory", x => x.FinancialCategoryId); + }); + + migrationBuilder.CreateTable( + name: "InstitutionAccessItem", + columns: table => new + { + InstitutionAccessItemId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserId = table.Column(type: "nvarchar(450)", nullable: false), + AccessToken = table.Column(type: "nvarchar(max)", nullable: false), + ItemId = table.Column(type: "nvarchar(max)", nullable: false), + InstitutionId = table.Column(type: "nvarchar(450)", nullable: false), + TenantId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_InstitutionAccessItem", x => x.InstitutionAccessItemId); + }); + + migrationBuilder.CreateTable( + name: "MerchantType", + columns: table => new + { + MerchantTypeId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(450)", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + CreatedByUserId = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + ModifiedByUserId = table.Column(type: "nvarchar(max)", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MerchantType", x => x.MerchantTypeId); + }); + + migrationBuilder.CreateTable( + name: "OAuthState", + columns: table => new + { + OAuthStateId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + OAuthProvider = table.Column(type: "nvarchar(max)", nullable: false), + UserId = table.Column(type: "nvarchar(max)", nullable: false), + State = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + TenantId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_OAuthState", x => x.OAuthStateId); + }); + + migrationBuilder.CreateTable( + name: "OAuthToken", + columns: table => new + { + OAuthTokenId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + OAuthProvider = table.Column(type: "nvarchar(450)", nullable: false), + AccessToken = table.Column(type: "nvarchar(max)", nullable: false), + TokenType = table.Column(type: "nvarchar(max)", nullable: false), + Scope = table.Column(type: "nvarchar(max)", nullable: false), + UserId = table.Column(type: "nvarchar(450)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + ExpiresAt = table.Column(type: "datetime2", nullable: true), + TenantId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_OAuthToken", x => x.OAuthTokenId); + }); + + migrationBuilder.CreateTable( + name: "PriceType", + columns: table => new + { + PriceTypeId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(450)", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + IsVariableCost = table.Column(type: "bit", nullable: false), + CreatedByUserId = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + ModifiedByUserId = table.Column(type: "nvarchar(max)", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_PriceType", x => x.PriceTypeId); + }); + + migrationBuilder.CreateTable( + name: "ProductType", + columns: table => new + { + ProductTypeId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(450)", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + CreatedByUserId = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + ModifiedByUserId = table.Column(type: "nvarchar(max)", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProductType", x => x.ProductTypeId); + }); + + migrationBuilder.CreateTable( + name: "UnitType", + columns: table => new + { + UnitTypeId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(450)", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + PerUnit = table.Column(type: "nvarchar(max)", nullable: false), + CreatedByUserId = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + ModifiedByUserId = table.Column(type: "nvarchar(max)", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_UnitType", x => x.UnitTypeId); + }); + + migrationBuilder.CreateTable( + name: "BudgetExcludedTransaction", + columns: table => new + { + BudgetExcludedTransactionId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + TransactionId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + BudgetId = table.Column(type: "int", nullable: false), + TenantId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_BudgetExcludedTransaction", x => x.BudgetExcludedTransactionId); + table.ForeignKey( + name: "FK_BudgetExcludedTransaction_Budget_BudgetId", + column: x => x.BudgetId, + principalTable: "Budget", + principalColumn: "BudgetId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "BudgetCategory", + columns: table => new + { + BudgetCategoryId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Estimate = table.Column(type: "decimal(18,2)", nullable: false), + BudgetId = table.Column(type: "int", nullable: false), + FinancialCategoryId = table.Column(type: "int", nullable: false), + TenantId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_BudgetCategory", x => x.BudgetCategoryId); + table.ForeignKey( + name: "FK_BudgetCategory_Budget_BudgetId", + column: x => x.BudgetId, + principalTable: "Budget", + principalColumn: "BudgetId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_BudgetCategory_FinancialCategory_FinancialCategoryId", + column: x => x.FinancialCategoryId, + principalTable: "FinancialCategory", + principalColumn: "FinancialCategoryId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "TransactionCategory", + columns: table => new + { + TransactionCategoryId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + TransactionId = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + FinancialCategoryId = table.Column(type: "int", nullable: false), + BudgetId = table.Column(type: "int", nullable: false), + TenantId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_TransactionCategory", x => x.TransactionCategoryId); + table.ForeignKey( + name: "FK_TransactionCategory_Budget_BudgetId", + column: x => x.BudgetId, + principalTable: "Budget", + principalColumn: "BudgetId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_TransactionCategory_FinancialCategory_FinancialCategoryId", + column: x => x.FinancialCategoryId, + principalTable: "FinancialCategory", + principalColumn: "FinancialCategoryId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "BudgetAccessItem", + columns: table => new + { + BudgetAccessItemId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + BudgetId = table.Column(type: "int", nullable: false), + InstitutionAccessItemId = table.Column(type: "int", nullable: false), + TenantId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_BudgetAccessItem", x => x.BudgetAccessItemId); + table.ForeignKey( + name: "FK_BudgetAccessItem_Budget_BudgetId", + column: x => x.BudgetId, + principalTable: "Budget", + principalColumn: "BudgetId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_BudgetAccessItem_InstitutionAccessItem_InstitutionAccessItemId", + column: x => x.InstitutionAccessItemId, + principalTable: "InstitutionAccessItem", + principalColumn: "InstitutionAccessItemId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Merchant", + columns: table => new + { + MerchantId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + MerchantIdentifier = table.Column(type: "nvarchar(450)", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + WebsiteUrl = table.Column(type: "nvarchar(max)", nullable: false), + SelfBoardingApplication = table.Column(type: "bit", nullable: false), + IsBillable = table.Column(type: "bit", nullable: false), + CreatedByUserId = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + ModifiedByUserId = table.Column(type: "nvarchar(max)", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + MerchantTypeId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Merchant", x => x.MerchantId); + table.ForeignKey( + name: "FK_Merchant_MerchantType_MerchantTypeId", + column: x => x.MerchantTypeId, + principalTable: "MerchantType", + principalColumn: "MerchantTypeId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Product", + columns: table => new + { + ProductId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + SerialNumber = table.Column(type: "nvarchar(450)", nullable: false), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: false), + Grade = table.Column(type: "nvarchar(max)", nullable: false), + Cost = table.Column(type: "decimal(18,2)", nullable: true), + Price = table.Column(type: "decimal(18,2)", nullable: true), + IsRevenue = table.Column(type: "bit", nullable: false), + Code = table.Column(type: "nvarchar(max)", nullable: false), + Sku = table.Column(type: "nvarchar(max)", nullable: false), + DefaultTaxRates = table.Column(type: "bit", nullable: false), + LookupCode = table.Column(type: "nvarchar(max)", nullable: false), + Percentage = table.Column(type: "decimal(18,2)", nullable: true), + CreatedByUserId = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + ModifiedByUserId = table.Column(type: "nvarchar(max)", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + MerchantId = table.Column(type: "int", nullable: false), + ProductTypeId = table.Column(type: "int", nullable: false), + PriceTypeId = table.Column(type: "int", nullable: false), + UnitTypeId = table.Column(type: "int", nullable: false), + TenantId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Product", x => x.ProductId); + table.ForeignKey( + name: "FK_Product_Merchant_MerchantId", + column: x => x.MerchantId, + principalTable: "Merchant", + principalColumn: "MerchantId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Product_PriceType_PriceTypeId", + column: x => x.PriceTypeId, + principalTable: "PriceType", + principalColumn: "PriceTypeId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Product_ProductType_ProductTypeId", + column: x => x.ProductTypeId, + principalTable: "ProductType", + principalColumn: "ProductTypeId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Product_UnitType_UnitTypeId", + column: x => x.UnitTypeId, + principalTable: "UnitType", + principalColumn: "UnitTypeId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ProductImage", + columns: table => new + { + ProductImageId = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + StorageId = table.Column(type: "uniqueidentifier", nullable: false), + FileName = table.Column(type: "nvarchar(max)", nullable: false), + AltText = table.Column(type: "nvarchar(max)", nullable: false), + FileSize = table.Column(type: "bigint", nullable: false), + IsStorageDeleted = table.Column(type: "bit", nullable: false), + CreatedByUserId = table.Column(type: "nvarchar(max)", nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false), + ModifiedByUserId = table.Column(type: "nvarchar(max)", nullable: false), + ModifiedAt = table.Column(type: "datetime2", nullable: false), + IsDeleted = table.Column(type: "bit", nullable: false), + ProductId = table.Column(type: "int", nullable: false), + TenantId = table.Column(type: "nvarchar(64)", maxLength: 64, nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ProductImage", x => x.ProductImageId); + table.ForeignKey( + name: "FK_ProductImage_Product_ProductId", + column: x => x.ProductId, + principalTable: "Product", + principalColumn: "ProductId", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_BudgetAccessItem_BudgetId", + table: "BudgetAccessItem", + column: "BudgetId"); + + migrationBuilder.CreateIndex( + name: "IX_BudgetAccessItem_InstitutionAccessItemId", + table: "BudgetAccessItem", + column: "InstitutionAccessItemId"); + + migrationBuilder.CreateIndex( + name: "IX_BudgetCategory_BudgetId", + table: "BudgetCategory", + column: "BudgetId"); + + migrationBuilder.CreateIndex( + name: "IX_BudgetCategory_FinancialCategoryId", + table: "BudgetCategory", + column: "FinancialCategoryId"); + + migrationBuilder.CreateIndex( + name: "IX_BudgetExcludedTransaction_BudgetId", + table: "BudgetExcludedTransaction", + column: "BudgetId"); + + migrationBuilder.CreateIndex( + name: "AK_InstitutionAccessItem_InstitutionId_UserId", + table: "InstitutionAccessItem", + columns: new[] { "InstitutionId", "UserId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "AK_Merchant_MerchantIdentifier", + table: "Merchant", + column: "MerchantIdentifier", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Merchant_MerchantTypeId", + table: "Merchant", + column: "MerchantTypeId"); + + migrationBuilder.CreateIndex( + name: "AK_MerchantType_Name", + table: "MerchantType", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "AK_OAuthProvider_UserId", + table: "OAuthToken", + columns: new[] { "OAuthProvider", "UserId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "AK_PriceType_Name", + table: "PriceType", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "AK_Product_SerialNumber", + table: "Product", + column: "SerialNumber", + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "IX_Product_MerchantId", + table: "Product", + column: "MerchantId"); + + migrationBuilder.CreateIndex( + name: "IX_Product_PriceTypeId", + table: "Product", + column: "PriceTypeId"); + + migrationBuilder.CreateIndex( + name: "IX_Product_ProductTypeId", + table: "Product", + column: "ProductTypeId"); + + migrationBuilder.CreateIndex( + name: "IX_Product_UnitTypeId", + table: "Product", + column: "UnitTypeId"); + + migrationBuilder.CreateIndex( + name: "AK_ProductImage_StorageId", + table: "ProductImage", + column: "StorageId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_ProductImage_ProductId", + table: "ProductImage", + column: "ProductId"); + + migrationBuilder.CreateIndex( + name: "AK_ProductType_Name", + table: "ProductType", + column: "Name", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_TransactionCategory_BudgetId", + table: "TransactionCategory", + column: "BudgetId"); + + migrationBuilder.CreateIndex( + name: "IX_TransactionCategory_FinancialCategoryId", + table: "TransactionCategory", + column: "FinancialCategoryId"); + + migrationBuilder.CreateIndex( + name: "AK_UnitType_Name", + table: "UnitType", + column: "Name", + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "BillTracking"); + + migrationBuilder.DropTable( + name: "BudgetAccessItem"); + + migrationBuilder.DropTable( + name: "BudgetCategory"); + + migrationBuilder.DropTable( + name: "BudgetExcludedTransaction"); + + migrationBuilder.DropTable( + name: "OAuthState"); + + migrationBuilder.DropTable( + name: "OAuthToken"); + + migrationBuilder.DropTable( + name: "ProductImage"); + + migrationBuilder.DropTable( + name: "TransactionCategory"); + + migrationBuilder.DropTable( + name: "InstitutionAccessItem"); + + migrationBuilder.DropTable( + name: "Product"); + + migrationBuilder.DropTable( + name: "Budget"); + + migrationBuilder.DropTable( + name: "FinancialCategory"); + + migrationBuilder.DropTable( + name: "Merchant"); + + migrationBuilder.DropTable( + name: "PriceType"); + + migrationBuilder.DropTable( + name: "ProductType"); + + migrationBuilder.DropTable( + name: "UnitType"); + + migrationBuilder.DropTable( + name: "MerchantType"); + } + } +} diff --git a/src/Migrations/20240825185759_InitialTypes.Designer.cs b/src/Migrations/20240825185759_InitialTypes.Designer.cs new file mode 100644 index 0000000..4decec2 --- /dev/null +++ b/src/Migrations/20240825185759_InitialTypes.Designer.cs @@ -0,0 +1,914 @@ +// +using System; +using Elysian.Infrastructure.Context; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Elysian.Migrations +{ + [DbContext(typeof(ElysianContext))] + [Migration("20240825185759_InitialTypes")] + partial class InitialTypes + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Elysian.Domain.Data.BillTracking", b => + { + b.Property("BillTrackingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BillTrackingId")); + + b.Property("BillNumber") + .HasColumnType("int"); + + b.Property("BillType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Congress") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("BillTrackingId"); + + b.ToTable("BillTracking", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Budget", b => + { + b.Property("BudgetId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BudgetId")); + + b.Property("EndDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("BudgetId"); + + b.ToTable("Budget", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetAccessItem", b => + { + b.Property("BudgetAccessItemId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BudgetAccessItemId")); + + b.Property("BudgetId") + .HasColumnType("int"); + + b.Property("InstitutionAccessItemId") + .HasColumnType("int"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("BudgetAccessItemId"); + + b.HasIndex("BudgetId"); + + b.HasIndex("InstitutionAccessItemId"); + + b.ToTable("BudgetAccessItem", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetCategory", b => + { + b.Property("BudgetCategoryId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BudgetCategoryId")); + + b.Property("BudgetId") + .HasColumnType("int"); + + b.Property("Estimate") + .HasColumnType("decimal(18,2)"); + + b.Property("FinancialCategoryId") + .HasColumnType("int"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("BudgetCategoryId"); + + b.HasIndex("BudgetId"); + + b.HasIndex("FinancialCategoryId"); + + b.ToTable("BudgetCategory", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetExcludedTransaction", b => + { + b.Property("BudgetExcludedTransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BudgetExcludedTransactionId")); + + b.Property("BudgetId") + .HasColumnType("int"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TransactionId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("BudgetExcludedTransactionId"); + + b.HasIndex("BudgetId"); + + b.ToTable("BudgetExcludedTransaction", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.FinancialCategory", b => + { + b.Property("FinancialCategoryId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FinancialCategoryId")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("FinancialCategoryId"); + + b.ToTable("FinancialCategory", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.InstitutionAccessItem", b => + { + b.Property("InstitutionAccessItemId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("InstitutionAccessItemId")); + + b.Property("AccessToken") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("InstitutionId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("ItemId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("InstitutionAccessItemId"); + + b.HasIndex("InstitutionId", "UserId") + .IsUnique() + .HasDatabaseName("AK_InstitutionAccessItem_InstitutionId_UserId"); + + b.ToTable("InstitutionAccessItem", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Merchant", b => + { + b.Property("MerchantId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsBillable") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MerchantIdentifier") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("MerchantTypeId") + .HasColumnType("int"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SelfBoardingApplication") + .HasColumnType("bit"); + + b.Property("WebsiteUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId"); + + b.HasIndex("MerchantIdentifier") + .IsUnique() + .HasDatabaseName("AK_Merchant_MerchantIdentifier"); + + b.HasIndex("MerchantTypeId"); + + b.ToTable("Merchant", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.MerchantType", b => + { + b.Property("MerchantTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantTypeId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("MerchantTypeId"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("AK_MerchantType_Name"); + + b.ToTable("MerchantType", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.OAuthState", b => + { + b.Property("OAuthStateId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OAuthStateId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("OAuthProvider") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("State") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OAuthStateId"); + + b.ToTable("OAuthState", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.OAuthToken", b => + { + b.Property("OAuthTokenId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OAuthTokenId")); + + b.Property("AccessToken") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("OAuthProvider") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Scope") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TokenType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("OAuthTokenId"); + + b.HasIndex("OAuthProvider", "UserId") + .IsUnique() + .HasDatabaseName("AK_OAuthProvider_UserId"); + + b.ToTable("OAuthToken", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.PriceType", b => + { + b.Property("PriceTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("PriceTypeId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsVariableCost") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("PriceTypeId"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("AK_PriceType_Name"); + + b.ToTable("PriceType", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Product", b => + { + b.Property("ProductId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ProductId")); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Cost") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DefaultTaxRates") + .HasColumnType("bit"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Grade") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsRevenue") + .HasColumnType("bit"); + + b.Property("LookupCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MerchantId") + .HasColumnType("int"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Price") + .HasColumnType("decimal(18,2)"); + + b.Property("PriceTypeId") + .HasColumnType("int"); + + b.Property("ProductTypeId") + .HasColumnType("int"); + + b.Property("SerialNumber") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Sku") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UnitTypeId") + .HasColumnType("int"); + + b.HasKey("ProductId"); + + b.HasIndex("MerchantId"); + + b.HasIndex("PriceTypeId"); + + b.HasIndex("ProductTypeId"); + + b.HasIndex("SerialNumber") + .IsUnique() + .HasDatabaseName("AK_Product_SerialNumber") + .HasFilter("[IsDeleted] = 0"); + + b.HasIndex("UnitTypeId"); + + b.ToTable("Product", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.ProductImage", b => + { + b.Property("ProductImageId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ProductImageId")); + + b.Property("AltText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileSize") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsStorageDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("StorageId") + .HasColumnType("uniqueidentifier"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("ProductImageId"); + + b.HasIndex("ProductId"); + + b.HasIndex("StorageId") + .IsUnique() + .HasDatabaseName("AK_ProductImage_StorageId"); + + b.ToTable("ProductImage", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.ProductType", b => + { + b.Property("ProductTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ProductTypeId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("ProductTypeId"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("AK_ProductType_Name"); + + b.ToTable("ProductType", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.TransactionCategory", b => + { + b.Property("TransactionCategoryId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionCategoryId")); + + b.Property("BudgetId") + .HasColumnType("int"); + + b.Property("FinancialCategoryId") + .HasColumnType("int"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TransactionId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("TransactionCategoryId"); + + b.HasIndex("BudgetId"); + + b.HasIndex("FinancialCategoryId"); + + b.ToTable("TransactionCategory", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.UnitType", b => + { + b.Property("UnitTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("UnitTypeId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("PerUnit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UnitTypeId"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("AK_UnitType_Name"); + + b.ToTable("UnitType", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetAccessItem", b => + { + b.HasOne("Elysian.Domain.Data.Budget", "Budget") + .WithMany() + .HasForeignKey("BudgetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.InstitutionAccessItem", "InstitutionAccessItem") + .WithMany() + .HasForeignKey("InstitutionAccessItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Budget"); + + b.Navigation("InstitutionAccessItem"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetCategory", b => + { + b.HasOne("Elysian.Domain.Data.Budget", "Budget") + .WithMany() + .HasForeignKey("BudgetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.FinancialCategory", "FinancialCategory") + .WithMany() + .HasForeignKey("FinancialCategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Budget"); + + b.Navigation("FinancialCategory"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetExcludedTransaction", b => + { + b.HasOne("Elysian.Domain.Data.Budget", "Budget") + .WithMany() + .HasForeignKey("BudgetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Budget"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Merchant", b => + { + b.HasOne("Elysian.Domain.Data.MerchantType", "MerchantType") + .WithMany() + .HasForeignKey("MerchantTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MerchantType"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Product", b => + { + b.HasOne("Elysian.Domain.Data.Merchant", "Merchant") + .WithMany() + .HasForeignKey("MerchantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.PriceType", "PriceType") + .WithMany() + .HasForeignKey("PriceTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.ProductType", "ProductType") + .WithMany() + .HasForeignKey("ProductTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.UnitType", "UnitType") + .WithMany() + .HasForeignKey("UnitTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Merchant"); + + b.Navigation("PriceType"); + + b.Navigation("ProductType"); + + b.Navigation("UnitType"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.ProductImage", b => + { + b.HasOne("Elysian.Domain.Data.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.TransactionCategory", b => + { + b.HasOne("Elysian.Domain.Data.Budget", "Budget") + .WithMany() + .HasForeignKey("BudgetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.FinancialCategory", "FinancialCategory") + .WithMany() + .HasForeignKey("FinancialCategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Budget"); + + b.Navigation("FinancialCategory"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Migrations/20240825185759_InitialTypes.cs b/src/Migrations/20240825185759_InitialTypes.cs new file mode 100644 index 0000000..0eba7ae --- /dev/null +++ b/src/Migrations/20240825185759_InitialTypes.cs @@ -0,0 +1,239 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Elysian.Migrations +{ + /// + public partial class InitialTypes : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + // MerchantTypes + migrationBuilder.InsertData( + table: "MerchantType", + columns: new[] { "MerchantTypeId", "Name", "Description", "CreatedByUserId", "CreatedAt", "ModifiedByUserId", "ModifiedAt", "IsDeleted" }, + values: new object[] + { + 1, + "Portfolio", + "Online portfolio with extended features", + Guid.Empty.ToString(), + DateTime.UtcNow, + Guid.Empty.ToString(), + DateTime.UtcNow, + false + } + ); + + migrationBuilder.InsertData( + table: "MerchantType", + columns: new[] { "MerchantTypeId", "Name", "Description", "CreatedByUserId", "CreatedAt", "ModifiedByUserId", "ModifiedAt", "IsDeleted" }, + values: new object[] + { + 2, + "Store", + "Physical or online store", + Guid.Empty.ToString(), + DateTime.UtcNow, + Guid.Empty.ToString(), + DateTime.UtcNow, + false + } + ); + + // Merchants + migrationBuilder.InsertData( + table: "Merchant", + columns: new[] + { + "MerchantId", + "MerchantIdentifier", + "Name", + "Description", + "WebsiteUrl", + "SelfBoardingApplication", + "IsBillable", + "CreatedByUserId", + "CreatedAt", + "ModifiedByUserId", + "ModifiedAt", + "IsDeleted", + "MerchantTypeId" + }, + values: new object[] + { + 1, + "robsmitha", + "robsmitha.com", + "Merchant for robsmitha.com", + "https://robsmitha.com", + false, + false, + Guid.Empty.ToString(), + DateTime.UtcNow, + Guid.Empty.ToString(), + DateTime.UtcNow, + false, + 1 + } + ); + + migrationBuilder.InsertData( + table: "Merchant", + columns: new[] + { + "MerchantId", + "MerchantIdentifier", + "Name", + "Description", + "WebsiteUrl", + "SelfBoardingApplication", + "IsBillable", + "CreatedByUserId", + "CreatedAt", + "ModifiedByUserId", + "ModifiedAt", + "IsDeleted", + "MerchantTypeId" + }, + values: new object[] + { + 2, + "geekscloset", + "geekscloset.com", + "Merchant for geekscloset.com", + "https://geekscloset.com", + false, + false, + Guid.Empty.ToString(), + DateTime.UtcNow, + Guid.Empty.ToString(), + DateTime.UtcNow, + false, + 2 + } + ); + + // PriceType + migrationBuilder.InsertData( + table: "PriceType", + columns: new[] + { + "PriceTypeId", + "Name", + "Description", + "IsVariableCost", + "CreatedByUserId", + "CreatedAt", + "ModifiedByUserId", + "ModifiedAt", + "IsDeleted" + }, + values: new object[] + { + 1, + "Fixed", + "Fixed pricing", + false, + Guid.Empty.ToString(), + DateTime.UtcNow, + Guid.Empty.ToString(), + DateTime.UtcNow, + false + } + ); + + migrationBuilder.InsertData( + table: "PriceType", + columns: new[] + { + "PriceTypeId", + "Name", + "Description", + "IsVariableCost", + "CreatedByUserId", + "CreatedAt", + "ModifiedByUserId", + "ModifiedAt", + "IsDeleted" + }, + values: new object[] + { + 2, + "Variable", + "Variable cost pricing", + true, + Guid.Empty.ToString(), + DateTime.UtcNow, + Guid.Empty.ToString(), + DateTime.UtcNow, + false + } + ); + + // ProductType + migrationBuilder.InsertData( + table: "ProductType", + columns: new[] + { + "ProductTypeId", + "Name", + "Description", + "CreatedByUserId", + "CreatedAt", + "ModifiedByUserId", + "ModifiedAt", + "IsDeleted" + }, + values: new object[] + { + 1, + "Trackables", + "Products that are trackable and can be looked up through site functionality.", + Guid.Empty.ToString(), + DateTime.UtcNow, + Guid.Empty.ToString(), + DateTime.UtcNow, + false + } + ); + + // UnitType + migrationBuilder.InsertData( + table: "UnitType", + columns: new[] + { + "UnitTypeId", + "Name", + "Description", + "PerUnit", + "CreatedByUserId", + "CreatedAt", + "ModifiedByUserId", + "ModifiedAt", + "IsDeleted" + }, + values: new object[] + { + 1, + "Quantity", + "Unit is measured in quantities", + "Each", + Guid.Empty.ToString(), + DateTime.UtcNow, + Guid.Empty.ToString(), + DateTime.UtcNow, + false + } + ); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/src/Migrations/20240825200249_AddTenantStore.Designer.cs b/src/Migrations/20240825200249_AddTenantStore.Designer.cs new file mode 100644 index 0000000..54b4137 --- /dev/null +++ b/src/Migrations/20240825200249_AddTenantStore.Designer.cs @@ -0,0 +1,914 @@ +// +using System; +using Elysian.Infrastructure.Context; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Elysian.Migrations +{ + [DbContext(typeof(ElysianContext))] + [Migration("20240825200249_AddTenantStore")] + partial class AddTenantStore + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Elysian.Domain.Data.BillTracking", b => + { + b.Property("BillTrackingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BillTrackingId")); + + b.Property("BillNumber") + .HasColumnType("int"); + + b.Property("BillType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Congress") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("BillTrackingId"); + + b.ToTable("BillTracking", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Budget", b => + { + b.Property("BudgetId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BudgetId")); + + b.Property("EndDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("BudgetId"); + + b.ToTable("Budget", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetAccessItem", b => + { + b.Property("BudgetAccessItemId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BudgetAccessItemId")); + + b.Property("BudgetId") + .HasColumnType("int"); + + b.Property("InstitutionAccessItemId") + .HasColumnType("int"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("BudgetAccessItemId"); + + b.HasIndex("BudgetId"); + + b.HasIndex("InstitutionAccessItemId"); + + b.ToTable("BudgetAccessItem", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetCategory", b => + { + b.Property("BudgetCategoryId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BudgetCategoryId")); + + b.Property("BudgetId") + .HasColumnType("int"); + + b.Property("Estimate") + .HasColumnType("decimal(18,2)"); + + b.Property("FinancialCategoryId") + .HasColumnType("int"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("BudgetCategoryId"); + + b.HasIndex("BudgetId"); + + b.HasIndex("FinancialCategoryId"); + + b.ToTable("BudgetCategory", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetExcludedTransaction", b => + { + b.Property("BudgetExcludedTransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BudgetExcludedTransactionId")); + + b.Property("BudgetId") + .HasColumnType("int"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TransactionId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("BudgetExcludedTransactionId"); + + b.HasIndex("BudgetId"); + + b.ToTable("BudgetExcludedTransaction", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.FinancialCategory", b => + { + b.Property("FinancialCategoryId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FinancialCategoryId")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("FinancialCategoryId"); + + b.ToTable("FinancialCategory", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.InstitutionAccessItem", b => + { + b.Property("InstitutionAccessItemId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("InstitutionAccessItemId")); + + b.Property("AccessToken") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("InstitutionId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("ItemId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("InstitutionAccessItemId"); + + b.HasIndex("InstitutionId", "UserId") + .IsUnique() + .HasDatabaseName("AK_InstitutionAccessItem_InstitutionId_UserId"); + + b.ToTable("InstitutionAccessItem", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Merchant", b => + { + b.Property("MerchantId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsBillable") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MerchantIdentifier") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("MerchantTypeId") + .HasColumnType("int"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SelfBoardingApplication") + .HasColumnType("bit"); + + b.Property("WebsiteUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId"); + + b.HasIndex("MerchantIdentifier") + .IsUnique() + .HasDatabaseName("AK_Merchant_MerchantIdentifier"); + + b.HasIndex("MerchantTypeId"); + + b.ToTable("Merchant", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.MerchantType", b => + { + b.Property("MerchantTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantTypeId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("MerchantTypeId"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("AK_MerchantType_Name"); + + b.ToTable("MerchantType", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.OAuthState", b => + { + b.Property("OAuthStateId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OAuthStateId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("OAuthProvider") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("State") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OAuthStateId"); + + b.ToTable("OAuthState", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.OAuthToken", b => + { + b.Property("OAuthTokenId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OAuthTokenId")); + + b.Property("AccessToken") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("OAuthProvider") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Scope") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TokenType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("OAuthTokenId"); + + b.HasIndex("OAuthProvider", "UserId") + .IsUnique() + .HasDatabaseName("AK_OAuthProvider_UserId"); + + b.ToTable("OAuthToken", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.PriceType", b => + { + b.Property("PriceTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("PriceTypeId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsVariableCost") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("PriceTypeId"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("AK_PriceType_Name"); + + b.ToTable("PriceType", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Product", b => + { + b.Property("ProductId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ProductId")); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Cost") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DefaultTaxRates") + .HasColumnType("bit"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Grade") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsRevenue") + .HasColumnType("bit"); + + b.Property("LookupCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MerchantId") + .HasColumnType("int"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Price") + .HasColumnType("decimal(18,2)"); + + b.Property("PriceTypeId") + .HasColumnType("int"); + + b.Property("ProductTypeId") + .HasColumnType("int"); + + b.Property("SerialNumber") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Sku") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UnitTypeId") + .HasColumnType("int"); + + b.HasKey("ProductId"); + + b.HasIndex("MerchantId"); + + b.HasIndex("PriceTypeId"); + + b.HasIndex("ProductTypeId"); + + b.HasIndex("SerialNumber") + .IsUnique() + .HasDatabaseName("AK_Product_SerialNumber") + .HasFilter("[IsDeleted] = 0"); + + b.HasIndex("UnitTypeId"); + + b.ToTable("Product", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.ProductImage", b => + { + b.Property("ProductImageId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ProductImageId")); + + b.Property("AltText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileSize") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsStorageDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("StorageId") + .HasColumnType("uniqueidentifier"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("ProductImageId"); + + b.HasIndex("ProductId"); + + b.HasIndex("StorageId") + .IsUnique() + .HasDatabaseName("AK_ProductImage_StorageId"); + + b.ToTable("ProductImage", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.ProductType", b => + { + b.Property("ProductTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ProductTypeId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("ProductTypeId"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("AK_ProductType_Name"); + + b.ToTable("ProductType", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.TransactionCategory", b => + { + b.Property("TransactionCategoryId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionCategoryId")); + + b.Property("BudgetId") + .HasColumnType("int"); + + b.Property("FinancialCategoryId") + .HasColumnType("int"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TransactionId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("TransactionCategoryId"); + + b.HasIndex("BudgetId"); + + b.HasIndex("FinancialCategoryId"); + + b.ToTable("TransactionCategory", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.UnitType", b => + { + b.Property("UnitTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("UnitTypeId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("PerUnit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UnitTypeId"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("AK_UnitType_Name"); + + b.ToTable("UnitType", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetAccessItem", b => + { + b.HasOne("Elysian.Domain.Data.Budget", "Budget") + .WithMany() + .HasForeignKey("BudgetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.InstitutionAccessItem", "InstitutionAccessItem") + .WithMany() + .HasForeignKey("InstitutionAccessItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Budget"); + + b.Navigation("InstitutionAccessItem"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetCategory", b => + { + b.HasOne("Elysian.Domain.Data.Budget", "Budget") + .WithMany() + .HasForeignKey("BudgetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.FinancialCategory", "FinancialCategory") + .WithMany() + .HasForeignKey("FinancialCategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Budget"); + + b.Navigation("FinancialCategory"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetExcludedTransaction", b => + { + b.HasOne("Elysian.Domain.Data.Budget", "Budget") + .WithMany() + .HasForeignKey("BudgetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Budget"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Merchant", b => + { + b.HasOne("Elysian.Domain.Data.MerchantType", "MerchantType") + .WithMany() + .HasForeignKey("MerchantTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MerchantType"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Product", b => + { + b.HasOne("Elysian.Domain.Data.Merchant", "Merchant") + .WithMany() + .HasForeignKey("MerchantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.PriceType", "PriceType") + .WithMany() + .HasForeignKey("PriceTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.ProductType", "ProductType") + .WithMany() + .HasForeignKey("ProductTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.UnitType", "UnitType") + .WithMany() + .HasForeignKey("UnitTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Merchant"); + + b.Navigation("PriceType"); + + b.Navigation("ProductType"); + + b.Navigation("UnitType"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.ProductImage", b => + { + b.HasOne("Elysian.Domain.Data.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.TransactionCategory", b => + { + b.HasOne("Elysian.Domain.Data.Budget", "Budget") + .WithMany() + .HasForeignKey("BudgetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.FinancialCategory", "FinancialCategory") + .WithMany() + .HasForeignKey("FinancialCategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Budget"); + + b.Navigation("FinancialCategory"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Migrations/20240825200249_AddTenantStore.cs b/src/Migrations/20240825200249_AddTenantStore.cs new file mode 100644 index 0000000..1d096d4 --- /dev/null +++ b/src/Migrations/20240825200249_AddTenantStore.cs @@ -0,0 +1,48 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Elysian.Migrations +{ + /// + public partial class AddTenantStore : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql(@" +CREATE TABLE [TenantInfo] ( + [Id] nvarchar(64) NOT NULL, + [Identifier] nvarchar(450) NULL, + [Name] nvarchar(max) NULL, + [CmsUrl] nvarchar(max) NULL, + CONSTRAINT [PK_TenantInfo] PRIMARY KEY ([Id]) +); +EXEC(N'CREATE UNIQUE INDEX [IX_TenantInfo_Identifier] ON [TenantInfo] ([Identifier]) WHERE [Identifier] IS NOT NULL'); +"); + + migrationBuilder.Sql(@" +INSERT INTO [dbo].[TenantInfo] + ([Id] + ,[Identifier] + ,[Name] + ,[CmsUrl]) +VALUES + (convert(nvarchar(64), newid()) + ,'robsmitha' + ,'robsmitha', + NULL), + (convert(nvarchar(64), newid()) + ,'geekscloset' + ,'geekscloset', + NULL) +"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/src/Migrations/20240831180549_FixUniqueIndexes.Designer.cs b/src/Migrations/20240831180549_FixUniqueIndexes.Designer.cs new file mode 100644 index 0000000..d1d3224 --- /dev/null +++ b/src/Migrations/20240831180549_FixUniqueIndexes.Designer.cs @@ -0,0 +1,914 @@ +// +using System; +using Elysian.Infrastructure.Context; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Elysian.Migrations +{ + [DbContext(typeof(ElysianContext))] + [Migration("20240831180549_FixUniqueIndexes")] + partial class FixUniqueIndexes + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Elysian.Domain.Data.BillTracking", b => + { + b.Property("BillTrackingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BillTrackingId")); + + b.Property("BillNumber") + .HasColumnType("int"); + + b.Property("BillType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Congress") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("BillTrackingId"); + + b.ToTable("BillTracking", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Budget", b => + { + b.Property("BudgetId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BudgetId")); + + b.Property("EndDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("BudgetId"); + + b.ToTable("Budget", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetAccessItem", b => + { + b.Property("BudgetAccessItemId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BudgetAccessItemId")); + + b.Property("BudgetId") + .HasColumnType("int"); + + b.Property("InstitutionAccessItemId") + .HasColumnType("int"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("BudgetAccessItemId"); + + b.HasIndex("BudgetId"); + + b.HasIndex("InstitutionAccessItemId"); + + b.ToTable("BudgetAccessItem", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetCategory", b => + { + b.Property("BudgetCategoryId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BudgetCategoryId")); + + b.Property("BudgetId") + .HasColumnType("int"); + + b.Property("Estimate") + .HasColumnType("decimal(18,2)"); + + b.Property("FinancialCategoryId") + .HasColumnType("int"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("BudgetCategoryId"); + + b.HasIndex("BudgetId"); + + b.HasIndex("FinancialCategoryId"); + + b.ToTable("BudgetCategory", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetExcludedTransaction", b => + { + b.Property("BudgetExcludedTransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BudgetExcludedTransactionId")); + + b.Property("BudgetId") + .HasColumnType("int"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TransactionId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("BudgetExcludedTransactionId"); + + b.HasIndex("BudgetId"); + + b.ToTable("BudgetExcludedTransaction", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.FinancialCategory", b => + { + b.Property("FinancialCategoryId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FinancialCategoryId")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("FinancialCategoryId"); + + b.ToTable("FinancialCategory", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.InstitutionAccessItem", b => + { + b.Property("InstitutionAccessItemId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("InstitutionAccessItemId")); + + b.Property("AccessToken") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("InstitutionId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("ItemId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("InstitutionAccessItemId"); + + b.HasIndex("InstitutionId", "UserId", "TenantId") + .IsUnique() + .HasDatabaseName("AK_InstitutionAccessItem_InstitutionId_UserId"); + + b.ToTable("InstitutionAccessItem", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Merchant", b => + { + b.Property("MerchantId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsBillable") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MerchantIdentifier") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("MerchantTypeId") + .HasColumnType("int"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SelfBoardingApplication") + .HasColumnType("bit"); + + b.Property("WebsiteUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId"); + + b.HasIndex("MerchantIdentifier") + .IsUnique() + .HasDatabaseName("AK_Merchant_MerchantIdentifier"); + + b.HasIndex("MerchantTypeId"); + + b.ToTable("Merchant", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.MerchantType", b => + { + b.Property("MerchantTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantTypeId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("MerchantTypeId"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("AK_MerchantType_Name"); + + b.ToTable("MerchantType", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.OAuthState", b => + { + b.Property("OAuthStateId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OAuthStateId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("OAuthProvider") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("State") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OAuthStateId"); + + b.ToTable("OAuthState", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.OAuthToken", b => + { + b.Property("OAuthTokenId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OAuthTokenId")); + + b.Property("AccessToken") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("OAuthProvider") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Scope") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TokenType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("OAuthTokenId"); + + b.HasIndex("OAuthProvider", "UserId", "TenantId") + .IsUnique() + .HasDatabaseName("AK_OAuthProvider_UserId"); + + b.ToTable("OAuthToken", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.PriceType", b => + { + b.Property("PriceTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("PriceTypeId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsVariableCost") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("PriceTypeId"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("AK_PriceType_Name"); + + b.ToTable("PriceType", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Product", b => + { + b.Property("ProductId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ProductId")); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Cost") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DefaultTaxRates") + .HasColumnType("bit"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Grade") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsRevenue") + .HasColumnType("bit"); + + b.Property("LookupCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MerchantId") + .HasColumnType("int"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Price") + .HasColumnType("decimal(18,2)"); + + b.Property("PriceTypeId") + .HasColumnType("int"); + + b.Property("ProductTypeId") + .HasColumnType("int"); + + b.Property("SerialNumber") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Sku") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UnitTypeId") + .HasColumnType("int"); + + b.HasKey("ProductId"); + + b.HasIndex("MerchantId"); + + b.HasIndex("PriceTypeId"); + + b.HasIndex("ProductTypeId"); + + b.HasIndex("UnitTypeId"); + + b.HasIndex("SerialNumber", "TenantId") + .IsUnique() + .HasDatabaseName("AK_Product_SerialNumber") + .HasFilter("[IsDeleted] = 0"); + + b.ToTable("Product", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.ProductImage", b => + { + b.Property("ProductImageId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ProductImageId")); + + b.Property("AltText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileSize") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsStorageDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("StorageId") + .HasColumnType("uniqueidentifier"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("ProductImageId"); + + b.HasIndex("ProductId"); + + b.HasIndex("StorageId", "TenantId") + .IsUnique() + .HasDatabaseName("AK_ProductImage_StorageId"); + + b.ToTable("ProductImage", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.ProductType", b => + { + b.Property("ProductTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ProductTypeId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("ProductTypeId"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("AK_ProductType_Name"); + + b.ToTable("ProductType", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.TransactionCategory", b => + { + b.Property("TransactionCategoryId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionCategoryId")); + + b.Property("BudgetId") + .HasColumnType("int"); + + b.Property("FinancialCategoryId") + .HasColumnType("int"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TransactionId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("TransactionCategoryId"); + + b.HasIndex("BudgetId"); + + b.HasIndex("FinancialCategoryId"); + + b.ToTable("TransactionCategory", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.UnitType", b => + { + b.Property("UnitTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("UnitTypeId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("PerUnit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UnitTypeId"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("AK_UnitType_Name"); + + b.ToTable("UnitType", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetAccessItem", b => + { + b.HasOne("Elysian.Domain.Data.Budget", "Budget") + .WithMany() + .HasForeignKey("BudgetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.InstitutionAccessItem", "InstitutionAccessItem") + .WithMany() + .HasForeignKey("InstitutionAccessItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Budget"); + + b.Navigation("InstitutionAccessItem"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetCategory", b => + { + b.HasOne("Elysian.Domain.Data.Budget", "Budget") + .WithMany() + .HasForeignKey("BudgetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.FinancialCategory", "FinancialCategory") + .WithMany() + .HasForeignKey("FinancialCategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Budget"); + + b.Navigation("FinancialCategory"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetExcludedTransaction", b => + { + b.HasOne("Elysian.Domain.Data.Budget", "Budget") + .WithMany() + .HasForeignKey("BudgetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Budget"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Merchant", b => + { + b.HasOne("Elysian.Domain.Data.MerchantType", "MerchantType") + .WithMany() + .HasForeignKey("MerchantTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MerchantType"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Product", b => + { + b.HasOne("Elysian.Domain.Data.Merchant", "Merchant") + .WithMany() + .HasForeignKey("MerchantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.PriceType", "PriceType") + .WithMany() + .HasForeignKey("PriceTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.ProductType", "ProductType") + .WithMany() + .HasForeignKey("ProductTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.UnitType", "UnitType") + .WithMany() + .HasForeignKey("UnitTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Merchant"); + + b.Navigation("PriceType"); + + b.Navigation("ProductType"); + + b.Navigation("UnitType"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.ProductImage", b => + { + b.HasOne("Elysian.Domain.Data.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.TransactionCategory", b => + { + b.HasOne("Elysian.Domain.Data.Budget", "Budget") + .WithMany() + .HasForeignKey("BudgetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.FinancialCategory", "FinancialCategory") + .WithMany() + .HasForeignKey("FinancialCategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Budget"); + + b.Navigation("FinancialCategory"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Migrations/20240831180549_FixUniqueIndexes.cs b/src/Migrations/20240831180549_FixUniqueIndexes.cs new file mode 100644 index 0000000..cbe531c --- /dev/null +++ b/src/Migrations/20240831180549_FixUniqueIndexes.cs @@ -0,0 +1,100 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Elysian.Migrations +{ + /// + public partial class FixUniqueIndexes : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "AK_ProductImage_StorageId", + table: "ProductImage"); + + migrationBuilder.DropIndex( + name: "AK_Product_SerialNumber", + table: "Product"); + + migrationBuilder.DropIndex( + name: "AK_OAuthProvider_UserId", + table: "OAuthToken"); + + migrationBuilder.DropIndex( + name: "AK_InstitutionAccessItem_InstitutionId_UserId", + table: "InstitutionAccessItem"); + + migrationBuilder.CreateIndex( + name: "AK_ProductImage_StorageId", + table: "ProductImage", + columns: new[] { "StorageId", "TenantId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "AK_Product_SerialNumber", + table: "Product", + columns: new[] { "SerialNumber", "TenantId" }, + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "AK_OAuthProvider_UserId", + table: "OAuthToken", + columns: new[] { "OAuthProvider", "UserId", "TenantId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "AK_InstitutionAccessItem_InstitutionId_UserId", + table: "InstitutionAccessItem", + columns: new[] { "InstitutionId", "UserId", "TenantId" }, + unique: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropIndex( + name: "AK_ProductImage_StorageId", + table: "ProductImage"); + + migrationBuilder.DropIndex( + name: "AK_Product_SerialNumber", + table: "Product"); + + migrationBuilder.DropIndex( + name: "AK_OAuthProvider_UserId", + table: "OAuthToken"); + + migrationBuilder.DropIndex( + name: "AK_InstitutionAccessItem_InstitutionId_UserId", + table: "InstitutionAccessItem"); + + migrationBuilder.CreateIndex( + name: "AK_ProductImage_StorageId", + table: "ProductImage", + column: "StorageId", + unique: true); + + migrationBuilder.CreateIndex( + name: "AK_Product_SerialNumber", + table: "Product", + column: "SerialNumber", + unique: true, + filter: "[IsDeleted] = 0"); + + migrationBuilder.CreateIndex( + name: "AK_OAuthProvider_UserId", + table: "OAuthToken", + columns: new[] { "OAuthProvider", "UserId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "AK_InstitutionAccessItem_InstitutionId_UserId", + table: "InstitutionAccessItem", + columns: new[] { "InstitutionId", "UserId" }, + unique: true); + } + } +} diff --git a/src/Migrations/ElysianContextModelSnapshot.cs b/src/Migrations/ElysianContextModelSnapshot.cs new file mode 100644 index 0000000..ccaa759 --- /dev/null +++ b/src/Migrations/ElysianContextModelSnapshot.cs @@ -0,0 +1,911 @@ +// +using System; +using Elysian.Infrastructure.Context; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Elysian.Migrations +{ + [DbContext(typeof(ElysianContext))] + partial class ElysianContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.2") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Elysian.Domain.Data.BillTracking", b => + { + b.Property("BillTrackingId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BillTrackingId")); + + b.Property("BillNumber") + .HasColumnType("int"); + + b.Property("BillType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Congress") + .HasColumnType("int"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("BillTrackingId"); + + b.ToTable("BillTracking", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Budget", b => + { + b.Property("BudgetId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BudgetId")); + + b.Property("EndDate") + .HasColumnType("datetime2"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("BudgetId"); + + b.ToTable("Budget", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetAccessItem", b => + { + b.Property("BudgetAccessItemId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BudgetAccessItemId")); + + b.Property("BudgetId") + .HasColumnType("int"); + + b.Property("InstitutionAccessItemId") + .HasColumnType("int"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("BudgetAccessItemId"); + + b.HasIndex("BudgetId"); + + b.HasIndex("InstitutionAccessItemId"); + + b.ToTable("BudgetAccessItem", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetCategory", b => + { + b.Property("BudgetCategoryId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BudgetCategoryId")); + + b.Property("BudgetId") + .HasColumnType("int"); + + b.Property("Estimate") + .HasColumnType("decimal(18,2)"); + + b.Property("FinancialCategoryId") + .HasColumnType("int"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("BudgetCategoryId"); + + b.HasIndex("BudgetId"); + + b.HasIndex("FinancialCategoryId"); + + b.ToTable("BudgetCategory", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetExcludedTransaction", b => + { + b.Property("BudgetExcludedTransactionId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("BudgetExcludedTransactionId")); + + b.Property("BudgetId") + .HasColumnType("int"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TransactionId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("BudgetExcludedTransactionId"); + + b.HasIndex("BudgetId"); + + b.ToTable("BudgetExcludedTransaction", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.FinancialCategory", b => + { + b.Property("FinancialCategoryId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("FinancialCategoryId")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("FinancialCategoryId"); + + b.ToTable("FinancialCategory", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.InstitutionAccessItem", b => + { + b.Property("InstitutionAccessItemId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("InstitutionAccessItemId")); + + b.Property("AccessToken") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("InstitutionId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("ItemId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("InstitutionAccessItemId"); + + b.HasIndex("InstitutionId", "UserId", "TenantId") + .IsUnique() + .HasDatabaseName("AK_InstitutionAccessItem_InstitutionId_UserId"); + + b.ToTable("InstitutionAccessItem", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Merchant", b => + { + b.Property("MerchantId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsBillable") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("MerchantIdentifier") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("MerchantTypeId") + .HasColumnType("int"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("SelfBoardingApplication") + .HasColumnType("bit"); + + b.Property("WebsiteUrl") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("MerchantId"); + + b.HasIndex("MerchantIdentifier") + .IsUnique() + .HasDatabaseName("AK_Merchant_MerchantIdentifier"); + + b.HasIndex("MerchantTypeId"); + + b.ToTable("Merchant", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.MerchantType", b => + { + b.Property("MerchantTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("MerchantTypeId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("MerchantTypeId"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("AK_MerchantType_Name"); + + b.ToTable("MerchantType", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.OAuthState", b => + { + b.Property("OAuthStateId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OAuthStateId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("OAuthProvider") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("State") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("OAuthStateId"); + + b.ToTable("OAuthState", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.OAuthToken", b => + { + b.Property("OAuthTokenId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("OAuthTokenId")); + + b.Property("AccessToken") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("ExpiresAt") + .HasColumnType("datetime2"); + + b.Property("OAuthProvider") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Scope") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TokenType") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("UserId") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("OAuthTokenId"); + + b.HasIndex("OAuthProvider", "UserId", "TenantId") + .IsUnique() + .HasDatabaseName("AK_OAuthProvider_UserId"); + + b.ToTable("OAuthToken", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.PriceType", b => + { + b.Property("PriceTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("PriceTypeId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsVariableCost") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("PriceTypeId"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("AK_PriceType_Name"); + + b.ToTable("PriceType", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Product", b => + { + b.Property("ProductId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ProductId")); + + b.Property("Code") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Cost") + .HasColumnType("decimal(18,2)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("DefaultTaxRates") + .HasColumnType("bit"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Grade") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsRevenue") + .HasColumnType("bit"); + + b.Property("LookupCode") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("MerchantId") + .HasColumnType("int"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Percentage") + .HasColumnType("decimal(18,2)"); + + b.Property("Price") + .HasColumnType("decimal(18,2)"); + + b.Property("PriceTypeId") + .HasColumnType("int"); + + b.Property("ProductTypeId") + .HasColumnType("int"); + + b.Property("SerialNumber") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("Sku") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("UnitTypeId") + .HasColumnType("int"); + + b.HasKey("ProductId"); + + b.HasIndex("MerchantId"); + + b.HasIndex("PriceTypeId"); + + b.HasIndex("ProductTypeId"); + + b.HasIndex("UnitTypeId"); + + b.HasIndex("SerialNumber", "TenantId") + .IsUnique() + .HasDatabaseName("AK_Product_SerialNumber") + .HasFilter("[IsDeleted] = 0"); + + b.ToTable("Product", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.ProductImage", b => + { + b.Property("ProductImageId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ProductImageId")); + + b.Property("AltText") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("FileSize") + .HasColumnType("bigint"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("IsStorageDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ProductId") + .HasColumnType("int"); + + b.Property("StorageId") + .HasColumnType("uniqueidentifier"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.HasKey("ProductImageId"); + + b.HasIndex("ProductId"); + + b.HasIndex("StorageId", "TenantId") + .IsUnique() + .HasDatabaseName("AK_ProductImage_StorageId"); + + b.ToTable("ProductImage", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.ProductType", b => + { + b.Property("ProductTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("ProductTypeId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.HasKey("ProductTypeId"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("AK_ProductType_Name"); + + b.ToTable("ProductType", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.TransactionCategory", b => + { + b.Property("TransactionCategoryId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("TransactionCategoryId")); + + b.Property("BudgetId") + .HasColumnType("int"); + + b.Property("FinancialCategoryId") + .HasColumnType("int"); + + b.Property("TenantId") + .IsRequired() + .HasMaxLength(64) + .HasColumnType("nvarchar(64)"); + + b.Property("TransactionId") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.HasKey("TransactionCategoryId"); + + b.HasIndex("BudgetId"); + + b.HasIndex("FinancialCategoryId"); + + b.ToTable("TransactionCategory", (string)null); + + b.HasAnnotation("Finbuckle:MultiTenant", true); + }); + + modelBuilder.Entity("Elysian.Domain.Data.UnitType", b => + { + b.Property("UnitTypeId") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("UnitTypeId")); + + b.Property("CreatedAt") + .HasColumnType("datetime2"); + + b.Property("CreatedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("IsDeleted") + .HasColumnType("bit"); + + b.Property("ModifiedAt") + .HasColumnType("datetime2"); + + b.Property("ModifiedByUserId") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("PerUnit") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("UnitTypeId"); + + b.HasIndex("Name") + .IsUnique() + .HasDatabaseName("AK_UnitType_Name"); + + b.ToTable("UnitType", (string)null); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetAccessItem", b => + { + b.HasOne("Elysian.Domain.Data.Budget", "Budget") + .WithMany() + .HasForeignKey("BudgetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.InstitutionAccessItem", "InstitutionAccessItem") + .WithMany() + .HasForeignKey("InstitutionAccessItemId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Budget"); + + b.Navigation("InstitutionAccessItem"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetCategory", b => + { + b.HasOne("Elysian.Domain.Data.Budget", "Budget") + .WithMany() + .HasForeignKey("BudgetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.FinancialCategory", "FinancialCategory") + .WithMany() + .HasForeignKey("FinancialCategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Budget"); + + b.Navigation("FinancialCategory"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.BudgetExcludedTransaction", b => + { + b.HasOne("Elysian.Domain.Data.Budget", "Budget") + .WithMany() + .HasForeignKey("BudgetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Budget"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Merchant", b => + { + b.HasOne("Elysian.Domain.Data.MerchantType", "MerchantType") + .WithMany() + .HasForeignKey("MerchantTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MerchantType"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.Product", b => + { + b.HasOne("Elysian.Domain.Data.Merchant", "Merchant") + .WithMany() + .HasForeignKey("MerchantId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.PriceType", "PriceType") + .WithMany() + .HasForeignKey("PriceTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.ProductType", "ProductType") + .WithMany() + .HasForeignKey("ProductTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.UnitType", "UnitType") + .WithMany() + .HasForeignKey("UnitTypeId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Merchant"); + + b.Navigation("PriceType"); + + b.Navigation("ProductType"); + + b.Navigation("UnitType"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.ProductImage", b => + { + b.HasOne("Elysian.Domain.Data.Product", "Product") + .WithMany() + .HasForeignKey("ProductId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Product"); + }); + + modelBuilder.Entity("Elysian.Domain.Data.TransactionCategory", b => + { + b.HasOne("Elysian.Domain.Data.Budget", "Budget") + .WithMany() + .HasForeignKey("BudgetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Elysian.Domain.Data.FinancialCategory", "FinancialCategory") + .WithMany() + .HasForeignKey("FinancialCategoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Budget"); + + b.Navigation("FinancialCategory"); + }); +#pragma warning restore 612, 618 + } + } +}