Fix Receipt TransactionId nullable database migrations

The previous commit had the model changes but the database wasn't
properly migrated. This commit adds the missing migrations to make
TransactionId nullable in the Receipts table.

Changes:
- Updated MoneyMapContext to make Transaction relationship optional
  for Receipt (IsRequired(false))
- Created additional migrations to properly handle:
  - Making TransactionId column nullable
  - Updating the unique index to handle NULL values with WHERE clause
- Applied all migrations to database successfully

The Receipts page should now work correctly for uploading unmapped
receipts without a TransactionId.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
AJ
2025-10-12 12:32:42 -04:00
parent 8eb07c43e0
commit c306ced9f0
6 changed files with 1333 additions and 6 deletions

View File

@@ -130,11 +130,12 @@ namespace MoneyMap.Data
e.Property(x => x.Total).HasColumnType("decimal(18,2)");
e.Property(x => x.Currency).HasMaxLength(8);
// Receipt must belong to a Transaction. If txn is deleted, cascade remove receipts.
// Receipt can optionally belong to a Transaction. If txn is deleted, cascade remove receipts.
e.HasOne(x => x.Transaction)
.WithMany(t => t.Receipts)
.HasForeignKey(x => x.TransactionId)
.OnDelete(DeleteBehavior.Cascade);
.OnDelete(DeleteBehavior.Cascade)
.IsRequired(false);
});
// ---------- RECEIPT PARSE LOG ----------