diff --git a/coffeecard/CoffeeCard.Library/Migrations/20230711144034_AddPurchaseTypes.cs b/coffeecard/CoffeeCard.Library/Migrations/20230711144034_AddPurchaseTypes.cs
index 37280f7c..7bce3474 100644
--- a/coffeecard/CoffeeCard.Library/Migrations/20230711144034_AddPurchaseTypes.cs
+++ b/coffeecard/CoffeeCard.Library/Migrations/20230711144034_AddPurchaseTypes.cs
@@ -20,8 +20,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
schema: "dbo",
table: "Purchases",
type: "nvarchar(max)",
- nullable: false,
- defaultValue: "");
+ nullable: true);
migrationBuilder.CreateTable(
name: "PosPurchases",
diff --git a/coffeecard/CoffeeCard.Library/Migrations/20230818201050_PurchaseTypeNonNullable.Designer.cs b/coffeecard/CoffeeCard.Library/Migrations/20230818201050_PurchaseTypeNonNullable.Designer.cs
new file mode 100644
index 00000000..32c3bc37
--- /dev/null
+++ b/coffeecard/CoffeeCard.Library/Migrations/20230818201050_PurchaseTypeNonNullable.Designer.cs
@@ -0,0 +1,580 @@
+//
+using System;
+using CoffeeCard.Library.Persistence;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+#nullable disable
+
+namespace CoffeeCard.Library.Migrations
+{
+ [DbContext(typeof(CoffeeCardContext))]
+ [Migration("20230818201050_PurchaseTypeNonNullable")]
+ partial class PurchaseTypeNonNullable
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasDefaultSchema("dbo")
+ .HasAnnotation("ProductVersion", "6.0.11")
+ .HasAnnotation("Relational:MaxIdentifierLength", 128);
+
+ SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1);
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.LoginAttempt", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("Time")
+ .HasColumnType("datetime2");
+
+ b.Property("User_Id")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("User_Id");
+
+ b.ToTable("LoginAttempts", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.PosPurhase", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("BaristaInitials")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("PurchaseId")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.HasIndex("PurchaseId");
+
+ b.ToTable("PosPurchases", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Product", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("Description")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ExperienceWorth")
+ .HasColumnType("int");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("NumberOfTickets")
+ .HasColumnType("int");
+
+ b.Property("Price")
+ .HasColumnType("int");
+
+ b.Property("Visible")
+ .HasColumnType("bit");
+
+ b.HasKey("Id");
+
+ b.ToTable("Products", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.ProductUserGroup", b =>
+ {
+ b.Property("ProductId")
+ .HasColumnType("int");
+
+ b.Property("UserGroup")
+ .HasColumnType("int");
+
+ b.HasKey("ProductId", "UserGroup");
+
+ b.ToTable("ProductUserGroups", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Programme", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("FullName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ShortName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("SortPriority")
+ .HasColumnType("int");
+
+ b.HasKey("Id");
+
+ b.ToTable("Programmes", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Purchase", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("DateCreated")
+ .HasColumnType("datetime2");
+
+ b.Property("ExternalTransactionId")
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("NumberOfTickets")
+ .HasColumnType("int");
+
+ b.Property("OrderId")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("Price")
+ .HasColumnType("int");
+
+ b.Property("ProductId")
+ .HasColumnType("int");
+
+ b.Property("ProductName")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("PurchasedById")
+ .HasColumnType("int")
+ .HasColumnName("PurchasedBy_Id");
+
+ b.Property("Status")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Type")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ExternalTransactionId");
+
+ b.HasIndex("OrderId")
+ .IsUnique();
+
+ b.HasIndex("ProductId");
+
+ b.HasIndex("PurchasedById");
+
+ b.ToTable("Purchases", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Statistic", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("ExpiryDate")
+ .HasColumnType("datetime2");
+
+ b.Property("LastSwipe")
+ .HasColumnType("datetime2");
+
+ b.Property("Preset")
+ .HasColumnType("int");
+
+ b.Property("SwipeCount")
+ .HasColumnType("int");
+
+ b.Property("UserId")
+ .HasColumnType("int")
+ .HasColumnName("User_Id");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.HasIndex("Preset", "ExpiryDate");
+
+ b.ToTable("Statistics", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Ticket", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("DateCreated")
+ .HasColumnType("datetime2");
+
+ b.Property("DateUsed")
+ .HasColumnType("datetime2");
+
+ b.Property("IsUsed")
+ .HasColumnType("bit");
+
+ b.Property("OwnerId")
+ .HasColumnType("int")
+ .HasColumnName("Owner_Id");
+
+ b.Property("ProductId")
+ .HasColumnType("int");
+
+ b.Property("PurchaseId")
+ .HasColumnType("int")
+ .HasColumnName("Purchase_Id");
+
+ b.HasKey("Id");
+
+ b.HasIndex("OwnerId");
+
+ b.HasIndex("PurchaseId");
+
+ b.ToTable("Tickets", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Token", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("TokenHash")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UserId")
+ .HasColumnType("int")
+ .HasColumnName("User_Id");
+
+ b.HasKey("Id");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Tokens", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.User", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("DateCreated")
+ .HasColumnType("datetime2");
+
+ b.Property("DateUpdated")
+ .HasColumnType("datetime2");
+
+ b.Property("Email")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("Experience")
+ .HasColumnType("int");
+
+ b.Property("IsVerified")
+ .HasColumnType("bit");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Password")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("PrivacyActivated")
+ .HasColumnType("bit");
+
+ b.Property("ProgrammeId")
+ .HasColumnType("int")
+ .HasColumnName("Programme_Id");
+
+ b.Property("Salt")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UserGroup")
+ .HasColumnType("int");
+
+ b.Property("UserState")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Email");
+
+ b.HasIndex("ProgrammeId");
+
+ b.ToTable("Users", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Voucher", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("int");
+
+ SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"), 1L, 1);
+
+ b.Property("Code")
+ .IsRequired()
+ .HasColumnType("nvarchar(450)");
+
+ b.Property("DateCreated")
+ .HasColumnType("datetime2");
+
+ b.Property("DateUsed")
+ .HasColumnType("datetime2");
+
+ b.Property("Description")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("ProductId")
+ .HasColumnType("int")
+ .HasColumnName("Product_Id");
+
+ b.Property("PurchaseId")
+ .HasColumnType("int");
+
+ b.Property("Requester")
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("UserId")
+ .HasColumnType("int")
+ .HasColumnName("User_Id");
+
+ b.HasKey("Id");
+
+ b.HasIndex("Code")
+ .IsUnique();
+
+ b.HasIndex("ProductId");
+
+ b.HasIndex("PurchaseId");
+
+ b.HasIndex("UserId");
+
+ b.ToTable("Vouchers", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.WebhookConfiguration", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("uniqueidentifier");
+
+ b.Property("LastUpdated")
+ .HasColumnType("datetime2");
+
+ b.Property("SignatureKey")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Status")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.Property("Url")
+ .IsRequired()
+ .HasColumnType("nvarchar(max)");
+
+ b.HasKey("Id");
+
+ b.ToTable("WebhookConfigurations", "dbo");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.LoginAttempt", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.User", "User")
+ .WithMany("LoginAttempts")
+ .HasForeignKey("User_Id")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.PosPurhase", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.Purchase", "Purchase")
+ .WithMany()
+ .HasForeignKey("PurchaseId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Purchase");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.ProductUserGroup", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.Product", "Product")
+ .WithMany("ProductUserGroup")
+ .HasForeignKey("ProductId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Product");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Purchase", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.Product", "Product")
+ .WithMany()
+ .HasForeignKey("ProductId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("CoffeeCard.Models.Entities.User", "PurchasedBy")
+ .WithMany("Purchases")
+ .HasForeignKey("PurchasedById")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Product");
+
+ b.Navigation("PurchasedBy");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Statistic", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.User", "User")
+ .WithMany("Statistics")
+ .HasForeignKey("UserId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Ticket", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.User", "Owner")
+ .WithMany("Tickets")
+ .HasForeignKey("OwnerId")
+ .OnDelete(DeleteBehavior.NoAction)
+ .IsRequired();
+
+ b.HasOne("CoffeeCard.Models.Entities.Purchase", "Purchase")
+ .WithMany("Tickets")
+ .HasForeignKey("PurchaseId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Owner");
+
+ b.Navigation("Purchase");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Token", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.User", "User")
+ .WithMany("Tokens")
+ .HasForeignKey("UserId");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.User", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.Programme", "Programme")
+ .WithMany("Users")
+ .HasForeignKey("ProgrammeId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Programme");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Voucher", b =>
+ {
+ b.HasOne("CoffeeCard.Models.Entities.Product", "Product")
+ .WithMany()
+ .HasForeignKey("ProductId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.HasOne("CoffeeCard.Models.Entities.Purchase", "Purchase")
+ .WithMany()
+ .HasForeignKey("PurchaseId");
+
+ b.HasOne("CoffeeCard.Models.Entities.User", "User")
+ .WithMany()
+ .HasForeignKey("UserId");
+
+ b.Navigation("Product");
+
+ b.Navigation("Purchase");
+
+ b.Navigation("User");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Product", b =>
+ {
+ b.Navigation("ProductUserGroup");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Programme", b =>
+ {
+ b.Navigation("Users");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.Purchase", b =>
+ {
+ b.Navigation("Tickets");
+ });
+
+ modelBuilder.Entity("CoffeeCard.Models.Entities.User", b =>
+ {
+ b.Navigation("LoginAttempts");
+
+ b.Navigation("Purchases");
+
+ b.Navigation("Statistics");
+
+ b.Navigation("Tickets");
+
+ b.Navigation("Tokens");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/coffeecard/CoffeeCard.Library/Migrations/20230818201050_PurchaseTypeNonNullable.cs b/coffeecard/CoffeeCard.Library/Migrations/20230818201050_PurchaseTypeNonNullable.cs
new file mode 100644
index 00000000..47e60fdb
--- /dev/null
+++ b/coffeecard/CoffeeCard.Library/Migrations/20230818201050_PurchaseTypeNonNullable.cs
@@ -0,0 +1,34 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace CoffeeCard.Library.Migrations
+{
+ public partial class PurchaseTypeNonNullable : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AlterColumn(
+ name: "Type",
+ schema: "dbo",
+ table: "Purchases",
+ type: "nvarchar(max)",
+ nullable: false,
+ oldClrType: typeof(string),
+ oldType: "nvarchar(max)",
+ oldNullable: true);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AlterColumn(
+ name: "Type",
+ schema: "dbo",
+ table: "Purchases",
+ type: "nvarchar(max)",
+ nullable: true,
+ oldClrType: typeof(string),
+ oldType: "nvarchar(max)");
+ }
+ }
+}