Add default value for PaymentType in Walk entity

This commit introduces a default value of `1` for the `PaymentType` property in the `Walk` entity. The `SqlDbContextModelSnapshot.cs` is updated to reflect this change, and the `SqlDbContext.cs` is configured to set the default value to `WalkPaymentType.MangoPay`. A new migration class `Walk_PaymentType_DefaultSet` is created to apply these changes to the database schema, ensuring that new records in the `Walks` table will have a default `PaymentType` of `1`.
This commit is contained in:
Florian Mihalits 2025-09-15 15:35:37 +02:00
parent fafbc55732
commit 18fc3fb3f2
4 changed files with 9520 additions and 1 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace gehGassi.Persistence.Migrations
{
/// <inheritdoc />
public partial class Walk_PaymentType_DefaultSet : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "PaymentType",
table: "Walks",
type: "int",
nullable: false,
defaultValue: 1,
oldClrType: typeof(int),
oldType: "int");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<int>(
name: "PaymentType",
table: "Walks",
type: "int",
nullable: false,
oldClrType: typeof(int),
oldType: "int",
oldDefaultValue: 1);
}
}
}

View File

@ -7819,7 +7819,9 @@ namespace gehGassi.Persistence.Migrations
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("PaymentType") b.Property<int>("PaymentType")
.HasColumnType("int"); .ValueGeneratedOnAdd()
.HasColumnType("int")
.HasDefaultValue(1);
b.Property<Point>("PickupLocation") b.Property<Point>("PickupLocation")
.HasColumnType("geography"); .HasColumnType("geography");

View File

@ -383,6 +383,7 @@ namespace gehGassi.Persistence
builder.Entity<Walk>().OwnsOne(p => p.ReturnAddress); builder.Entity<Walk>().OwnsOne(p => p.ReturnAddress);
builder.Entity<Walk>().Property(c => c.Price).HasColumnType("decimal(18,2)"); builder.Entity<Walk>().Property(c => c.Price).HasColumnType("decimal(18,2)");
builder.Entity<Walk>().Property(c => c.VoucherAmmount).HasColumnType("decimal(18,2)"); builder.Entity<Walk>().Property(c => c.VoucherAmmount).HasColumnType("decimal(18,2)");
builder.Entity<Walk>().Property(c => c.PaymentType).HasDefaultValue(WalkPaymentType.MangoPay);
builder.Entity<WalkComplaint>().HasIndex(c => c.Index); builder.Entity<WalkComplaint>().HasIndex(c => c.Index);
builder.Entity<WalkComplaint>().HasOne<Walk>().WithMany().HasForeignKey(c => c.WalkId).OnDelete(DeleteBehavior.Cascade); builder.Entity<WalkComplaint>().HasOne<Walk>().WithMany().HasForeignKey(c => c.WalkId).OnDelete(DeleteBehavior.Cascade);