Introduce a 'Modified' field to track the last modification date of prospects. Automatically update this field on changes and integrate it in UI display for better transparency.
41 lines
1.1 KiB
C#
41 lines
1.1 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace FoodsharingSiegen.Server.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class ProposalModified : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AddColumn<DateTime>(
|
|
name: "Modified",
|
|
table: "Prospects",
|
|
type: "TEXT",
|
|
nullable: true);
|
|
|
|
// Fill Modified column of existing rows
|
|
migrationBuilder.Sql(@"
|
|
UPDATE Prospects
|
|
SET Modified = COALESCE(
|
|
(SELECT MAX(Created)
|
|
FROM Interactions
|
|
WHERE Interactions.ProspectID = Prospects.Id),
|
|
Prospects.Created
|
|
);
|
|
");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropColumn(
|
|
name: "Modified",
|
|
table: "Prospects");
|
|
}
|
|
}
|
|
}
|